Attachment 'PageApproval.diff'

Download

   1 --- Page.py.orig	2008-02-11 19:00:12.000000000 -0300
   2 +++ Page.py	2008-02-11 22:58:03.000000000 -0300
   3 @@ -503,6 +503,41 @@
   4          """
   5          return self.exists(domain='standard', includeDeleted=includeDeleted)
   6  
   7 +    def isApprovedPage(self):
   8 +        """ Is this page approved for public viewing?
   9 +
  10 +        @rtype: bool
  11 +        @return: true, if this page has been approved 
  12 +        """
  13 +        approvedFile = os.path.join(self.getPagePath(), "approved")
  14 +        if os.path.isfile(approvedFile):
  15 +            approvedRevision = {}
  16 +            for line in open(approvedFile).readlines():
  17 +                tmp = line.split("\t")
  18 +                approvedRevision[tmp[0]] = tmp[1]
  19 +            currentRevision = "%08d" % self.get_real_rev()
  20 +            if currentRevision in approvedRevision:
  21 +                return True
  22 +        return False
  23 +
  24 +    def getLastApprovedVersion(self):
  25 +       """ Get The last approved version for public viewing
  26 +       @rtype: int
  27 +       @return: Version number, None if none approved
  28 +       """
  29 +       approvedFile = os.path.join(self.getPagePath(), "approved")
  30 +       if os.path.isfile(approvedFile):
  31 +           approvedRevision = []
  32 +           for line in open(approvedFile).readlines():
  33 +               tmp = line.split("\t")
  34 +               approvedRevision.append(int(tmp[0]))
  35 +           if len(approvedRevision) ==  0:
  36 +               return None
  37 +           else:
  38 +               return max(approvedRevision)
  39 +       else:
  40 +           return None
  41 +
  42      def exists(self, rev=0, domain=None, includeDeleted=False):
  43          """ Does this page exist?
  44  
  45 @@ -1032,6 +1067,7 @@
  46          pi_formtext = []
  47          pi_formfields = []
  48          pi_lines = 0
  49 +        pi_review = None
  50  
  51          # check for XML content
  52          if body and body[:5] == '<?xml':
  53 @@ -1130,6 +1166,9 @@
  54                  if args in i18n.wikiLanguages():
  55                      self.language = args
  56                      request.setContentLanguage(self.language)
  57 +            elif verb == "review":
  58 +                # This page can be reviewed/approved
  59 +                pi_review = args
  60              else:
  61                  # unknown PI ==> end PI parsing, and show invalid PI as text
  62                  body = line + '\n' + body
  63 @@ -1144,6 +1183,20 @@
  64          if not content_only:
  65              request.setHttpHeader("Content-Type: %s; charset=%s" % ('text/html', config.charset))
  66              if page_exists:
  67 +                # Before sending anything check if we need to redirect to the last Approved Version
  68 +                if ( pi_review == "yes" ) and (not self.isApprovedPage()) and (not request.user.may.review(self.page_name)):
  69 +                    lastApRev = self.getLastApprovedVersion()
  70 +                    if lastApRev != None:
  71 +                        # Redirect to the latest Public Revision
  72 +                        rev = int(lastApRev)
  73 +                        pi_redirect = self.page_name
  74 +                        url_str = '%s/%s?action=show&rev=%d&redirect=%s' % (
  75 +                               request.getScriptname(),
  76 +                               wikiutil.quoteWikinameURL(pi_redirect),
  77 +                               rev,
  78 +                               wikiutil.url_quote_plus(self.page_name, ''),)
  79 +                        request.http_redirect(url_str)
  80 +                        return
  81                  request.setHttpHeader('Status: 200 OK')
  82                  if not request.cacheable:
  83                      # use "nocache" headers if we're using a method that is not simply "display"
  84 @@ -1162,6 +1215,7 @@
  85                  request.setHttpHeader('Status: 404 NOTFOUND')
  86                  request.setResponseCode(404)
  87  
  88 +
  89              request.http_headers()
  90              request.write(doc_leader)
  91  
  92 @@ -1248,6 +1302,8 @@
  93                                                  formatter=self.formatter))
  94          elif not request.user.may.read(self.page_name):
  95              request.write("<strong>%s</strong><br>" % _("You are not allowed to view this page."))
  96 +        elif (pi_review == "yes") and (not self.isApprovedPage()) and (not request.user.may.review(self.page_name)):
  97 +              request.write("<strong>%s</strong><br>" % _("Sorry. This page has not been approved yet for public access or you are not allowed to review it."))
  98          else:
  99              # parse the text and send the page content
 100              self.send_page_content(request, Parser, body,

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-02-05 17:13:18, 2.6 KB) [[attachment:ApprovePage-191.py]]
  • [get | view] (2005-10-18 14:16:34, 2.8 KB) [[attachment:ApprovePage.py]]
  • [get | view] (2005-11-08 14:48:57, 2.9 KB) [[attachment:ApprovePage.py-20050811]]
  • [get | view] (2005-11-08 14:51:44, 2.9 KB) [[attachment:ApprovePage.py-20050811-2]]
  • [get | view] (2010-11-18 09:43:04, 7.1 KB) [[attachment:Page.diff-v193-18112010]]
  • [get | view] (2010-02-05 17:15:25, 78.1 KB) [[attachment:Page.py]]
  • [get | view] (2010-11-18 09:41:22, 79.2 KB) [[attachment:Page.py-v193-18112010]]
  • [get | view] (2010-02-05 17:15:58, 4.3 KB) [[attachment:Page.py.patch]]
  • [get | view] (2008-02-12 01:09:14, 4.3 KB) [[attachment:PageApproval.diff]]
  • [get | view] (2010-02-05 17:25:50, 21.4 KB) [[attachment:approval-history.png]]
  • [get | view] (2010-11-18 10:19:10, 2.4 KB) [[attachment:approvePage.py-v193-18112010]]
  • [get | view] (2006-12-04 21:40:20, 3.0 KB) [[attachment:approvepage2.py]]
  • [get | view] (2005-10-18 14:17:03, 4.5 KB) [[attachment:modern.py]]
  • [get | view] (2010-11-18 09:42:23, 3.8 KB) [[attachment:modern_iso.diff-v193-18112010]]
  • [get | view] (2005-11-08 14:48:07, 4.6 KB) [[attachment:modern_iso.py]]
  • [get | view] (2010-11-18 09:40:06, 6.2 KB) [[attachment:modern_iso.py-v193-18112010]]
  • [get | view] (2006-12-04 21:40:00, 4.9 KB) [[attachment:modern_iso2.py]]
  • [get | view] (2010-11-18 09:40:39, 15.0 KB) [[attachment:modernized_iso.py-v193-18112010]]
  • [get | view] (2006-12-04 21:40:39, 1.5 KB) [[attachment:page.diff]]
  • [get | view] (2010-11-18 10:10:42, 7.2 KB) [[attachment:rightsidebar_iso.py-v193-18112010]]
  • [get | view] (2010-02-05 17:13:56, 29.0 KB) [[attachment:solenoid_iso-191.py]]
  • [get | view] (2010-02-05 17:15:05, 1.4 KB) [[attachment:solenoid_iso-191.py.patch]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.