source: trunk/SharedMetadata.py @ 1919

Revision 1919, 17.5 KB checked in by jukka, 12 years ago (diff)

Refactored groups to not use portal_groups. Things should be faster and users from weird sources shouldn't cause so much problems. Not much tested yet, but archetype update and quickinstaller reinstall works fine.

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
24
25# Modifications that need to affect globally
26BaseSchema['effectiveDate'].widget.visible = {'edit':'invisible', 'view':'invisible'}
27BaseSchema['expirationDate'].widget.visible = {'edit':'invisible', 'view':'invisible'}
28
29bodytext = Schema((
30    WYSIWYMField('bodyText',
31                 accessor="getBodyText",
32                 mutator = "setBodyText",
33                 edit_accessor = 'getRawBodyText',
34                 index='ZCTextIndex:schema',
35                 searchable = True,
36                 widget=LeVisualWidget(label = "Body text",
37                                      label_msgid = "label_wysiwym_body_text",
38                                      i18n_domain = "lemill",
39                                      ),
40                ),
41))
42
43bodytext_simple = Schema((
44    WYSIWYMField('bodyText',
45                 accessor="getBodyText",
46                 mutator = "setBodyText",
47                 edit_accessor = 'getRawBodyText',
48                 index='ZCTextIndex:schema',
49                 searchable = True,
50                 widget=LeTextAreaWidget(
51                    label="Body text",
52                    label_msgid="label_wysiwym_body_text",
53                    i18n_domain="lemill"),
54                 ),
55))
56
57description = Schema((
58    StringField('description',
59        index="ZCTextIndex:schema",
60        searchable=True,
61        schemata="metadata",
62        widget=LeTextAreaWidget(
63            rows = 2,
64            label="Description",
65            label_msgid="label_description",
66            i18n_domain="lemill"),
67    )
68))
69
70no_description = Schema((
71    StringField('description',
72        searchable=False,
73        schemata = "metadata",
74        widget = LeTextAreaWidget(
75            visible={'view':'invisible','edit':'invisible'}
76        ),
77    ),
78))
79
80language_schema = Schema((
81    StringField(
82            'language',
83            index='FieldIndex:schema',
84            schemata="metadata",
85            accessor="Language",
86            default_method ='defaultLanguage',
87            vocabulary='getLanguagelist',
88            widget=SelectionWidget(
89                label='Language',
90                label_msgid="label_language",
91                description="Select the language of this resource.",
92                description_msgid="help_language",
93                i18n_domain="lemill"
94                ),
95        ),
96))
97
98license_schema = Schema((
99   TextField('rights',
100       schemata="metadata",
101       default = "CreativeCommons",
102       vocabulary=DisplayList((LICENSES)),
103       widget=CopyrightWidget(
104           visible={'edit':'visible'},
105                label='License',
106                label_msgid='label_license',
107                i18n_domain="lemill"
108           ),
109       ),
110))
111
112piece_license_schema = Schema((
113   TextField('rights',
114       schemata="metadata",
115       default = "CreativeCommons",
116       vocabulary=DisplayList((ALL_LICENSES)),
117       widget=CopyrightWidget(
118                visible={'view':'visible','edit':'visible'},
119                label='License',
120                label_msgid='label_license',
121                i18n_domain="lemill"
122           ),
123       ),
124))
125license_schema = Schema((
126   TextField('rights',
127       schemata="metadata",
128       default = "CreativeCommons",
129       vocabulary=DisplayList((LICENSES)),
130       widget=CopyrightWidget(
131           visible={'edit':'visible'}
132           ),
133       ),
134))
135
136latest_edit_schema = Schema((
137   ComputedField('latestEdit',
138        index = 'DateIndex:schema',
139        expression = 'here.getLatestEditDate()',
140        widget=ComputedWidget(
141            visible={'edit':'invisible', 'view':'invisible'}
142            ),
143        ),
144))
145
146# Overwrite some Archetypes ExtensibleMetadata.py field definitions to make them go away.
147lemill_metadata_mods = Schema((
148    StringField(
149        name='title',
150        required=1,
151        searchable=1,
152        default='',
153        accessor='Title',
154        widget=LeStringWidget(
155            label_msgid='label_title',
156            visible={'view' : 'invisible'},
157            i18n_domain='plone',
158        ),
159    ),
160   StringField('allowDiscussion',
161       default='0',
162       widget=SelectionWidget(
163           visible={'view':'invisible','edit':'invisible'}
164           ),
165       ),
166   LinesField('subject',
167       searchable=False,
168       widget=KeywordWidget(
169           visible={'view':'invisible','edit':'invisible'}
170           ),
171       ),
172   LinesField('contributors',
173       widget=LinesWidget(
174           visible={'view':'invisible','edit':'invisible'}
175           ),
176       ),
177))
178
179
180tags = Schema((
181   TagsField('tags',
182        index="KeywordIndex:schema",
183        accessor="getTags",
184        searchable=True,
185        widget=TagsWidget(
186            label="Tags",
187            label_msgid="label_tags",
188            description="Enter descriptive tags for this resource, separated by commas.",
189            description_msgid="help_tags",
190            i18n_domain="lemill"
191        ),
192        schemata="metadata",
193    ),
194))
195
196coverImage = Schema((
197    ImageField('coverImage',
198               schemata="metadata",
199               required=False,
200               accessor='getCoverImage',
201               mutator='setCoverImage',
202               swallowResizeExceptions=True,
203               original_size=(120,120),
204               widget = ImageWidget(
205                   visible={'view':'invisible','edit':'invisible'},
206                   ),
207               ),
208    BooleanField('hasCoverImage',
209                default=False,
210                index="FieldIndex:schema",
211                accessor='getHasCoverImage',
212                mutator='setHasCoverImage',
213                widget = BooleanWidget(
214                    visible = {'view':'invisible', 'edit':'invisible'},
215                    ),
216                ),
217    ImageField('originalCoverImage',
218        schemata = "metadata",
219        required=False,
220        accessor='getOriginalCoverImage',
221        mutator='setOriginalCoverImage',
222        widget = ImageWidget(
223            visible = {'view': 'invisible', 'edit':'invisible'},
224            ),
225        ),
226))
227
228author_schema = Schema((
229    LinesField('creators',
230              schemata="metadata",
231              searchable=True,
232              accessor='getAuthorsNames',
233              widget = StringWidget(
234                  visible = {'view':'invisible', 'edit':'invisible'},
235                  ),
236              )
237))
238
239original_author_schema = Schema((
240    StringField('originalAuthor',
241              schemata="metadata",
242              seachable=True,
243              widget = LeStringWidget(
244                  visible = {'view':'invisible', 'edit':'visible'},
245                  label='Original author',
246                  label_msgid='label_original_author',
247                  i18n_domain="lemill",
248                  ),
249              )
250))
251
252contentFile = Schema((
253    FileField('file',
254              #allowable_content_type = (...),
255              accessor='getFile',
256              mutator='setFile',
257              widget=FileWidget(label="Contents",
258                                label_msgid="label_piece_file",
259                                i18n_domain="lemill",
260                                show_content_type = True,
261                                #visible = {'edit' : 'visible', 'view' : 'invisible' }
262                                ),
263              ),
264))
265
266sourceFile = Schema((
267    FileField('source',
268              #allowable_content_type = (...),
269              widget=FileWidget(label="Source file",
270                                label_msgid="label_piece_source_file",
271                                description="Upload the source file which has the contents in an easily editable format.",
272                                description_msgid="help_piece_source_file",
273                                i18n_domain="lemill",
274                                show_content_type = True,
275                                visible = {'edit' : 'invisible', 'view' : 'invisible' }
276                                ),
277              ),
278))
279
280audioFile = Schema((
281    AudioField('audio',
282        accessor='getAudioFile',
283        mutator='setAudioFile',
284        widget=AudioWidget(label="Audio recording",
285            label_msgid="label_audio_recording",
286            description="An audio recording of the presentation",
287            description_msgid="help_presentation_audio_recording",
288            i18n_domain="lemill"
289            ),
290        ),
291))
292
293
294version_schema = Schema((
295    ReferenceField('parentVersion',
296        required = False,
297        searchable = True,
298        relationship = 'is version of',
299        widget = ReferenceWidget(
300            label="Version of",
301            label_msgid="label_version_of",           
302            visible = {'view':'visible', 'edit':'invisible'},
303            i18n_domain="lemill"
304            ),
305        ),
306    ReferenceField('versions',
307        relationship = 'has versions',
308        multiValued = True,
309        widget = ReferenceWidget(
310            label="Versions",
311            label_msgid="label_versions",           
312            visible = { 'view': 'visible', 'edit': 'invisible' },
313            i18n_domain="lemill"
314        ),
315    ),
316))
317
318
319translation_schema = Schema((
320    ReferenceField('translation_of',
321        relationship = 'translates',
322        widget = ReferenceWidget(
323            label="Translation of",
324            label_msgid="label_translation_of",           
325            visible = { 'view': 'visible', 'edit': 'invisible' },
326            i18n_domain="lemill"
327        ),
328    ),
329    ReferenceField('translations',
330        relationship = 'has translations',
331        multiValued = True,
332        widget = ReferenceWidget(
333            label="Translations",
334            label_msgid="label_translations",           
335            visible = { 'view': 'visible', 'edit': 'invisible' },
336            i18n_domain="lemill"
337        ),
338    ),
339))
340
341group_sharing = Schema((
342    StringField('groups',
343        schemata = 'metadata',
344        accessor='getGroupsShared',
345        mutator='setGroupsShared',
346        index="FieldIndex:schema",
347        vocabulary = 'getUserGroups',
348        default = 'no_group',
349        enforceVocabulary = False,
350        multiValued = False,
351        widget=GroupWidget(
352            label="Assigned group",
353            label_msgid="label_assigned_group",
354            description="Assign one of your groups to work with this resource.",
355            description_msgid="help_resource_group",
356            i18n_domain="lemill",
357            visible={'edit': 'invisible', 'view': 'invisible'},
358            ),
359        ),
360    ReferenceField('groupEditing',
361        relationship = "is_edited_by",
362        schemata = 'metadata',
363        index="FieldIndex:schema",
364        vocabulary = 'getUserGroups',
365        enforceVocabulary = False,
366        multiValued = False,
367        widget=GroupWidget(
368            label="Assigned group",
369            label_msgid="label_assigned_group",
370            description="Assign one of your groups to work with this resource.",
371            description_msgid="help_resource_group",
372            i18n_domain="lemill",
373            visible={'edit': 'visible', 'view': 'invisible'},
374            ),
375        ),
376
377
378    ))
379
380target_group_schema = Schema((
381    LinesField('target_group',
382        vocabulary = DisplayList((
383            ("pre-school education", "pre-school education"),
384            ("1st grade", "1st grade"),
385            ("2nd grade", "2nd grade"),
386            ("3rd grade", "3rd grade"),
387            ("4th grade", "4th grade"),
388            ("5th grade", "5th grade"),
389            ("6th grade", "6th grade"),
390            ("7th grade", "7th grade"),
391            ("8th grade", "8th grade"),
392            ("9th grade", "9th grade"),
393            ("10th grade", "10th grade"),
394            ("11th grade", "11th grade"),
395            ("12th grade", "12th grade"),
396            ("higher education", "higher education"),
397            ("adult education","adult education"),
398            ("teachers", "teachers"),
399            ("special education", "special education"),
400            )),
401        index = "KeywordIndex:schema",
402        multivalued=True,
403        schemata="metadata",
404        widget=TwoColumnMultiSelectionWidget(
405            format="checkbox",
406            label="Target group",
407            label_msgid="label_target_group",
408            description="Choose suitable student levels for this resource.",
409            description_msgid="description_target_group",
410            i18n_domain="lemill",
411        ),
412    ),
413))
414
415subject_area_schema = Schema((
416    LinesField('subject_area',
417        vocabulary = DisplayList([(x,x) for x in SUBJECT_AREAS]),
418        index = "KeywordIndex:schema",
419        multivalued=True,
420        schemata="metadata",
421        widget=TwoColumnMultiSelectionWidget(
422            format="checkbox",
423            label="Subject area",
424            label_msgid="label_subject_area",
425            description="Choose curriculum subject areas that are appropriate for this resource.",
426            description_msgid="description_subject_area",
427            i18n_domain="lemill",
428        ),
429    ),
430))
431
432deletionReason = Schema((
433    StringField('deletionReason',
434        searchable=False,
435        schemata = "metadata",
436        widget = TextAreaWidget(
437            visible={'view':'invisible','edit':'invisible'}
438        ),
439    ),
440))
441
442# These are used for Material, but hidden from the UI
443ieee_lom_lre_ap = Schema((
444    LinesField('learningResourceType',
445        vocabulary = DisplayList((
446            ("assessment", "Assessment"),
447            ("broadcast", "Broadcast"),
448            ("course", "Course"),
449            ("drill", "Drill and practice"),
450            ("educational game", "Educational game"),
451            ("demonstration", "Demonstration"),
452            ("experiment", "Experiment"),
453            ("exploration", "Exploration"),
454            ("glossary", "Glossary"),
455            ("guide", "Guide"),
456            ("learning asset", "Learning asset"),
457            ("lesson plan", "Lesson plan"),
458            ("open activity", "Open activity"),
459            ("reference", "Reference"),
460            ("simulation", "Simulation"),
461            ("tool", "Tool"),
462            ("weblog", "Weblog"),
463            ("wiki", "Wiki"),
464            )),
465        index = "KeywordIndex:schema",
466        multivalued=True,
467        schemata="metadata",
468        widget=MultiSelectionWidget(
469            format="checkbox",
470            visible={'view':'invisible','edit':'invisible'},
471            label="Learning resource type",
472            label_msgid="label_learning_resource_type",
473            description="Choose suitable resource type categories.",
474            description_msgid="desc_learning_resource_type",
475            i18n_domain="lemill",
476        ),
477    ),
478    LinesField('endUserRole',
479        vocabulary = DisplayList((
480            ("author", "Author"),
481            ("counsellor", "Counsellor"),
482            ("learner", "Learner"),
483            ("manager", "Manager"),
484            ("teacher", "Teacher"),
485            ("other", "Other"),
486            )),
487        index = "KeywordIndex:schema",
488        multivalued=True,
489        schemata="metadata",
490        widget=MultiSelectionWidget(
491            format="checkbox",
492            visible = {'view':'invisible', 'edit':'invisible'},
493            label="Intended end user role",
494            label_msgid="label_end_user_role",
495            description="Choose typical roles that users of this resource have.",
496            description_msgid="desc_end_user_role",
497            i18n_domain="lemill",
498        ),
499    ),
500    LinesField('learningContext',
501        vocabulary = DisplayList((
502            ("pre-school", "Pre-school"),
503            ("compulsory education", "Compulsory education"),
504            ("special education", "Special education"),
505            ("vocational education", "Vocational education"),
506            ("higher education", "Higher education"),
507            ("distance education", "Distance education"),
508            ("adult / continuing education", "Adult / Continuing education"),
509            ("professional development", "Professional development"),
510            ("school libraries / documentation centre", "School libraries / Documentation centre"),
511            ("educational administration", "Educational administration"),
512            ("policy making", "Policy making"),
513            ("other", "Other"),
514            )),
515        index = "KeywordIndex:schema",
516        multivalued=True,
517        schemata="metadata",
518        widget=MultiSelectionWidget(
519            format="checkbox",
520            visible={'view':'invisible','edit':'invisible'},
521            label="Learning context",
522            label_msgid="label_learning_context",
523            description="Choose typical learning context for this resource.",
524            description_msgid="desc_learning_context",
525            i18n_domain="lemill",
526        ),
527    ),
528))
529
530
531score = Schema((
532    IntegerField('score',
533        index = 'FieldIndex:schema',
534        default = 1,
535        widget = IntegerWidget(
536                 visible = {'view':'invisible', 'edit':'invisible'},
537             ),
538        ),
539))
Note: See TracBrowser for help on using the repository browser.