Changeset 2998
- Timestamp:
- 01/15/10 17:25:30 (2 years ago)
- Files:
-
- trunk/Branchable.py (added)
- trunk/CommonMixIn.py (modified) (2 diffs)
- trunk/LeMillReference.py (modified) (2 diffs)
- trunk/LeMillTool.py (modified) (1 diff)
- trunk/LearningResource.py (modified) (1 diff)
- trunk/LessonPlan.py (modified) (2 diffs)
- trunk/Material.py (modified) (1 diff)
- trunk/MemberFolder.py (modified) (1 diff)
- trunk/MultimediaMaterial.py (modified) (2 diffs)
- trunk/PILOTMaterial.py (modified) (2 diffs)
- trunk/Resource.py (modified) (3 diffs)
- trunk/SchoolProjectMaterial.py (modified) (2 diffs)
- trunk/config.py (modified) (3 diffs)
- trunk/skins/lemill/cached_script_featured_content.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CommonMixIn.py
r2975 r2998 31 31 from types import MethodType as instancemethod 32 32 import time, re, traceback, transaction 33 34 33 35 34 # For sortable_title -method … … 110 109 def isDiscussable(self): 111 110 """ We are not, but can be overrided by more complex resources """ 111 return False 112 113 def isBranchable(self): 112 114 return False 113 115 trunk/LeMillReference.py
r2979 r2998 24 24 from config import PROJECTNAME, MODIFY_CONTENT, VIEW 25 25 from Material import Material 26 from Schemata import material_schema, description 26 from Schemata import material_schema, description, author_schema, group_sharing 27 27 28 28 … … 120 120 121 121 122 schema = material_schema + description + lemillreference_schema122 schema = material_schema + description + author_schema + group_sharing + lemillreference_schema 123 123 124 124 schema = schema.copy() trunk/LeMillTool.py
r2997 r2998 1663 1663 pc=getToolByName(self, 'portal_catalog') 1664 1664 if portal_type=='content': 1665 portal_type=list(MATERIAL_TYPES)+['LeMill Reference','LeMillPrintResource']1665 portal_type=list(MATERIAL_TYPES)+['LeMillPrintResource'] 1666 1666 return pc(portal_type=portal_type, getState="public") 1667 1667 trunk/LearningResource.py
r2949 r2998 140 140 else: 141 141 member_id = lutool.getAuthenticatedId() 142 if getattr(self, 'editingMode', '')=='other_users_can_edit_a_copy' and not (self.amIOwner() or self.canIModerate()): 143 return False 142 if self.isBranchable(): 143 if not self.branchableEditingCheck(): 144 return False 144 145 if not getattr(self, 'getGroupEditing', False): 145 146 return True trunk/LessonPlan.py
r2949 r2998 26 26 from Material import Material 27 27 from permissions import MODIFY_CONTENT 28 from Branchable import Branchable 28 29 29 30 lessonplan_schema = Schema(( … … 113 114 114 115 115 class LessonPlan( Material):116 class LessonPlan(Branchable, Material): 116 117 """Lesson plan""" 117 118 schema = schema trunk/Material.py
r2975 r2998 65 65 return text 66 66 67 ############ Workflow methods #################################68 69 def canDeleteOnCancel(self):70 """ Materials can have newly created branches that may look like good objects but they aren't """71 history=self.getHistory()72 if not history:73 return True74 summary=history[0].get('_summary','')75 if summary.startswith('Copy of '): # this is a newly created branch76 return True77 return LearningResource.canDeleteOnCancel(self)78 79 security.declarePrivate('manage_beforeDelete')80 def manage_beforeDelete(self, item, container):81 """ When deleting, remove branch-related references. """82 if self.Schema().has_key('branch_of'):83 branch_parent= self.getBranch_of()84 storeRefs = getattr(item, '_v_cp_refs', None)85 if branch_parent and not storeRefs:86 branch_parent.removeFromBranches(self.UID())87 LearningResource.manage_beforeDelete(self, item, container)88 89 ############ Branching ########################################90 91 92 93 security.declareProtected(ADD_CONTENT_PERMISSION,'createBranch')94 def createBranch(self, REQUEST):95 """ Create a branch for object """96 if self.state=='deleted' or self.state=='private':97 return98 lutool=getToolByName(self, 'lemill_usertool')99 lt=getToolByName(self, 'lemill_tool')100 parent = aq_parent(aq_inner(self))101 new = parent.lemill_invokeFactory(parent, self.meta_type, id=self.meta_type.lower()+str(id(self)), do_create=True)102 base_obj=self103 104 for field in base_obj.schema.values():105 # list all fields here that shouldn't be copyied to new object106 if not getattr(field, 'copied_in_branching', True) or field.getName()=='id':107 continue108 old_accessor = field.getEditAccessor(base_obj)109 new_mutator = field.getMutator(new)110 if not old_accessor:111 continue112 val = old_accessor()113 copied_val = None114 try:115 copied_val = copy.copy(val)116 except TypeError:117 copied_val = copy.copy(val.aq_base)118 new_mutator(copied_val)119 120 # Setting parent and needed values121 baseuid=base_obj.UID()122 base_obj.addToBranches(new.UID())123 new.setBranch_of(baseuid)124 author=lutool.getAuthenticatedId()125 new.setCreators([author]+list(base_obj.Creators()))126 new.storeInHistory({}, summary='Copy of %s created' % base_obj.title_or_id())127 new.setHistory(new.getHistory()+base_obj.getHistory()+new.getHistory())128 lt.addPortalMessage('You are editing a copy of the original learning resource.')129 return REQUEST.RESPONSE.redirect('%s/base_edit' % new.absolute_url())130 131 132 security.declareProtected(ModerateContent,'removeBranches')133 def removeBranches(self):134 """ Manage command to remove broken branches """135 self.setBranches([])136 137 def addToBranches(self, UID):138 """ Makes sure that object UID is in branches """139 branch_list = self.getRawBranches()140 if UID not in branch_list:141 branch_list.append(UID)142 self.setBranches(branch_list)143 144 def removeFromBranches(self, UID):145 """ remove """146 branch_list = self.getRawBranches()147 if UID in branch_list:148 branch_list.remove(UID)149 self.setBranches(branch_list)150 151 def allowOnlyBranch(self):152 """ only checks if this is 'locked' resource, doesn't check if the author is one that is asking """153 return getattr(self, 'editingMode','')=='other_users_can_edit_a_copy'154 155 def allowSettingOfEditingPermissions(self):156 """ Only authors and moderators can hide drafts or prevent editing """157 # if translation, don't show editing_settings fields158 return (self.amIOwner() or self.canIModerate()) and not self.getRawTranslation_of()159 160 161 162 163 67 registerType(Material, PROJECTNAME) trunk/MemberFolder.py
r2994 r2998 545 545 elif res.meta_type=='Collection': 546 546 dict['Collections'].append(res) 547 elif res.meta_type=='Piece' or res.meta_type=='LeMillReference':547 elif res.meta_type=='Piece': 548 548 dict['Pieces'].append(res) 549 549 return dict trunk/MultimediaMaterial.py
r2791 r2998 25 25 from Schemata import no_description, material_schema, community_editing_schema, draft_schema 26 26 from Material import Material 27 from Branchable import Branchable 27 28 from permissions import MODIFY_CONTENT 28 29 import re … … 59 60 60 61 61 class MultimediaMaterial( Material):62 class MultimediaMaterial(Branchable, Material): 62 63 """Web page""" 63 64 trunk/PILOTMaterial.py
r2949 r2998 25 25 from Products.CMFPlone import PloneMessageFactory as PMF 26 26 from Material import Material 27 from Branchable import Branchable 27 28 28 29 pilotmaterial_schema = Schema(( … … 86 87 87 88 88 class PILOTMaterial( Material):89 class PILOTMaterial(Branchable, Material): 89 90 """ PILOT Material """ 90 91 trunk/Resource.py
r2997 r2998 92 92 self.recalculateAuthors() 93 93 self.recalculateScore() 94 # if in MATERIAL_TYPES, see if state has to be changed95 94 if self.hasComplexWorkflow(): 96 95 if self.getHideDrafts(): … … 823 822 f.set(self, reason) 824 823 self.setState('deleted') 825 if self.meta_type in MATERIAL_TYPES: 826 self.aliases['(Default)']='base_view' 824 self.aliases['(Default)']='base_view' 827 825 try: 828 826 self.reindexObject(['getState']) … … 834 832 def rescue(self, REQUEST): 835 833 """Undelete a resource """ 836 if self.meta_type in MATERIAL_TYPES: 837 self.aliases['(Default)']='fullscreen_view' 834 self.aliases['(Default)']=self.__class__().aliases['(Default)'] 838 835 self.undeleteResource() 839 836 return REQUEST.RESPONSE.redirect(self.absolute_url()) trunk/SchoolProjectMaterial.py
r2949 r2998 25 25 from config import PROJECTNAME, MODIFY_CONTENT, VIEW 26 26 from Material import Material 27 from Branchable import Branchable 27 28 28 29 schoolprojectmaterial_schema = Schema(( … … 101 102 #schema['bodyText'].widget.visible = {'edit':'invivible', 'view':'invisible'} 102 103 103 class SchoolProjectMaterial( Material):104 class SchoolProjectMaterial(Branchable, Material): 104 105 """ School Project Material """ 105 106 trunk/config.py
r2986 r2998 104 104 REMOTE_SERVERS = ["http://lemill.net"] 105 105 106 MATERIAL_TYPES = ('PresentationMaterial', 'MultimediaMaterial', 'PILOTMaterial', 'ExerciseMaterial','LessonPlan', 'SchoolProjectMaterial' )107 CONTENT_TYPES = ('Piece','LeMill Reference','LeMillPrintResource') + MATERIAL_TYPES106 MATERIAL_TYPES = ('PresentationMaterial', 'MultimediaMaterial', 'PILOTMaterial', 'ExerciseMaterial','LessonPlan', 'SchoolProjectMaterial', 'LeMillReference') 107 CONTENT_TYPES = ('Piece','LeMillPrintResource') + MATERIAL_TYPES 108 108 ACTIVITY_TYPES = ('Activity',) 109 109 TOOLS_TYPES = ('Tool',) … … 282 282 {'id':'drafts', 'title':'Draft', 'view':'lemill_published_view', 'sortby':'getLatestEdit', 'reversed':True,'criterions':[('ATCurrentAuthorCriterion','Creator',''),('ATSelectionCriterion','getState',['draft','private'])]},)), 283 283 # +++++++++++++++++++++++ 284 (MATERIAL_TYPES+('LeMill Reference','LeMillPrintResource',), (284 (MATERIAL_TYPES+('LeMillPrintResource',), ( 285 285 {'id':'language', 'title':'Language', 'getmethod':'Language', 'view':'lemill_browse_content'}, 286 286 {'id':'subject_area', 'title':'Subject area', 'getmethod':'getSubject_area', 'view':'lemill_browse_content'}, … … 296 296 {'id':'browse_pieces', 'title':'Pieces', 'view':'lemill_content_titlecloud'},)), 297 297 # +++++++++++++++++++++++ 298 (MATERIAL_TYPES+ACTIVITY_TYPES+TOOLS_TYPES+COMMUNITY_TYPES+('LeMill Reference','LeMillPrintResource',), (298 (MATERIAL_TYPES+ACTIVITY_TYPES+TOOLS_TYPES+COMMUNITY_TYPES+('LeMillPrintResource',), ( 299 299 {'id':'recent', 'title':"What's going on", 'getmethod':'getLatestEdit', 'sortby':'getLatestEdit', 'reversed':True, 'view':'lemill_recent_view'},)) 300 300 # +++++++++++++++++++++++ trunk/skins/lemill/cached_script_featured_content.py
r2949 r2998 10 10 SCORE_THRESHOLD=5 11 11 12 featured_types= list(context.getMaterialTypes())+['LeMillReference']12 featured_types=context.getMaterialTypes() 13 13 top3_categories={'top3languages':'Language', 'top3tags':'getTags', 'top3subject_areas':'getSubject_area', 'top3target_groups':'getTarget_group'} 14 14
