source: trunk/Story.py @ 72

Revision 72, 4.5 KB checked in by meelis, 14 years ago (diff)

references #133 Story content type created has all described functionalities, but some of them has to be modified for better look

  • Property svn:eol-style set to native
Line 
1from Products.Archetypes.public import BaseSchema, Schema
2from Products.Archetypes.public import StringField, LinesField, TextField, ReferenceField
3from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget, RichWidget
4from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget
5from WYSIWYM import WYSIWYMField, WYSIWYMWidget
6from Products.CMFCore.permissions import ModifyPortalContent
7from Products.Archetypes.public import BaseContent, registerType
8from Globals import InitializeClass
9from Products.CMFCore.utils import getToolByName
10from AccessControl import ClassSecurityInfo, Unauthorized
11from config import PROJECTNAME
12
13schema = BaseSchema + Schema((
14    TextField('description',
15        accessor="Description",
16        widget=TextAreaWidget(
17            label="Description",
18            label_msgid="label_description",
19            description="Description here",
20            description_msgid="desc_description",
21            i18n_domain="toolbox"),
22        ),
23    WYSIWYMField('body',
24        required=True,
25        primary=False,
26        languageIndependent=False,
27        widget=WYSIWYMWidget(
28            label="Body",
29            label_msgid="label_body",
30            description="Story body",
31            description_msgid="desc_body",
32            i18n_domain="toolbox",),
33        ),
34    LinesField('tags',
35        widget=LinesWidget(
36            label="Tags",
37            label_msgid="label_tags",
38            description="Write the tags here",
39            description_msgid="desc_tags",
40            i18n_domain="toolbox"
41        ),
42    ),
43    ReferenceField('relatedContent',
44        relationship = 'relatesTo',
45        multiValued = True,
46        isMetadata = True,
47        languageIndependent = False,
48        index = 'KeywordIndex',
49        write_permission = ModifyPortalContent,
50        allowed_types=('Document','Pice','Content','Material'),
51        widget = ReferenceBrowserWidget(
52            allow_search = True,
53            allow_browse = True,
54            show_indexes = False,
55            force_close_on_insert = True,
56            startup_directory = "content",
57            size = 4,
58
59            label = "Related Content",
60            label_msgid = "label_related_content",
61            description = "",
62            description_msgid = "help_related_content",
63            i18n_domain = "toolbox",
64            visible = {'edit' : 'visible', 'view' : 'invisible' }
65            )
66        ),
67    ReferenceField('relatedActivities',
68        relationship = 'relatesToActivities',
69        multiValued = True,
70        isMetadata = True,
71        languageIndependent = False,
72        index = 'KeywordIndex',
73        write_permission = ModifyPortalContent,
74        allowed_types=('Document','Activity',),
75        widget = ReferenceBrowserWidget(
76            allow_search = True,
77            allow_browse = True,
78            show_indexes = False,
79            force_close_on_insert = True,
80            startup_directory = "activities",
81            size = 4,
82
83            label = "Related Activities",
84            label_msgid = "label_related_activities",
85            description = "",
86            description_msgid = "help_related_activities",
87            i18n_domain = "toolbox",
88            visible = {'edit' : 'visible', 'view' : 'invisible' }
89            )
90        ),
91    ReferenceField('relatedTools',
92        relationship = 'relatesToTools',
93        multiValued = True,
94        isMetadata = True,
95        languageIndependent = False,
96        index = 'KeywordIndex',
97        write_permission = ModifyPortalContent,
98        allowed_types=('Document','Tool',),
99        widget = ReferenceBrowserWidget(
100            allow_search = True,
101            allow_browse = True,
102            show_indexes = False,
103            force_close_on_insert = True,
104            startup_directory = "tools",
105            size = 4,
106
107            label = "Related Tools",
108            label_msgid = "label_related_tools",
109            description = "",
110            description_msgid = "help_related_tools",
111            i18n_domain = "toolbox",
112            visible = {'edit' : 'visible', 'view' : 'invisible' }
113            )
114        )
115))
116
117class Story(BaseContent):
118    schema = schema
119    actions= (
120    {
121    'id':'view',
122    'name':'view',
123    'action':'string:${object_url}/story_view',
124    'premission':('View',),
125    },
126    {
127    'id':'edit',
128    'name':'Edit',
129    'action':'string:${object_url}/story_edit',
130    'premission':('View',),
131    },
132    )
133    meta_type = "Story"
134    archetype_name = "Story" 
135    global_allow = 1
136
137
138registerType(Story, PROJECTNAME)
Note: See TracBrowser for help on using the repository browser.