Guest User

Untitled

a guest
May 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. #
  3. # GNU General Public License (GPL)
  4. #
  5. __author__ = """Johannes Raggam <johannes@raggam.co.at>"""
  6. __docformat__ = 'plaintext'
  7.  
  8. from plone.portlets.interfaces import IPortletDataProvider
  9. from plone.app.portlets.portlets import base
  10. from zope import schema
  11. from zope.interface import implements
  12. from zope.formlib import form
  13. from zope.app.form.browser import TextWidget
  14.  
  15. from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
  16.  
  17.  
  18. class CustomTextWidget(TextWidget):
  19. displayWidth = 80
  20.  
  21.  
  22. class IMottoPortlet(IPortletDataProvider):
  23. """A portlet which renders predefined static HTML to display a motto.
  24. """
  25. motto_author = schema.TextLine(
  26. title = u"Motto Autor",
  27. description = u"Urheber des Spruchs",
  28. required=True)
  29.  
  30. motto_text = schema.Text(
  31. title = u"Text",
  32. description = u"Motto Text",
  33. required=True)
  34.  
  35.  
  36. class Assignment(base.Assignment):
  37. implements(IMottoPortlet)
  38.  
  39. motto_author = u"Motto portlet"
  40. motto_text = u""
  41.  
  42. def __init__(self, motto_author=u"", motto_text=u""):
  43. self.motto_author = motto_author
  44. self.motto_text = motto_text
  45.  
  46. @property
  47. def title(self):
  48. return self.motto_author
  49.  
  50.  
  51. class Renderer(base.Renderer):
  52. render = ViewPageTemplateFile('motto_portlet.pt')
  53.  
  54.  
  55. class AddForm(base.AddForm):
  56. form_fields = form.Fields(IMottoPortlet)
  57. form_fields['motto_author'].custom_widget = CustomTextWidget
  58. label = u"Motto portlet hinzufügen"
  59. description = u"Dieses Portlet zeigt einen Spruch auf der Website an."
  60.  
  61. def create(self, data):
  62. return Assignment(**data)
  63.  
  64.  
  65. class EditForm(base.EditForm):
  66. form_fields = form.Fields(IMottoPortlet)
  67. form_fields['motto_author'].custom_widget = CustomTextWidget
  68. label = u"Motto portlet bearbeiten"
  69. description = u"Dieses Portlet zeigt einen Spruch auf der Website an."
Add Comment
Please, Sign In to add comment