# HG changeset patch # User Paul Boddie # Date 1318693162 -7200 # Node ID 2e97d9694103e8e6bf7d975164f240c54a97a6a5 # Parent f0f973f66678eb012921ec6fc9203eb0391fc7db Made it possible for queued changes to be saved into the target page as the original author of the changes by introducing an exception for the ApproveChanges action into the event handling logic. Added a notice in the action indicating whether competing edits have been made to the target page since the queued changes were saved. diff -r f0f973f66678 -r 2e97d9694103 actions/ApproveChanges.py --- a/actions/ApproveChanges.py Sat Oct 15 01:48:48 2011 +0200 +++ b/actions/ApproveChanges.py Sat Oct 15 17:39:22 2011 +0200 @@ -31,16 +31,47 @@ self.form_trigger = "approve" self.form_trigger_label = _("Approve changes") + def get_revision(self): + request = self.request + form = get_form(request) + + # Get the revision or None. + + rev = form.get("rev") + if rev is None: + return self.page.current_rev() + else: + return int(rev[0]) + + def get_body(self, rev): + request = self.request + page = Page(request, self.page.page_name, rev=rev) + return page.get_raw_body() + def get_form_html(self, buttons_html): _ = self._ request = self.request fmt = request.formatter - form = get_form(request) - rev = form.get("rev") + rev = self.get_revision() + + # Get information about the queued changes. + + body = self.get_body(rev) + _body, directives = remove_directives(body, ["acl", "parent-revision", "unapproved-user"]) + + # Get the target page's parent revision for the queued changes. + + target_page_name = get_target_page_name(self.pagename) + target_page = PageEditor(request, target_page_name) + + current_rev = target_page.current_rev() + parent_rev = int(directives.get("parent-revision", current_rev)) d = { "buttons_html" : buttons_html, "prompt" : escape(_("Approve the displayed page version?")), + "rev" : escattr(rev), + "notice" : escape(_("The affected page has been edited since the queued changes were made.")), } # Prepare the output HTML. @@ -49,7 +80,15 @@ - + ''' % d + + if parent_rev != current_rev: + html += ''' + + + ''' % d + + html += '''
%(prompt)s
%(notice)s
%(buttons_html)s @@ -59,7 +98,7 @@ if rev: html += ''' -''' % {"rev" : escattr(rev[0])} +''' % d return html @@ -86,18 +125,8 @@ # First, the displayed revision of the queued changes page must be # retrieved. - form = get_form(request) - - # Get the revision or None. - - rev = form.get("rev") - if rev is None: - rev = self.page.current_rev() - else: - rev = int(rev[0]) - - page = Page(request, self.page.page_name, rev=rev) - body = page.get_raw_body() + rev = self.get_revision() + body = self.get_body(rev) # Remove any introduced directives. diff -r f0f973f66678 -r 2e97d9694103 events/queue_for_review.py --- a/events/queue_for_review.py Sat Oct 15 01:48:48 2011 +0200 +++ b/events/queue_for_review.py Sat Oct 15 17:39:22 2011 +0200 @@ -36,9 +36,10 @@ return Abort(_("Queued changes may not be edited.")) # For normal pages, the user has to be approved. Otherwise, the page will be - # saved into a queue. + # saved into a queue. If the save operation occurs as part of an approval + # action, however, the effective user will be able to save the page. - elif not is_approved(request): + elif not request.action == "ApproveChanges" and not is_approved(request): # Save the page in the queue.