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.You are not allowed to attach a file to this page.