[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 |
---|
[2420] | 7 | from Products.Archetypes.public import StringWidget |
---|
[2402] | 8 | from Products.Archetypes.public import MultiSelectionWidget |
---|
| 9 | from Products.Archetypes.public import LinesField |
---|
| 10 | from Products.Archetypes.public import StringField |
---|
| 11 | from Products.Archetypes.public import DisplayList |
---|
| 12 | |
---|
[2746] | 13 | from quintagroup.plonegooglesitemaps.interfaces import INewsSitemapProvider |
---|
| 14 | |
---|
[2402] | 15 | class ExtendableStringField(ExtensionField, StringField): |
---|
| 16 | """An extendable string field.""" |
---|
| 17 | |
---|
| 18 | class ExtendableLinesField(ExtensionField, LinesField): |
---|
| 19 | """An extendable string field.""" |
---|
| 20 | |
---|
[2420] | 21 | access_lst = ["Subscription", "Registration"] |
---|
| 22 | genres_lst = ["PressRelease","Satire","Blog","OpEd","Opinion","UserGenerated"] |
---|
[2402] | 23 | |
---|
| 24 | class NewsExtender(object): |
---|
[2746] | 25 | adapts(INewsSitemapProvider) |
---|
[2402] | 26 | implements(ISchemaExtender) |
---|
| 27 | |
---|
| 28 | fields = [ |
---|
| 29 | ExtendableStringField("gsm_access", |
---|
| 30 | accessor="gsm_access", |
---|
[2420] | 31 | vocabulary=DisplayList(zip(["",]+access_lst, ["Open access",]+access_lst)), |
---|
[2411] | 32 | default="", |
---|
[2402] | 33 | schemata="GoogleSitemap", |
---|
| 34 | widget = SelectionWidget( |
---|
| 35 | label="Access", |
---|
| 36 | description="Specifies whether an article is available to all " \ |
---|
| 37 | "readers (in case of the emtpy field, or only to those " \ |
---|
| 38 | "with a free or paid membership to your site.", |
---|
| 39 | format="radio"), |
---|
| 40 | ), |
---|
[2419] | 41 | ExtendableLinesField("gsm_genres", |
---|
[2402] | 42 | accessor="gsm_genres", |
---|
| 43 | vocabulary=DisplayList(zip(genres_lst, genres_lst)), |
---|
| 44 | schemata="GoogleSitemap", |
---|
[2411] | 45 | default=(), |
---|
[2402] | 46 | widget = MultiSelectionWidget( |
---|
| 47 | label="Genres", |
---|
| 48 | description="Select one or more properties for an article, " \ |
---|
| 49 | "namely, whether it is a press release, a blog post, an " \ |
---|
| 50 | "opinion, an op-ed piece, user-generated content, or satire.", |
---|
| 51 | format="checkbox"), |
---|
| 52 | ), |
---|
[2420] | 53 | ExtendableStringField("gsm_stock", |
---|
| 54 | accessor="gsm_stock", |
---|
| 55 | default="", |
---|
| 56 | schemata="GoogleSitemap", |
---|
| 57 | widget = StringWidget( |
---|
| 58 | label="Stock Tickers", |
---|
| 59 | description="A comma-separated list of up to 5 stock tickers "\ |
---|
| 60 | "of the companies, mutual funds, or other financial entities "\ |
---|
| 61 | "that are the main subject of the article. Relevant primarily "\ |
---|
| 62 | "for business articles. Each ticker must be prefixed by the "\ |
---|
| 63 | "name of its stock exchange, and must match its entry in "\ |
---|
| 64 | "Google Finance. For example, \"NASDAQ:AMAT\" (but not "\ |
---|
| 65 | "\"NASD:AMAT\"), or \"BOM:500325\" (but not \"BOM:RIL\").", |
---|
| 66 | size=70), |
---|
| 67 | ), |
---|
[2402] | 68 | ] |
---|
| 69 | |
---|
| 70 | def __init__(self, context): |
---|
| 71 | self.context = context |
---|
| 72 | |
---|
| 73 | def getFields(self): |
---|
| 74 | return self.fields |
---|