3c3 < MoinMoin - modern theme --- > MoinMoin - modern theme, enhanced to support ISO/FDA like review and approval 6a7,11 > > Frank Steinhauer (FST) 11.2010: > * added approval changes of Oliver Siemoneit 12.2006, improved a bit > * approvePage action not written in capital letters to avoid auto matic appending to the actions menu. > 8a14 > import os #FST 9a16 > from MoinMoin import wikiutil 13c20,97 < name = "modern" --- > #FST start > name = "modern_iso" > > _showApproveLink = None > > def showApproval(self, page): > """ This methods > * writes approved by xxx into the output if current version is approved > * sets the flag that controls the "Approve" link in the Editbar > """ > > # check whether page exists at all > if not page.exists(): > return "" > > # don't show approval stuff when login or searching > action = self.request.query_string > if action.startswith('action=login') or action.startswith('action=fullsearch') or action.startswith('action=user'): > return "" > > # check if file "approved" exists in page dir > approvedFile = os.path.join(page.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" % page.get_real_rev() > if currentRevision in approvedRevision: > self._showApproveLink = False > return "approved by " + approvedRevision[currentRevision] > if page.get_real_rev() == page.getRevList()[0]: > self._showApproveLink = True > else: > self._showApproveLink = False > return "" > > def showApprovalHistory(self, d): > """ > Show box with approval message if there is are approved versions of this page > """ > page = d['page'] > > # check whether page exists at all > if not page.exists(): > return "" > > approvedFile = os.path.join(page.getPagePath(), "approved") > if os.path.isfile(approvedFile): > action = self.request.query_string > # Note: if (self.query_string.find('action=login') < 0) might work too... > if not action.startswith('action=login') and not action.startswith('action=fullsearch') and not action.startswith('action=user'): > # return the page's approval status > return page.getApprovalMessage() > return "" > > def approveLink(self, page): > """ Return approve link to valid users > Use small letters in action name to prevent adding Action to "more Actions" scrolldown list > @rtype: unicode > @return: approve link > """ > _ = self.request.getText > > #if user has perms > title = _("Approve") > quotedname = wikiutil.quoteWikinameURL(page.page_name) > return page.link_to(self.request, text=_('Approve', formatted=False), querystr='action=approvePage') > > def editbarItems(self, page): > """ add our approve stuff to the list """ > > links = ThemeBase.editbarItems(self,page) > if self._showApproveLink: > if "approve" not in self.request.cfg.actions_excluded and self.request.user.may.approve(page.page_name): > links.append(self.approveLink(page)) > return links > #FST end 33a118 > self.showApproval(d['page']), #FST 37d121 < #u'