source: trunk/SharedMetadata.py @ 580

Revision 580, 13.3 KB checked in by szabolcs, 13 years ago (diff)

closes #610, spent 2h

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 WYSIWYMWidget, WYSIWYMField, TagsField, TagsWidget, CopyrightWidget, Age_rangeWidget
23from config import LICENSES
24
25bodytext = Schema((
26    WYSIWYMField('bodyText',
27                 accessor="getBodyText",
28                 mutator = "setBodyText",
29                 index='ZCTextIndex:schema',
30                 searchable = True,
31                 widget=WYSIWYMWidget(label = "Body text",
32                                      label_msgid = "label_wysiwym_body_text",
33                                      description = "Write the actual text content here.",
34                                      description_msgid = "help_wysiwym_body_text",
35                                      i18n_domain = "lemill",
36                                      ),
37                ),
38))
39
40description = Schema((
41    StringField('description',
42        index="ZCTextIndex:schema",
43        searchable=True,
44        schemata="metadata",
45        widget=TextAreaWidget(
46            rows = 2,
47            label="Description",
48            label_msgid="label_description",
49            description="Write a short description here",
50            description_msgid="help_description",
51            i18n_domain="lemill"),
52    )
53))
54
55no_description = Schema((
56    StringField('description',
57        searchable=False,
58        schemata = "metadata",
59        widget = TextAreaWidget(
60            visible={'view':'invisible','edit':'invisible'}
61        ),
62    ),
63))
64
65language_schema = Schema((
66    StringField(
67            'language',
68            index='FieldIndex:schema',
69            schemata="metadata",
70            accessor="Language",
71            default_method ='defaultLanguage',
72            vocabulary='getLanguagelist',
73            widget=SelectionWidget(
74                label='Language',
75                label_msgid="label_language",
76                description="Select the language of this resource",
77                description_msgid="help_language",
78                i18n_domain="lemill"
79                ),
80        ),
81))
82
83license_schema = Schema((
84   TextField('rights',
85       schemata="metadata",
86       default = "CreativeCommons",
87       vocabulary=DisplayList((LICENSES)),
88       widget=CopyrightWidget(
89           visible={'edit':'visible'}
90           ),
91       ),
92))
93
94# Overwrite some Archetypes ExtensibleMetadata.py field definitions to make them go away.
95lemill_metadata_mods = Schema((
96   StringField('allowDiscussion',
97       default='0',
98       widget=SelectionWidget(
99           visible={'view':'invisible','edit':'invisible'}
100           ),
101       ),
102   LinesField('subject',
103       searchable=False,
104       widget=KeywordWidget(
105           visible={'view':'invisible','edit':'invisible'}
106           ),
107       ),
108   LinesField('contributors',
109       widget=LinesWidget(
110           visible={'view':'invisible','edit':'invisible'}
111           ),
112       ),
113))
114
115age_group = Schema((
116    StringField('age_group',
117        index="KeywordIndex:schema",
118        widget=Age_rangeWidget(
119            label="Typical Age Range",
120            label_msgid="label_age_range",
121            description="Enter the lowest and highest suitable age (eg. '12-18'). If no lower or higher limit exists, leave that field empty.",
122            description_msgid="help_age_range",
123            i18n_domain="lemill"
124        ),
125        schemata="metadata"
126    ),
127))
128
129tags = Schema((
130   TagsField('tags',
131        index="KeywordIndex:schema",
132        accessor="getTags",
133        searchable=True,
134        widget=TagsWidget(
135            label="Tags",
136            label_msgid="label_tags",
137            description="Enter descriptive tags for this resource, separated by commas.",
138            description_msgid="help_tags",
139            i18n_domain="lemill"
140        ),
141        schemata="metadata",
142    ),
143))
144
145parentVersion = Schema((
146    StringField('parentVersion',
147        required = False,
148        searchable = True,
149        accessor = 'getParentVersion',
150        mutator = 'setParentVersion',
151        widget = StringWidget(
152            visible = {'view':'invisible', 'edit':'invisible'},
153            ),
154        ),
155))
156
157coverImage = Schema((
158    ImageField('coverImage',
159               schemata="metadata",
160               required=False,
161               accessor='getCoverImage',
162               mutator='setCoverImage',
163               #original_size=(160,120),
164               widget = ImageWidget(
165                   visible={'view':'invisible','edit':'invisible'},
166                   ),
167               ),
168    BooleanField('hasCoverImage',
169                default=False,
170                index="FieldIndex:schema",
171                accessor='getHasCoverImage',
172                mutator='setHasCoverImage',
173                widget = BooleanWidget(
174                    visible = {'view':'invisible', 'edit':'invisible'},
175                    ),
176                ),
177    ImageField('originalCoverImage',
178        schemata = "metadata",
179        required=False,
180        accessor='getOriginalCoverImage',
181        mutator='setOriginalCoverImage',
182        widget = ImageWidget(
183            visible = {'view': 'invisible', 'edit':'invisible'},
184            ),
185        ),
186))
187
188author_schema = Schema((
189    LinesField('creators',
190              schemata="metadata",
191              accessor='getAuthorsNames',
192              widget = StringWidget(
193                  visible = {'view':'invisible', 'edit':'invisible'},
194                  label='Creators',
195                  label_msgid='label_creators',
196                  ),
197              )
198))
199
200original_author_schema = Schema((
201    StringField('originalAuthor',
202              schemata="metadata",
203              widget = StringWidget(
204                  visible = {'view':'invisible', 'edit':'visible'},
205                  label='Original author',
206                  label_msgid='label_original_author',
207                  ),
208              )
209))
210
211contentFile = Schema((
212    FileField('file',
213              #allowable_content_type = (...),
214              accessor='getFile',
215              mutator='setFile',
216              widget=FileWidget(label="Contents",
217                                label_msgid="label_piece_file",
218                                description="Upload the file with the contents",
219                                description_msgid="help_piece_file",
220                                i18n_domain="lemill",
221                                show_content_type = True,
222                                #visible = {'edit' : 'visible', 'view' : 'invisible' }
223                                ),
224              ),
225))
226
227sourceFile = Schema((
228    FileField('source',
229              #allowable_content_type = (...),
230              widget=FileWidget(label="Source file",
231                                label_msgid="label_piece_source_file",
232                                description="Upload the source file which has the contents in an easily editable format",
233                                description_msgid="help_piece_source_file",
234                                i18n_domain="lemill",
235                                show_content_type = True,
236                                visible = {'edit' : 'invisible', 'view' : 'invisible' }
237                                ),
238              ),
239))
240
241audioFile = Schema((
242    FileField('audio',
243        accessor='getAudioFile',
244        mutator='setAudioFile',
245        widget=FileWidget(label="Audio recording",
246            label_msgid="label_material_audio_recording",
247            description="An audio recording of the presentation",
248            description_msgid="help_material_audio_recording",
249            i18n_domain="lemill"
250            ),
251        ),
252))
253
254group_sharing = Schema((
255    StringField('groups',
256        schemata = 'metadata',
257        accessor='getGroupsShared',
258        mutator='setGroupsShared',
259        vocabulary = 'getUserGroups',
260        enforceVocabulary = True,
261        multiValued = True,
262        widget=PicklistWidget(
263            label="Share with a group",
264            label_msgid="label_material_group_sharing",
265            description="",
266            i18n_domain="lemill",
267            visible={'edit': 'visible', 'view': 'invisible'},
268            ),
269        ),
270    ))
271
272target_group_schema = Schema((
273    LinesField('target_group',
274        vocabulary = DisplayList((
275            ("pre-school education", "pre-school education"),
276            ("1st grade", "1st grade"),
277            ("2nd grade", "2nd grade"),
278            ("3rd grade", "3rd grade"),
279            ("4th grade", "4th grade"),
280            ("5th grade", "5th grade"),
281            ("6th grade", "6th grade"),
282            ("7th grade", "7th grade"),
283            ("8th grade", "8th grade"),
284            ("9th grade", "9th grade"),
285            ("10th grade", "10th grade"),
286            ("11th grade", "11th grade"),
287            ("12th grade", "12th grade"),
288            ("special education", "special education"),
289            ("higher education", "higher education"),
290            ("teacher training", "teacher training"),
291            )),
292        index = "KeywordIndex:schema",
293        multivalued=True,
294        schemata="metadata",
295        widget=MultiSelectionWidget(
296            format="checkbox",
297            label="Target group",
298            label_msgid="label_target_group",
299            description="Choose suitable student levels for this resource",
300            description_msgid="desc_target_group",
301            i18n_domain="lemill",
302        ),
303    ),
304))
305
306# this is probably deprecated w. story #543
307learning_metadata = Schema((
308    LinesField('learningResourceType',
309        vocabulary = DisplayList((
310            ("assessment", "Assessment"),
311            #("broadcast", "Broadcast"),
312            ("course", "Course"),
313            #("drill", "Drill and practice"),
314            ("educational game", "Educational game"),
315            ("demonstration", "Demonstration"),
316            ("experiment", "Experiment"),
317            ("exploration", "Exploration"),
318            ("glossary", "Glossary"),
319            ("guide", "Guide"),
320            #("learning asset", "Learning asset"),
321            #("lesson plan", "Lesson plan"),
322            #("open activity", "Open activity"),
323            ("reference", "Reference"),
324            ("simulation", "Simulation"),
325            #("tool", "Tool"),
326            #("weblog", "Weblog"),
327            #("wiki", "Wiki"),
328            )),
329        index = "KeywordIndex:schema",
330        multivalued=True,
331        schemata="metadata",
332        widget=MultiSelectionWidget(
333            format="checkbox",
334            label="Learning resource type",
335            label_msgid="label_learning_resource_type",
336            description="Choose suitable resource type categories",
337            description_msgid="desc_learning_resource_type",
338            i18n_domain="lemill",
339        ),
340    ),
341    LinesField('endUserRole',
342        vocabulary = DisplayList((
343            ("author", "Author"),
344            ("counsellor", "Counsellor"),
345            ("learner", "Learner"),
346            ("manager", "Manager"),
347            ("teacher", "Teacher"),
348            ("other", "Other"),
349            )),
350        index = "KeywordIndex:schema",
351        multivalued=True,
352        schemata="metadata",
353        widget=MultiSelectionWidget(
354            format="checkbox",
355            visible = {'view':'invisible', 'edit':'invisible'},
356            label="Intended end user role",
357            label_msgid="label_end_user_role",
358            description="Choose typical roles that users of this resource have",
359            description_msgid="desc_end_user_role",
360            i18n_domain="lemill",
361        ),
362    ),
363    LinesField('learningContext',
364        vocabulary = DisplayList((
365            ("pre-school", "Pre-school"),
366            ("compulsory education", "Compulsory education"),
367            ("special education", "Special education"),
368            ("vocational education", "Vocational education"),
369            ("higher education", "Higher education"),
370            ("distance education", "Distance education"),
371            ("adult / continuing education", "Adult / Continuing education"),
372            ("professional development", "Professional development"),
373            #("school libraries / documentation centre", "School libraries / Documentation centre"),
374            #("educational administration", "Educational administration"),
375            #("policy making", "Policy making"),
376            #("other", "Other"),
377            )),
378        index = "KeywordIndex:schema",
379        multivalued=True,
380        schemata="metadata",
381        widget=MultiSelectionWidget(
382            format="checkbox",
383            label="Learning context",
384            label_msgid="label_learning_context",
385            description="Choose typical learning context for this resource",
386            description_msgid="desc_learning_context",
387            i18n_domain="lemill",
388        ),
389    ),
390))
391
Note: See TracBrowser for help on using the repository browser.