| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
from AccessControl import ClassSecurityInfo |
|---|
| 20 |
from Products.Archetypes.public import * |
|---|
| 21 |
from Products.CMFCore.utils import getToolByName |
|---|
| 22 |
|
|---|
| 23 |
from FieldsWidgets import TwoColumnMultiSelectionWidget, HTMLLinkWidget |
|---|
| 24 |
from config import PROJECTNAME, MODIFY_CONTENT, VIEW |
|---|
| 25 |
from Material import Material |
|---|
| 26 |
from Schemata import material_schema, description, author_schema, group_sharing |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
LICENSE_TYPES = ( |
|---|
| 30 |
('None', 'None - All Rights Reserved',), |
|---|
| 31 |
('CCAL', 'Creative Commons Attribution License',), |
|---|
| 32 |
('CCAND', 'Creative Commons Attribution-NoDerivs',), |
|---|
| 33 |
('CCANCND', 'Creative Commons Attribution-NonCommercial-NoDerivs',), |
|---|
| 34 |
('CCANC', 'Creative Commons Attribution-NonCommercial',), |
|---|
| 35 |
('CCANCSA', 'Creative Commons Attribution-NonCommercial-ShareAlike',), |
|---|
| 36 |
('CCAS', 'Creative Commons Attribution-ShareAlike',), |
|---|
| 37 |
('GNUFDL', 'GNU Free Documentation License',), |
|---|
| 38 |
('PD', 'Public Domain',), |
|---|
| 39 |
) |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
lemillreference_schema = Schema(( |
|---|
| 43 |
StringField('location', |
|---|
| 44 |
default = 'http://', |
|---|
| 45 |
copied_in_translation=True, |
|---|
| 46 |
accessor = 'getTechnicalLocation', |
|---|
| 47 |
required = True, |
|---|
| 48 |
searchable = True, |
|---|
| 49 |
widget = HTMLLinkWidget( |
|---|
| 50 |
label="Location", |
|---|
| 51 |
label_msgid='label_location_url', |
|---|
| 52 |
description='URL to the resource.', |
|---|
| 53 |
description_msgid='description_location_url', |
|---|
| 54 |
i18n_domain="lemill", |
|---|
| 55 |
), |
|---|
| 56 |
), |
|---|
| 57 |
StringField('author', |
|---|
| 58 |
copied_in_translation=True, |
|---|
| 59 |
searchable=True, |
|---|
| 60 |
widget = StringWidget( |
|---|
| 61 |
label = 'Author', |
|---|
| 62 |
label_msgid = 'label_author', |
|---|
| 63 |
description = 'Author of this resource', |
|---|
| 64 |
description_msgid = 'description_author', |
|---|
| 65 |
i18n_domain = 'lemill', |
|---|
| 66 |
), |
|---|
| 67 |
), |
|---|
| 68 |
StringField('license', |
|---|
| 69 |
copied_in_translation=True, |
|---|
| 70 |
vocabulary = DisplayList((LICENSE_TYPES)), |
|---|
| 71 |
searchable = True, |
|---|
| 72 |
widget = SelectionWidget( |
|---|
| 73 |
label = 'License', |
|---|
| 74 |
label_msgid = 'label_license', |
|---|
| 75 |
description = 'Choose appropriate license', |
|---|
| 76 |
description_msgid = 'description_choose_license', |
|---|
| 77 |
i18n_domain = 'lemill', |
|---|
| 78 |
), |
|---|
| 79 |
), |
|---|
| 80 |
)) |
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 |
lrt = Schema(( |
|---|
| 85 |
LinesField('learningResourceType', |
|---|
| 86 |
vocabulary = DisplayList(( |
|---|
| 87 |
("assessment", "Assessment"), |
|---|
| 88 |
("broadcast", "Broadcast"), |
|---|
| 89 |
("course", "Course"), |
|---|
| 90 |
("drill", "Drill and practice"), |
|---|
| 91 |
("educational game", "Educational game"), |
|---|
| 92 |
("demonstration", "Demonstration"), |
|---|
| 93 |
("experiment", "Experiment"), |
|---|
| 94 |
("exploration", "Exploration"), |
|---|
| 95 |
("glossary", "Glossary"), |
|---|
| 96 |
("guide", "Guide"), |
|---|
| 97 |
|
|---|
| 98 |
("lesson plan", "Lesson plan"), |
|---|
| 99 |
("open activity", "Open activity"), |
|---|
| 100 |
("reference", "Reference"), |
|---|
| 101 |
("simulation", "Simulation"), |
|---|
| 102 |
("tool", "Tool"), |
|---|
| 103 |
("weblog", "Weblog"), |
|---|
| 104 |
("website", "Web Site"), |
|---|
| 105 |
("wiki", "Wiki"), |
|---|
| 106 |
)), |
|---|
| 107 |
index = "KeywordIndex:schema", |
|---|
| 108 |
multivalued=True, |
|---|
| 109 |
copied_in_translation=True, |
|---|
| 110 |
widget=TwoColumnMultiSelectionWidget( |
|---|
| 111 |
format="checkbox", |
|---|
| 112 |
label="Learning resource type", |
|---|
| 113 |
label_msgid="label_learning_resource_type", |
|---|
| 114 |
description="Choose suitable resource type categories", |
|---|
| 115 |
description_msgid="desc_learning_resource_type", |
|---|
| 116 |
i18n_domain="lemill", |
|---|
| 117 |
), |
|---|
| 118 |
), |
|---|
| 119 |
)) |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
schema = material_schema + description + author_schema + group_sharing + lemillreference_schema |
|---|
| 123 |
|
|---|
| 124 |
schema = schema.copy() |
|---|
| 125 |
|
|---|
| 126 |
toBeHidden = ['allowDiscussion', 'contributors', 'creators', 'rights', 'subject'] |
|---|
| 127 |
for x in schema.keys(): |
|---|
| 128 |
schema[x].schemata = 'default' |
|---|
| 129 |
schema[x].isMetadata = False |
|---|
| 130 |
if x in toBeHidden: |
|---|
| 131 |
schema[x].widget.visible = {'view': 'invisible', 'edit':'invisible'} |
|---|
| 132 |
schema.moveField('location', pos='top') |
|---|
| 133 |
schema.moveField('author', after='title') |
|---|
| 134 |
schema.moveField('description', after='author') |
|---|
| 135 |
schema.moveField('tags', after='description') |
|---|
| 136 |
|
|---|
| 137 |
class LeMillReference(Material): |
|---|
| 138 |
""" Reference to external resource """ |
|---|
| 139 |
|
|---|
| 140 |
schema = schema |
|---|
| 141 |
|
|---|
| 142 |
meta_type = 'LeMillReference' |
|---|
| 143 |
archetype_name = 'LeMillReference' |
|---|
| 144 |
default_location = 'content/references' |
|---|
| 145 |
|
|---|
| 146 |
portlet = 'here/portlet_lemillreference_actions/macros/portlet' |
|---|
| 147 |
security = ClassSecurityInfo() |
|---|
| 148 |
security.declareObjectPublic() |
|---|
| 149 |
|
|---|
| 150 |
aliases = { |
|---|
| 151 |
'(Default)' : 'base_view', |
|---|
| 152 |
'view' : 'base_view', |
|---|
| 153 |
'edit' : 'base_edit' |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
def hasComplexWorkflow(self): |
|---|
| 157 |
""" Can have drafts or versions """ |
|---|
| 158 |
return False |
|---|
| 159 |
|
|---|
| 160 |
def amIMaterial(self): |
|---|
| 161 |
""" references are not proper material""" |
|---|
| 162 |
return False |
|---|
| 163 |
|
|---|
| 164 |
registerType(LeMillReference, PROJECTNAME) |
|---|