1 | from zope.interface import implements |
---|
2 | |
---|
3 | from plone.portlets.interfaces import IPortletDataProvider |
---|
4 | from plone.app.portlets.portlets import base |
---|
5 | |
---|
6 | from zope import schema |
---|
7 | from zope.formlib import form |
---|
8 | from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile |
---|
9 | |
---|
10 | from quintagroup.portlet.map import QGMapPortletMessageFactory as _ |
---|
11 | |
---|
12 | |
---|
13 | class IQGMapPortlet(IPortletDataProvider): |
---|
14 | """A portlet |
---|
15 | |
---|
16 | It inherits from IPortletDataProvider because for this portlet, the |
---|
17 | data that is being rendered and the portlet assignment itself are the |
---|
18 | same. |
---|
19 | """ |
---|
20 | |
---|
21 | # TODO: Add any zope.schema fields here to capture portlet configuration |
---|
22 | # information. Alternatively, if there are no settings, leave this as an |
---|
23 | # empty interface - see also notes around the add form and edit form |
---|
24 | # below. |
---|
25 | |
---|
26 | # some_field = schema.TextLine(title=_(u"Some field"), |
---|
27 | # description=_(u"A field to use"), |
---|
28 | # required=True) |
---|
29 | |
---|
30 | |
---|
31 | class Assignment(base.Assignment): |
---|
32 | """Portlet assignment. |
---|
33 | |
---|
34 | This is what is actually managed through the portlets UI and associated |
---|
35 | with columns. |
---|
36 | """ |
---|
37 | |
---|
38 | implements(IQGMapPortlet) |
---|
39 | |
---|
40 | # TODO: Set default values for the configurable parameters here |
---|
41 | |
---|
42 | # some_field = u"" |
---|
43 | |
---|
44 | # TODO: Add keyword parameters for configurable parameters here |
---|
45 | # def __init__(self, some_field=u""): |
---|
46 | # self.some_field = some_field |
---|
47 | |
---|
48 | def __init__(self): |
---|
49 | pass |
---|
50 | |
---|
51 | @property |
---|
52 | def title(self): |
---|
53 | """This property is used to give the title of the portlet in the |
---|
54 | "manage portlets" screen. |
---|
55 | """ |
---|
56 | return "Quintagroup Google Map portlet" |
---|
57 | |
---|
58 | |
---|
59 | class Renderer(base.Renderer): |
---|
60 | """Portlet renderer. |
---|
61 | |
---|
62 | This is registered in configure.zcml. The referenced page template is |
---|
63 | rendered, and the implicit variable 'view' will refer to an instance |
---|
64 | of this class. Other methods can be added and referenced in the template. |
---|
65 | """ |
---|
66 | |
---|
67 | render = ViewPageTemplateFile('qgmapportlet.pt') |
---|
68 | |
---|
69 | |
---|
70 | class AddForm(base.AddForm): |
---|
71 | """Portlet add form. |
---|
72 | |
---|
73 | This is registered in configure.zcml. The form_fields variable tells |
---|
74 | zope.formlib which fields to display. The create() method actually |
---|
75 | constructs the assignment that is being added. |
---|
76 | """ |
---|
77 | form_fields = form.Fields(IQGMapPortlet) |
---|
78 | |
---|
79 | def create(self, data): |
---|
80 | return Assignment(**data) |
---|
81 | |
---|
82 | |
---|
83 | # NOTE: If this portlet does not have any configurable parameters, you |
---|
84 | # can use the next AddForm implementation instead of the previous. |
---|
85 | |
---|
86 | # class AddForm(base.NullAddForm): |
---|
87 | # """Portlet add form. |
---|
88 | # """ |
---|
89 | # def create(self): |
---|
90 | # return Assignment() |
---|
91 | |
---|
92 | |
---|
93 | # NOTE: If this portlet does not have any configurable parameters, you |
---|
94 | # can remove the EditForm class definition and delete the editview |
---|
95 | # attribute from the <plone:portlet /> registration in configure.zcml |
---|
96 | |
---|
97 | |
---|
98 | class EditForm(base.EditForm): |
---|
99 | """Portlet edit form. |
---|
100 | |
---|
101 | This is registered with configure.zcml. The form_fields variable tells |
---|
102 | zope.formlib which fields to display. |
---|
103 | """ |
---|
104 | form_fields = form.Fields(IQGMapPortlet) |
---|