Changeset 2859

Show
Ignore:
Timestamp:
08/14/09 03:01:43 (2 years ago)
Author:
jukka
Message:

Fixed #1899

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CommonMixIn.py

    r2858 r2859  
    588588            v['original'] = original or False 
    589589 
    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')
    591591            v['showBranches'] = showBranches = original or v['branches'] 
    592592        else: 
  • trunk/LargeSectionFolder.py

    r2858 r2859  
    129129 
    130130 
     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)  
    131155 
    132156    security.declareProtected(MANAGE_PORTAL, 'reindex_section') 
  • trunk/LearningResource.py

    r2858 r2859  
    5151        """ When deleting, remove self from lists of translations and remove related discussions. """         
    5252        translation_parent= self.getTranslation_of() 
    53         if translation_parent: 
     53        storeRefs = getattr(item, '_v_cp_refs', None) 
     54        if translation_parent and not storeRefs: 
    5455            translation_parent.removeTranslation(self.UID()) 
    5556        # Currently it is a bit improbable that just created 
    5657        # object has discussions, but keep it robust for further changes. 
    5758        discussion=self.getDiscussion(do_create=False)  
    58         if discussion
     59        if discussion and not storeRefs
    5960            discussion.aq_parent.manage_delObjects([discussion.id]) 
    6061        # Groups do not refer back to objects, only objects refer to groups, so that doesn't 
  • trunk/Material.py

    r2858 r2859  
    8383        """ When deleting, remove branch-related references. """         
    8484        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()) 
    8788        LearningResource.manage_beforeDelete(self, item, container) 
    8889 
    8990    ############ Branching ######################################## 
     91 
     92 
    9093 
    9194    security.declareProtected(ADD_CONTENT_PERMISSION,'createBranch') 
     
    127130        return REQUEST.RESPONSE.redirect('%s/base_edit' % new.absolute_url())         
    128131 
     132 
     133    security.declareProtected(ModerateContent,'removeBranches') 
     134    def removeBranches(self): 
     135        """ Manage command to remove broken branches """ 
     136        self.setBranches([]) 
     137 
    129138    def addToBranches(self, UID): 
    130139        """ 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() 
    133141        if UID not in branch_list: 
    134142            branch_list.append(UID) 
     
    137145    def removeFromBranches(self, UID): 
    138146        """ remove """ 
    139         branch_list = self.getBranches() 
    140         branch_list = [z.UID() for x in branch_list if x!=None] 
     147        branch_list = self.getRawBranches() 
    141148        if UID in branch_list: 
    142149            branch_list.remove(UID) 
    143150            self.setBranches(branch_list) 
    144  
    145     def firstEditCancelled(self): 
    146         """ remove from branches and delete this """ 
    147         pass 
    148151 
    149152    def allowOnlyBranch(self): 
  • trunk/skins/lemill/portlet_macros.pt

    r2814 r2859  
    127127          <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> 
    128128        </li> 
     129        </tal:branch> 
    129130        <li tal:condition="d/original"> 
    130131          <a href="" tal:attributes="href d/original" i18n:translate="link_copy_original">Original</a> 
    131132        </li> 
    132         </tal:branch> 
    133133    </ul> 
    134134</div>