source: trunk/Schemata.py @ 3065

Revision 3065, 13.7 KB checked in by jukka, 9 years ago (diff)

Fixing stylesheets for edit pages.

Line 
1# Copyright 2006 by the LeMill Team (see AUTHORS)
2#
3# This file is part of LeMill.
4#
5# LeMill is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# LeMill is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with LeMill; if not, write to the Free Software
17# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19
20#These are common pieces of schema for content types
21from Products.Archetypes.public import *
22from FieldsWidgets import *
23from config import LICENSES, ALL_LICENSES, SUBJECT_AREAS, TARGET_GROUPS
24
25
26# Modifications that need to affect globally
27BaseSchema['effectiveDate'].widget.visible = {'edit':'invisible', 'view':'invisible'}
28BaseSchema['expirationDate'].widget.visible = {'edit':'invisible', 'view':'invisible'}
29
30
31
32state = Schema((
33    StringField('state',
34              searchable=False,
35              index='FieldIndex:schema',
36              widget = StringWidget(
37                  visible = {'view':'invisible', 'edit':'invisible'},
38                  ),
39              )
40))
41
42editing_settings = Schema((
43    StringField('editingMode',
44              vocabulary = DisplayList((
45                  ("anybody_can_edit", "Anybody can edit this learning resource"),
46                  ("other_users_can_edit_a_copy", "Other users can only edit a copy of this resource"),
47              )),
48              schemata='metadata',
49              accessor='getEditingMode',
50              mutator='setEditingMode',
51              searchable=False,
52              default='anybody_can_edit',
53              widget = SelectionWidget(
54                  condition='object/allowSettingOfEditingPermissions',# Condition to show widget or not
55                  format = 'radio',
56                  visible = {'view':'invisible', 'edit':'visible'},
57                  ),
58              ),
59    BooleanField('hideDrafts',
60              default=True,
61              schemata='metadata',
62              accessor='getHideDrafts',
63              mutator='setHideDrafts',
64              searchable=False,
65              widget = BooleanWidget(
66                  condition='object/allowSettingOfEditingPermissions',
67                  visible = {'view':'invisible', 'edit':'visible'},
68                  label = 'Draft version is hidden from other users',
69                  label_msgid = 'label_hide_drafts',
70                  i18n_domain = 'lemill',
71                  ),
72              ),
73))
74
75bodytext = Schema((
76    WYSIWYMField('bodyText',
77                 accessor="getBodyText",
78                 mutator = "setBodyText",
79                 edit_accessor = 'getRawBodyText',
80                 index='ZCTextIndex',
81                 copied_in_translation=True,
82                 searchable = True,
83                 widget=LeVisualWidget(label = "Body text",
84                                      label_msgid = "label_wysiwym_body_text",
85                                      i18n_domain = "lemill",
86                                      ),
87                ),
88))
89
90
91description = Schema((
92    StringField('description',
93        index=None,
94        searchable=True,
95        schemata="metadata",
96        widget=LeTextAreaWidget(
97            rows = 2,
98            label="Description",
99            label_msgid="label_description",
100            i18n_domain="lemill"),
101    )
102))
103
104no_description = Schema((
105    StringField('description',
106        searchable=False,
107        schemata = "metadata",
108        widget = LeTextAreaWidget(
109            visible={'view':'invisible','edit':'invisible'}
110        ),
111    ),
112))
113
114language_schema = Schema((
115    StringField(
116            'language',
117            index='FieldIndex:schema',
118            schemata="metadata",
119            accessor="Language",
120            default_method ='defaultLanguage',
121            vocabulary='getLanguagelist',
122            widget=SelectionWidget(
123                label='Language',
124                label_msgid="label_language",
125                i18n_domain="lemill"
126                ),
127        ),
128))
129
130license_schema = Schema((
131   StringField('rights',
132       schemata="metadata",
133       default = "CreativeCommons",
134       copied_in_translation=True,
135       vocabulary=DisplayList((LICENSES)),
136       widget=CopyrightWidget(
137           visible={'edit':'visible'},
138                label='Rights',
139                label_msgid='label_rights',
140                i18n_domain="lemill",
141                use_label=0
142           ),
143       ),
144))
145
146
147latest_edit_schema = Schema((
148   ComputedField('latestEdit',
149        index = 'DateIndex:schema',
150        copied_in_translation=True,
151        expression = 'here.getLatestEditDate()',
152        widget=ComputedWidget(
153            visible={'edit':'invisible', 'view':'invisible'}
154            ),
155        ),
156))
157
158# Overwrite some Archetypes ExtensibleMetadata.py field definitions to make them go away.
159lemill_metadata_mods = Schema((
160    StringField(
161        name='title',
162        required=1,
163        searchable=1,
164        default='',
165        accessor='Title',
166        copied_in_translation=True,
167        widget=LeStringWidget(
168            label_msgid='label_title',
169            visible={'view' : 'invisible'},
170            i18n_domain='plone',
171        ),
172    ),
173   StringField('allowDiscussion',
174       default='0',
175       widget=SelectionWidget(
176           visible={'view':'invisible','edit':'invisible'}
177           ),
178       ),
179   LinesField('subject',
180       searchable=False,
181       index=None,
182       widget=KeywordWidget(
183           visible={'view':'invisible','edit':'invisible'}
184           ),
185       ),
186   LinesField('contributors',
187       widget=LinesWidget(
188           visible={'view':'invisible','edit':'invisible'}
189           ),
190       ),
191   LinesField('relatedItems',
192       searchable=False,
193       index=None,
194       widget=KeywordWidget(
195           visible={'view':'invisible','edit':'invisible'}
196           ),
197       ),
198   
199))
200
201
202tags = Schema((
203   TagsField('tags',
204        index="KeywordIndex:schema",
205        accessor="getTags",
206        searchable=True,
207        widget=TagsWidget(
208            label="Tags",
209            label_msgid="label_tags",
210            description="Enter descriptive tags for this resource, separated by commas.",
211            description_msgid="help_tags",
212            i18n_domain="lemill"
213        ),
214        schemata="metadata",
215    ),
216))
217
218coverImage = Schema((
219    ImageField('coverImage',
220               schemata="metadata",
221               required=False,
222               accessor='getCoverImage',
223               mutator='setCoverImage',
224               swallowResizeExceptions=True,
225               copied_in_translation=True,
226               original_size=(120,120),
227               widget = ImageWidget(
228                   visible={'view':'invisible','edit':'invisible'},
229                   ),
230               ),
231    BooleanField('hasCoverImage',
232                default=False,
233                index="FieldIndex:schema",
234                accessor='getHasCoverImage',
235                mutator='setHasCoverImage',
236                copied_in_translation=True,
237                widget = BooleanWidget(
238                    visible = {'view':'invisible', 'edit':'invisible'},
239                    ),
240                ),
241))
242
243author_schema = Schema((
244    LinesField('creators',
245              schemata="metadata",
246              searchable=True,
247              accessor='getAuthorsNames',
248              widget = StringWidget(
249                  visible = {'view':'invisible', 'edit':'invisible'},
250                  ),
251              )
252))
253
254
255
256
257translation_schema = Schema((
258    ReferenceField('translation_of',
259        relationship = 'translates',
260        widget = ReferenceWidget(
261            label="Translation of",
262            label_msgid="label_translation_of",           
263            visible = { 'view': 'visible', 'edit': 'invisible' },
264            i18n_domain="lemill"
265        ),
266    ),
267    ReferenceField('translations',
268        relationship = 'has translations',
269        multiValued = True,
270        widget = ReferenceWidget(
271            label="Translations",
272            label_msgid="label_translations",           
273            visible = { 'view': 'visible', 'edit': 'invisible' },
274            i18n_domain="lemill"
275        ),
276    ),
277))
278
279branching_schema = Schema((
280    ReferenceField('branch_of',
281        relationship = 'branches',
282        widget = ReferenceWidget(
283            label = "Branch of",
284            visible = { 'view': 'visible', 'edit': 'invisible' },
285            i18n_domain = "lemill"
286        ),
287    ),
288    ReferenceField('branches',
289        relationship = 'has branches',
290        multiValued = True,
291        widget = ReferenceWidget(
292            label = "Branches",
293            visible = { 'view': 'visible', 'edit': 'invisible' },
294            i18n_domain = "lemill"
295        ),
296    ),
297))
298
299group_sharing = Schema((
300    ReferenceField('groupEditing',
301        relationship = "is_edited_by",
302        schemata = 'metadata',
303        index="KeywordIndex:schema",
304        vocabulary = 'getUserGroups',
305        enforceVocabulary = False,
306        multiValued = True,
307        copied_in_translation=False,
308        copied_in_branching=False,
309        widget=GroupWidget(
310            label="Assigned group",
311            label_msgid="label_assigned_group",
312            description="Assign one of your groups to work with this resource.",
313            description_msgid="help_resource_group",
314            i18n_domain="lemill",
315            visible={'edit': 'visible', 'view': 'invisible'},
316            ),
317        ),
318
319
320    ))
321
322target_group_schema = Schema((
323    LinesField('target_group',
324        vocabulary = DisplayList(zip(TARGET_GROUPS,TARGET_GROUPS)),
325        index = "KeywordIndex:schema",
326        multivalued=True,
327        copied_in_translation=True,
328        schemata="metadata",
329        widget=TwoColumnMultiSelectionWidget(
330            format="checkbox",
331            label="Target group",
332            label_msgid="label_target_group",
333            i18n_domain="lemill",
334        ),
335    ),
336))
337
338subject_area_schema = Schema((
339    LinesField('subject_area',
340        vocabulary = DisplayList(zip(SUBJECT_AREAS,SUBJECT_AREAS)),
341        index = "KeywordIndex:schema",
342        multivalued=True,
343        copied_in_translation=True,
344        schemata="metadata",
345        widget=TwoColumnMultiSelectionWidget(
346            format="checkbox",
347            label="Subject area",
348            label_msgid="label_subject_area",
349            i18n_domain="lemill",
350        ),
351    ),
352))
353
354deletionReason = Schema((
355    StringField('deletionReason',
356        searchable=False,
357        schemata = "metadata",
358        widget = TextAreaWidget(
359            visible={'view':'invisible','edit':'invisible'}
360        ),
361    ),
362))
363
364# Jukka 11.4: Removed ieee_lom_lre_ap. These shouldn't be handled with separate fields, write adapters instead.
365
366
367score = Schema((
368    IntegerField('score',
369        index = 'FieldIndex:schema',
370        default = 1,
371        widget = IntegerWidget(
372                 visible = {'view':'invisible', 'edit':'invisible'},
373             ),
374        ),
375))
376
377links_schema=Schema((
378   LeMillLinksField('contentLinks',
379        accessor="getContentLinks",
380        mutator = "setContentLinks",
381        copied_in_translation=True,
382        index=None,
383        widget=LeMillLinksWidget(label = "Content",
384            label_msgid = "label_content",
385            description = "Learning resources that are used in the project. You can write here information about printed resources or copy addresses of web resources and LeMill content.",
386            description_msgid = "help_project_content",
387            rows = 6,
388            i18n_domain = "lemill",
389            visible ={'edit':'visible', 'view':'visible'}
390            ),
391    ),
392   LeMillLinksField('methodsLinks',
393        accessor="getMethodsLinks",
394        mutator = "setMethodsLinks",
395        copied_in_translation=True,
396        index=None,
397        widget=LeMillLinksWidget(label = "Methods",
398            label_msgid = "label_methods",
399            description = "Instructional methods that are used in the project. You can copy here web addresses of LeMill methods.",
400            description_msgid = "help_project_methods",
401            rows = 6,
402            i18n_domain = "lemill",
403            visible ={'edit':'visible', 'view':'visible'}
404            ),
405    ),
406   LeMillLinksField('toolsLinks',
407        accessor="getToolsLinks",
408        mutator = "setToolsLinks",
409        copied_in_translation=True,
410        index=None,
411        widget=LeMillLinksWidget(label = "Tools",
412            label_msgid = "label_tools",
413            description = "Tools that are used in the project. You can copy here web addresses of LeMill tools.",
414            description_msgid = "help_project_tools",
415            rows = 6,
416            i18n_domain = "lemill",
417            visible ={'edit':'visible', 'view':'visible'}
418            ),
419    ),
420))
421
422site_address = Schema((
423    StringField('address',
424        default= "http://",
425        index=None,
426        copied_in_translation=True,
427        searchable=True,
428        widget = HTMLLinkWidget(
429            label="Homepage URL",
430            label_msgid="label_homepage_url",
431            i18n_domain="lemill"
432        ),
433    ),
434))
435
436# Base schemas for LeMill archetype definitions
437
438resource_schema = BaseSchema + score + state + lemill_metadata_mods + deletionReason + latest_edit_schema + tags
439
440learning_resource_schema = resource_schema + language_schema + coverImage
441
442material_schema = learning_resource_schema + subject_area_schema + target_group_schema
443
444community_editing_schema = group_sharing + license_schema + author_schema + translation_schema
445
446draft_schema = editing_settings + branching_schema
447
Note: See TracBrowser for help on using the repository browser.