Changeset 2996

Show
Ignore:
Timestamp:
01/12/10 14:39:49 (2 years ago)
Author:
jukka
Message:

Fixed #1883, added two management scripts to remove unnecessary history entries or to reauthor them.

Files:

Legend:

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

    r2995 r2996  
    407407            return '' 
    408408 
     409 
     410    security.declareProtected(MANAGE_PORTAL, 'resetFirstAuthor') 
     411    def resetFirstAuthor(self, userid): 
     412        """ If after copying, updating or some other maintenance act the first author of a resource has changed 
     413            this maintenance method helps to set first author to userid """ 
     414        history=self.getHistory() 
     415        history[-1]['_by']=userid 
     416        self.setHistory(history) 
     417        self.recalculateAuthors()         
     418 
     419    security.declareProtected(MANAGE_PORTAL, 'removeHistoryEntry') 
     420    def removeHistoryEntry(self, index): 
     421        """ If after copying, updating or some other maintenance creates a misleading history entry 
     422            this maintenance method removes it. """ 
     423        history=self.getHistory() 
     424        del history[int(index)] 
     425        self.setHistory(history) 
     426        self.recalculateAuthors()         
     427 
    409428    security.declarePrivate('recalculateAuthors') 
    410429    def recalculateAuthors(self, removeAdmin=''): 
     
    439458            original_creator = history_entries[i].get('author','')  
    440459            i-=1 
    441         now = time.time() 
    442460        print 'original_creator: %s' % original_creator 
    443461 
     
    661679        return time.asctime(time.localtime(timestamp)) 
    662680 
     681 
    663682    def getHistoricalFields(self, timestamp, take_previous_version=False): 
    664683        """ get historical fields from timestamp or the immediate next entry before timestamp (previous version) """