source: products/quintagroup.plonegooglesitemaps/tags/1.4.4/quintagroup/plonegooglesitemaps/content/newsextender.py

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

#131: Added 'stock_tickers' tag to newssitemap view, news extender schema

  • Property svn:eol-style set to native
File size: 2.9 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 StringWidget
8from Products.Archetypes.public import MultiSelectionWidget
9from Products.Archetypes.public import LinesField
10from Products.Archetypes.public import StringField
11from Products.Archetypes.public import DisplayList
12
13class ExtendableStringField(ExtensionField, StringField):
14    """An extendable string field."""
15
16class ExtendableLinesField(ExtensionField, LinesField):
17    """An extendable string field."""
18
19access_lst = ["Subscription", "Registration"]
20genres_lst = ["PressRelease","Satire","Blog","OpEd","Opinion","UserGenerated"]
21
22class 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
Note: See TracBrowser for help on using the repository browser.