1 | from zope.component import adapts |
---|
2 | from zope.interface import implements |
---|
3 | from archetypes.schemaextender.field import ExtensionField |
---|
4 | from archetypes.schemaextender.interfaces import ISchemaExtender |
---|
5 | |
---|
6 | from Products.Archetypes.public import SelectionWidget |
---|
7 | from Products.Archetypes.public import MultiSelectionWidget |
---|
8 | from Products.Archetypes.public import LinesField |
---|
9 | from Products.Archetypes.public import StringField |
---|
10 | from Products.Archetypes.public import DisplayList |
---|
11 | |
---|
12 | class ExtendableStringField(ExtensionField, StringField): |
---|
13 | """An extendable string field.""" |
---|
14 | |
---|
15 | class ExtendableLinesField(ExtensionField, LinesField): |
---|
16 | """An extendable string field.""" |
---|
17 | |
---|
18 | access_lst = ("", "Subscription", "Registration") |
---|
19 | genres_lst = ("", "PressRelease","Satire","Blog","OpEd","Opinion","UserGenerated") |
---|
20 | |
---|
21 | class 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 | schemata="GoogleSitemap", |
---|
29 | widget = SelectionWidget( |
---|
30 | label="Access", |
---|
31 | description="Specifies whether an article is available to all " \ |
---|
32 | "readers (in case of the emtpy field, or only to those " \ |
---|
33 | "with a free or paid membership to your site.", |
---|
34 | format="radio"), |
---|
35 | ), |
---|
36 | ExtendableStringField("gsm_genres", |
---|
37 | accessor="gsm_genres", |
---|
38 | vocabulary=DisplayList(zip(genres_lst, genres_lst)), |
---|
39 | schemata="GoogleSitemap", |
---|
40 | widget = MultiSelectionWidget( |
---|
41 | label="Genres", |
---|
42 | description="Select one or more properties for an article, " \ |
---|
43 | "namely, whether it is a press release, a blog post, an " \ |
---|
44 | "opinion, an op-ed piece, user-generated content, or satire.", |
---|
45 | format="checkbox"), |
---|
46 | ), |
---|
47 | ] |
---|
48 | |
---|
49 | def __init__(self, context): |
---|
50 | self.context = context |
---|
51 | |
---|
52 | def getFields(self): |
---|
53 | return self.fields |
---|