Changeset 2859
- Timestamp:
- 08/14/09 03:01:43 (2 years ago)
- Files:
-
- trunk/CommonMixIn.py (modified) (1 diff)
- trunk/LargeSectionFolder.py (modified) (1 diff)
- trunk/LearningResource.py (modified) (1 diff)
- trunk/Material.py (modified) (3 diffs)
- trunk/skins/lemill/portlet_macros.pt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/CommonMixIn.py
r2858 r2859 588 588 v['original'] = original or False 589 589 590 v['branches'] = [br.absolute_url() for br in self.getBranches() if br .state=='public' or br.state=='draft']590 v['branches'] = [br.absolute_url() for br in self.getBranches() if br and (br.state=='public' or br.state=='draft')] 591 591 v['showBranches'] = showBranches = original or v['branches'] 592 592 else: trunk/LargeSectionFolder.py
r2858 r2859 129 129 130 130 131 security.declareProtected(MANAGE_PORTAL, 'fixReferenceCatalog') 132 def fixReferenceCatalog(self): 133 """ goes through references and removes references originating from trash """ 134 rc=getToolByName(self, 'reference_catalog') 135 reference_types=['is_discussion_about', 'is_edited_by', 'relatesToCollections', 'relatesToContent', 'relatesToMethods','relatesToTools','translates','uses'] # 'branches', 'displays', 'has branches', 'has translations', 'has versions', 'is contact of', 'is version of', 136 for ref_type in reference_types: 137 broken=0 138 total=0 139 results=rc({'relationship':ref_type}) 140 print '%s references of type %s' % (len(results), ref_type) 141 for ref in results: 142 total+=1 143 if ref.getPath().startswith('trash/'): 144 broken+=1 145 print 'referencing from trash: (%s / %s)' % (broken, total) 146 try: 147 ref_ob=ref.getObject() 148 rc._deleteReference(ref_ob) 149 except AttributeError: 150 rc.uncatalog_object(ref.getPath()) 151 152 if total%100==0: 153 print total 154 print 'trash: %s , total: %s' % (broken, total) 131 155 132 156 security.declareProtected(MANAGE_PORTAL, 'reindex_section') trunk/LearningResource.py
r2858 r2859 51 51 """ When deleting, remove self from lists of translations and remove related discussions. """ 52 52 translation_parent= self.getTranslation_of() 53 if translation_parent: 53 storeRefs = getattr(item, '_v_cp_refs', None) 54 if translation_parent and not storeRefs: 54 55 translation_parent.removeTranslation(self.UID()) 55 56 # Currently it is a bit improbable that just created 56 57 # object has discussions, but keep it robust for further changes. 57 58 discussion=self.getDiscussion(do_create=False) 58 if discussion :59 if discussion and not storeRefs: 59 60 discussion.aq_parent.manage_delObjects([discussion.id]) 60 61 # Groups do not refer back to objects, only objects refer to groups, so that doesn't trunk/Material.py
r2858 r2859 83 83 """ When deleting, remove branch-related references. """ 84 84 branch_parent= self.getBranch_of() 85 if branch_parent: 86 branch_parent.removeBranch(self.UID()) 85 storeRefs = getattr(item, '_v_cp_refs', None) 86 if branch_parent and not storeRefs: 87 branch_parent.removeFromBranches(self.UID()) 87 88 LearningResource.manage_beforeDelete(self, item, container) 88 89 89 90 ############ Branching ######################################## 91 92 90 93 91 94 security.declareProtected(ADD_CONTENT_PERMISSION,'createBranch') … … 127 130 return REQUEST.RESPONSE.redirect('%s/base_edit' % new.absolute_url()) 128 131 132 133 security.declareProtected(ModerateContent,'removeBranches') 134 def removeBranches(self): 135 """ Manage command to remove broken branches """ 136 self.setBranches([]) 137 129 138 def addToBranches(self, UID): 130 139 """ Makes sure that object UID is in branches """ 131 branch_list = self.getBranches() 132 branch_list = [x.UID() for x in branch_list if x!=None] 140 branch_list = self.getRawBranches() 133 141 if UID not in branch_list: 134 142 branch_list.append(UID) … … 137 145 def removeFromBranches(self, UID): 138 146 """ remove """ 139 branch_list = self.getBranches() 140 branch_list = [z.UID() for x in branch_list if x!=None] 147 branch_list = self.getRawBranches() 141 148 if UID in branch_list: 142 149 branch_list.remove(UID) 143 150 self.setBranches(branch_list) 144 145 def firstEditCancelled(self):146 """ remove from branches and delete this """147 pass148 151 149 152 def allowOnlyBranch(self): trunk/skins/lemill/portlet_macros.pt
r2814 r2859 127 127 <a href="" tal:attributes="href resource"><tal:version i18n:translate="label_copy_version">Version <tal:number i18n:name="number" tal:content="repeat/resource/number">1</tal:number></tal:version></a> 128 128 </li> 129 </tal:branch> 129 130 <li tal:condition="d/original"> 130 131 <a href="" tal:attributes="href d/original" i18n:translate="link_copy_original">Original</a> 131 132 </li> 132 </tal:branch>133 133 </ul> 134 134 </div>
