[2402] | 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)), |
---|
[2411] | 28 | default="", |
---|
[2402] | 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 | ExtendableStringField("gsm_genres", |
---|
| 38 | accessor="gsm_genres", |
---|
| 39 | vocabulary=DisplayList(zip(genres_lst, genres_lst)), |
---|
| 40 | schemata="GoogleSitemap", |
---|
[2411] | 41 | default=(), |
---|
[2402] | 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 |
---|