# HG changeset patch # User Paul Boddie # Date 1384044477 -3600 # Node ID b1d7199b266879422e599828a2382e3927b7e7da # Parent d8385e3c215f82801cfc63e19599244fdf035acb Changed the action to support discarding of edits, review of other queued edits, and the eventual possibility to block users. diff -r d8385e3c215f -r b1d7199b2668 actions/ApproveChanges.py --- a/actions/ApproveChanges.py Wed Nov 06 17:20:30 2013 +0100 +++ b/actions/ApproveChanges.py Sun Nov 10 01:47:57 2013 +0100 @@ -17,6 +17,7 @@ from MoinMoin.Page import Page from MoinMoin.PageEditor import PageEditor, conflict_markers from MoinMoin.util import diff3 +from MoinSupport import getPagesForSearch from ApproveChangesSupport import * # Action class and supporting functions. @@ -30,8 +31,8 @@ def __init__(self, pagename, request): ActionBase.__init__(self, pagename, request) _ = self._ - self.form_trigger = "approve" - self.form_trigger_label = _("Approve changes") + self.form_trigger = "execute" + self.form_trigger_label = _("Execute the indicated changes") def get_revision(self): request = self.request @@ -54,6 +55,7 @@ _ = self._ request = self.request fmt = request.formatter + form = get_form(request) if not is_queued_changes_page(request, self.pagename): return fmt.paragraph(1) + fmt.text(_("This page does not show queued changes.")) + fmt.paragraph(0) @@ -77,36 +79,98 @@ username = directives.get("unapproved-user") + # Get other edit details, if requested. + + if form.get("show-edits") and username: + queued_edits = getPagesForSearch("title:regex:%s/ApprovalQueue$" % username, request) + else: + queued_edits = [] + d = { "approval_label" : escape(_("Make %s an approved user") % username), + "approve_edit_label" : escape(_("Approve the displayed page version")), + "block_label" : escape(_("Block user %s by disabling their account") % username), "buttons_html" : buttons_html, - "prompt" : escape(_("Approve the displayed page version?")), + "discard_edit_label" : escape(_("Discard the displayed page version")), + "editaction_label" : escape(_("Edit action")), + "nothing_label" : escape(_("Take no action for now")), "rev" : escattr(rev), "notice" : escape(_("The affected page has been edited since the queued changes were made.")), + "show_edits_label" : escattr(_("Show all queued edits by this user.")), + "showing_edits_label" : escape(_("Queued edits by this user")), + "useraction_label" : escape(_("User action")), } + # Make sure that the radio buttons are selected. + + for value in "nothing", "approve", "block": + d["useraction_%s" % value] = form.get("useraction", ["nothing"])[0] == value and "checked='checked'" or "" + + for value in "approve", "discard": + d["editaction_%s" % value] = form.get("editaction", ["approve"])[0] == value and "checked='checked'" or "" + # Prepare the output HTML. html = ''' - - - - ''' % d +
%(prompt)s
''' if parent_rev != current_rev: html += ''' - + ''' % d + # Actions to be taken with the edit. + + html += ''' + + + + + + + ''' % d + + # User information and actions. + if username and not user_is_approved(request, username): + if not queued_edits: + html += ''' + + + + ''' % d + else: + html += ''' + + + + ''' + + # Actions to be taken with the user. + html += ''' - + + + + + + + + ''' % d html += ''' + @@ -164,9 +228,27 @@ # Approve the user if requested, regardless of what happens below. - if username and form.get("approve", ["false"])[0] == "true": + if username and form.get("useraction", [""])[0] == "approve": add_to_group_page(request, username, get_approved_editors_group(request)) + # NOTE: Add user blocking. + + # Discard the edit if requested. + + if form.get("editaction", [""])[0] == "discard": + + # NOTE: The page could be deleted completely or certain revisions + # NOTE: purged. + # NOTE: (to-do/proper-queued-page-deletion.txt) + + current_page = PageEditor(request, self.pagename) + current_page.deletePage(_("Changes to page discarded.")) + + # Redirect to the target page. + + request.http_redirect(target_page.url(request)) + return 1, None + # Where the parent revision differs from the current revision of the # page, attempt to merge the changes.
%(notice)s%(notice)s
    ''' % d + + for queued_page in queued_edits: + html += ''' +
  • %s
  • ''' % escape(queued_page.page_name) + + html += ''' +
%(approval_label)s
%(buttons_html)s