1.1 --- a/ApproveChangesSupport.py Wed Oct 12 00:04:21 2011 +0200
1.2 +++ b/ApproveChangesSupport.py Wed Oct 12 00:33:12 2011 +0200
1.3 @@ -16,6 +16,7 @@
1.4 """
1.5
1.6 from MoinMoin import user
1.7 +from MoinMoin.wikiutil import escape
1.8 import re
1.9
1.10 acl_pattern = re.compile(ur"^#acl .*$", re.UNICODE | re.MULTILINE)
1.11 @@ -164,4 +165,7 @@
1.12 else:
1.13 return request.form
1.14
1.15 +def escattr(s):
1.16 + return escape(s, 1)
1.17 +
1.18 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/actions/ApproveChanges.py Wed Oct 12 00:04:21 2011 +0200
2.2 +++ b/actions/ApproveChanges.py Wed Oct 12 00:33:12 2011 +0200
2.3 @@ -14,8 +14,8 @@
2.4 Dependencies = ['pages']
2.5
2.6 from MoinMoin.action import ActionBase
2.7 +from MoinMoin.Page import Page
2.8 from MoinMoin.PageEditor import PageEditor
2.9 -from MoinMoin.wikiutil import escape
2.10 from ApproveChangesSupport import *
2.11
2.12 # Action class and supporting functions.
2.13 @@ -34,6 +34,8 @@
2.14 _ = self._
2.15 request = self.request
2.16 fmt = request.formatter
2.17 + form = get_form(request)
2.18 + rev = form.get("rev")
2.19
2.20 d = {
2.21 "buttons_html" : buttons_html,
2.22 @@ -54,6 +56,10 @@
2.23 </tr>
2.24 </table>''' % d
2.25
2.26 + if rev:
2.27 + html += '''
2.28 +<input name="rev" type="hidden" value="%(rev)s" />''' % {"rev" : escattr(rev[0])}
2.29 +
2.30 return html
2.31
2.32 def do_action(self):
2.33 @@ -80,12 +86,24 @@
2.34 target_page = PageEditor(request, target_page_name)
2.35
2.36 # Save the target page, removing any protective ACL.
2.37 + # First, the displayed revision must be retrieved.
2.38
2.39 - body = self.page.get_raw_body()
2.40 + form = get_form(request)
2.41 +
2.42 + # Get the revision or None.
2.43 +
2.44 + rev = form.get("rev")
2.45 + if rev is None:
2.46 + rev = self.page.current_rev()
2.47 + else:
2.48 + rev = int(rev[0])
2.49 +
2.50 + page = Page(request, self.page.page_name, rev=rev)
2.51 + body = page.get_raw_body()
2.52 body = remove_access_control(request, body)
2.53
2.54 try:
2.55 - target_page.saveText(body, 0, comment=_("Changes to page approved."))
2.56 + target_page.saveText(body, 0, comment=_("Changes to page approved from queue revision %d.") % rev)
2.57 except PageEditor.Unchanged:
2.58 pass
2.59
3.1 --- a/to-do/approve-specific-version.txt Wed Oct 12 00:04:21 2011 +0200
3.2 +++ b/to-do/approve-specific-version.txt Wed Oct 12 00:33:12 2011 +0200
3.3 @@ -1,2 +1,3 @@
3.4 -The approval action should act like the revert action and operate on a specific
3.5 -revision of each queued changes page.
3.6 +Done!
3.7 +(The approval action should act like the revert action and operate on a specific
3.8 +revision of each queued changes page.)