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