source: products/quintagroup.plonegooglesitemaps/trunk/quintagroup/plonegooglesitemaps/content/newsextender.py @ 2419

Last change on this file since 2419 was 2419, checked in by mylan, 14 years ago

#131: Fix gsm_genres field type

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1from zope.component import adapts
2from zope.interface import implements
3from archetypes.schemaextender.field import ExtensionField
4from archetypes.schemaextender.interfaces import ISchemaExtender
5
6from Products.Archetypes.public import SelectionWidget
7from Products.Archetypes.public import MultiSelectionWidget
8from Products.Archetypes.public import LinesField
9from Products.Archetypes.public import StringField
10from Products.Archetypes.public import DisplayList
11
12class ExtendableStringField(ExtensionField, StringField):
13    """An extendable string field."""
14
15class ExtendableLinesField(ExtensionField, LinesField):
16    """An extendable string field."""
17
18access_lst = ("", "Subscription", "Registration")
19genres_lst = ("", "PressRelease","Satire","Blog","OpEd","Opinion","UserGenerated")
20
21class NewsExtender(object):
22    implements(ISchemaExtender)
23
24    fields = [
25        ExtendableStringField("gsm_access",
26            accessor="gsm_access",
27            vocabulary=DisplayList(zip(access_lst, access_lst)),
28            default="",
29            schemata="GoogleSitemap",
30            widget = SelectionWidget(
31                label="Access",
32                description="Specifies whether an article is available to all " \
33                    "readers (in case of the emtpy field, or only to those " \
34                    "with a free or paid membership to your site.",
35                format="radio"),
36        ),
37        ExtendableLinesField("gsm_genres",
38            accessor="gsm_genres",
39            vocabulary=DisplayList(zip(genres_lst, genres_lst)),
40            schemata="GoogleSitemap",
41            default=(),
42            widget = MultiSelectionWidget(
43                label="Genres",
44                description="Select one or more properties for an article, " \
45                    "namely, whether it is a press release, a blog post, an " \
46                    "opinion, an op-ed piece, user-generated content, or satire.",
47                format="checkbox"),
48        ),
49    ]
50
51    def __init__(self, context):
52        self.context = context
53
54    def getFields(self):
55        return self.fields
Note: See TracBrowser for help on using the repository browser.