source: trunk/SharedMetadata.py @ 577

Revision 577, 13.0 KB checked in by vahur, 13 years ago (diff)

re #613 spent 2h
selecting groups is there. creating group on "metadata" page is not.

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':'invisible'}
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
200contentFile = Schema((
201    FileField('file',
202              #allowable_content_type = (...),
203              accessor='getFile',
204              mutator='setFile',
205              widget=FileWidget(label="Contents",
206                                label_msgid="label_piece_file",
207                                description="Upload the file with the contents",
208                                description_msgid="help_piece_file",
209                                i18n_domain="lemill",
210                                show_content_type = True,
211                                #visible = {'edit' : 'visible', 'view' : 'invisible' }
212                                ),
213              ),
214))
215
216sourceFile = Schema((
217    FileField('source',
218              #allowable_content_type = (...),
219              widget=FileWidget(label="Source file",
220                                label_msgid="label_piece_source_file",
221                                description="Upload the source file which has the contents in an easily editable format",
222                                description_msgid="help_piece_source_file",
223                                i18n_domain="lemill",
224                                show_content_type = True,
225                                visible = {'edit' : 'invisible', 'view' : 'invisible' }
226                                ),
227              ),
228))
229
230audioFile = Schema((
231    FileField('audio',
232        accessor='getAudioFile',
233        mutator='setAudioFile',
234        widget=FileWidget(label="Audio recording",
235            label_msgid="label_material_audio_recording",
236            description="An audio recording of the presentation",
237            description_msgid="help_material_audio_recording",
238            i18n_domain="lemill"
239            ),
240        ),
241))
242
243group_sharing = Schema((
244    StringField('groups',
245        schemata = 'metadata',
246        accessor='getGroupsShared',
247        mutator='setGroupsShared',
248        vocabulary = 'getUserGroups',
249        enforceVocabulary = True,
250        multiValued = True,
251        widget=PicklistWidget(
252            label="Share with a group",
253            label_msgid="label_material_group_sharing",
254            description="",
255            i18n_domain="lemill",
256            visible={'edit': 'visible', 'view': 'invisible'},
257            ),
258        ),
259    ))
260
261target_group_schema = Schema((
262    LinesField('target_group',
263        vocabulary = DisplayList((
264            ("pre-school education", "pre-school education"),
265            ("1st grade", "1st grade"),
266            ("2nd grade", "2nd grade"),
267            ("3rd grade", "3rd grade"),
268            ("4th grade", "4th grade"),
269            ("5th grade", "5th grade"),
270            ("6th grade", "6th grade"),
271            ("7th grade", "7th grade"),
272            ("8th grade", "8th grade"),
273            ("9th grade", "9th grade"),
274            ("10th grade", "10th grade"),
275            ("11th grade", "11th grade"),
276            ("12th grade", "12th grade"),
277            ("special education", "special education"),
278            ("higher education", "higher education"),
279            ("teacher training", "teacher training"),
280            )),
281        index = "KeywordIndex:schema",
282        multivalued=True,
283        schemata="metadata",
284        widget=MultiSelectionWidget(
285            format="checkbox",
286            label="Target group",
287            label_msgid="label_target_group",
288            description="Choose suitable student levels for this resource",
289            description_msgid="desc_target_group",
290            i18n_domain="lemill",
291        ),
292    ),
293))
294
295# this is probably deprecated w. story #543
296learning_metadata = Schema((
297    LinesField('learningResourceType',
298        vocabulary = DisplayList((
299            ("assessment", "Assessment"),
300            #("broadcast", "Broadcast"),
301            ("course", "Course"),
302            #("drill", "Drill and practice"),
303            ("educational game", "Educational game"),
304            ("demonstration", "Demonstration"),
305            ("experiment", "Experiment"),
306            ("exploration", "Exploration"),
307            ("glossary", "Glossary"),
308            ("guide", "Guide"),
309            #("learning asset", "Learning asset"),
310            #("lesson plan", "Lesson plan"),
311            #("open activity", "Open activity"),
312            ("reference", "Reference"),
313            ("simulation", "Simulation"),
314            #("tool", "Tool"),
315            #("weblog", "Weblog"),
316            #("wiki", "Wiki"),
317            )),
318        index = "KeywordIndex:schema",
319        multivalued=True,
320        schemata="metadata",
321        widget=MultiSelectionWidget(
322            format="checkbox",
323            label="Learning resource type",
324            label_msgid="label_learning_resource_type",
325            description="Choose suitable resource type categories",
326            description_msgid="desc_learning_resource_type",
327            i18n_domain="lemill",
328        ),
329    ),
330    LinesField('endUserRole',
331        vocabulary = DisplayList((
332            ("author", "Author"),
333            ("counsellor", "Counsellor"),
334            ("learner", "Learner"),
335            ("manager", "Manager"),
336            ("teacher", "Teacher"),
337            ("other", "Other"),
338            )),
339        index = "KeywordIndex:schema",
340        multivalued=True,
341        schemata="metadata",
342        widget=MultiSelectionWidget(
343            format="checkbox",
344            visible = {'view':'invisible', 'edit':'invisible'},
345            label="Intended end user role",
346            label_msgid="label_end_user_role",
347            description="Choose typical roles that users of this resource have",
348            description_msgid="desc_end_user_role",
349            i18n_domain="lemill",
350        ),
351    ),
352    LinesField('learningContext',
353        vocabulary = DisplayList((
354            ("pre-school", "Pre-school"),
355            ("compulsory education", "Compulsory education"),
356            ("special education", "Special education"),
357            ("vocational education", "Vocational education"),
358            ("higher education", "Higher education"),
359            ("distance education", "Distance education"),
360            ("adult / continuing education", "Adult / Continuing education"),
361            ("professional development", "Professional development"),
362            #("school libraries / documentation centre", "School libraries / Documentation centre"),
363            #("educational administration", "Educational administration"),
364            #("policy making", "Policy making"),
365            #("other", "Other"),
366            )),
367        index = "KeywordIndex:schema",
368        multivalued=True,
369        schemata="metadata",
370        widget=MultiSelectionWidget(
371            format="checkbox",
372            label="Learning context",
373            label_msgid="label_learning_context",
374            description="Choose typical learning context for this resource",
375            description_msgid="desc_learning_context",
376            i18n_domain="lemill",
377        ),
378    ),
379))
380
Note: See TracBrowser for help on using the repository browser.