- Version: %d Status: %s
- > > %s > >
29a30,32
> Frank Steinhauer (FST) 11.2010:
> * added approval changes based on Oliver Siemoneit (12.2006) and "lameike" (02.2010)
>
205a209,308
> #FST start new methods
> def isApprovedPage(self):
> """ is this page/document approved?
> @rtype: bool
> @return: true, if this page has been approved
> """
> approvedFile = os.path.join(self.getPagePath(), "approved")
> if os.path.isfile(approvedFile):
> approvedRevision = {}
> for line in open(approvedFile).readlines():
> tmp = line.split("\t")
> approvedRevision[tmp[0]] = tmp[1]
> currentRevision = "%08d" % self.get_real_rev()
> if currentRevision in approvedRevision:
> return True
> return False
>
> def getLastApprovedVersion(self):
> """ get the last approved version of this page/document
> @rtype: int
> @return: version number, None if page is not approved (yet)
> """
> approvedFile = os.path.join(self.getPagePath(), "approved")
> if os.path.isfile(approvedFile):
> approvedRevision = []
> for line in open(approvedFile).readlines():
> tmp = line.split("\t")
> approvedRevision.append(int(tmp[0]))
> if len(approvedRevision) == 0:
> return None
> else:
> return max(approvedRevision)
> else:
> return None
>
> def getApprovalMessage(self):
> pi = self.parse_processing_instructions()
> if pi['review'] == None:
> return ""
> currentRevision = self.get_real_rev()
> approvedFile = os.path.join(self.getPagePath(), "approved")
> approvedRevision = []
> approvers = []
> approvedDateTime = []
> approvedURL = []
> boxtype = "warning"
> history = ""
> if os.path.isfile(approvedFile):
> for line in open(approvedFile).readlines():
> tmp = line.split("\t")
> approvedRevision.append(int(tmp[0]))
> approvers.append(tmp[1])
> #thatTime = datetime.strptime(tmp[2], "%Y/%m/%d %H:%M:S")
> #approvedDateTime.append(thatTime.isoformat())
> approvedDateTime.append(tmp[2] if len(tmp) > 2 else ">see Info or last line in revision<" )
> approvedURL.append( '%s/%s?action=show&rev=%d' % (
> self.request.getScriptname(),
> wikiutil.quoteWikinameURL(self.page_name),
> int(tmp[0])) )
>
> history = ""
> for i in range(len(approvedRevision)):
> history = ("Version %d: approved on %s by %s\n
\n%s") % (approvedURL[i], approvedRevision[i], approvedDateTime[i], approvers[i], history )
>
> if (currentRevision == len(self.getRevList())) and (not currentRevision == max(approvedRevision)):
> # most recent version, not yet approved
> status = "Draft"
> boxtype = "caution"
> elif currentRevision == max(approvedRevision):
> # latest approved version (could but need not be most recent version of all)
> status = "Approved"
> boxtype = "important"
> elif currentRevision in approvedRevision:
> # any approved version (not the latest because of previous block)
> status = "Invalid (approved, but outdated)!"
> boxtype = "warning"
> else:
> # some in-between version, never approved
> status = "Invalid"
> boxtype = "warning"
> else:
> # no approval history yet, so this is a draft
> status = "Draft"
> boxtype = "caution"
>
> return '''
>