# HG changeset patch # User Paul Boddie # Date 1318278538 -7200 # Node ID 272ec424a9874c1b67abf242d061f9d3e4665871 # Parent 542d8a9bd507d1027f1c50e21b5601a51cb86c46 Changed the storage of queued changes to use a single subpage under each page. diff -r 542d8a9bd507 -r 272ec424a987 ApproveChangesSupport.py --- a/ApproveChangesSupport.py Mon Oct 10 22:15:09 2011 +0200 +++ b/ApproveChangesSupport.py Mon Oct 10 22:28:58 2011 +0200 @@ -10,42 +10,24 @@ __version__ = "0.1" -def get_queued_changes_area(request): - return getattr(request.cfg, "queued_changes_area", "ApprovalQueue") +def get_queued_changes_page(request): + return getattr(request.cfg, "queued_changes_page", "ApprovalQueue") def get_approved_editors_group(request): return getattr(request.cfg, "approved_editors_group", "ApprovedGroup") -def match_queue_pages(pagename, queued_changes_area): - - "Return a filter function which matches subpages of 'pagename'." - - return re.compile(ur"^%s/%s/.*$" % (re.escape(pagename), re.escape(queued_changes_area)), re.UNICODE).match - -def get_queue_pages(request, pagename, queued_changes_area): +def is_queued_changes_page(request, pagename): - """ - Return the queued pages given the 'request', 'pagename' and subpage folder - specified by 'queued_changes_area'. - """ - - return request.rootpage.getPageList(exists=1, filter=match_queue_pages(pagename, queued_changes_area)) - -def is_queued_page(pagename, queued_changes_area): - - """ - Return whether 'pagename' is a queued page by testing for the presence of - the 'queued_changes_area' component in its page path. - """ + "Return whether 'pagename' is a queued changes page by testing its name." parts = pagename.split("/") - return len(parts) > 2 and parts[-2] == queued_changes_area + return len(parts) > 1 and parts[-1] == get_queued_changes_page(request) def get_target_page_name(pagename): - "Return the target page name for the given queued 'pagename'." + "Return the target page name for the given queued changes 'pagename'." - return "/".join(pagename.split("/")[:-2]) + return "/".join(pagename.split("/")[:-1]) # Utility classes and associated functions. # NOTE: These are a subset of EventAggregatorSupport. diff -r 542d8a9bd507 -r 272ec424a987 actions/ApproveChanges.py --- a/actions/ApproveChanges.py Mon Oct 10 22:15:09 2011 +0200 +++ b/actions/ApproveChanges.py Mon Oct 10 22:28:58 2011 +0200 @@ -3,8 +3,8 @@ MoinMoin - ApproveChanges Permit the approval of an edited page queued by the page editor when an - unprivileged user attempted to save a page. Since queued pages are placed in - a subpage area, this action just moves the queued page content into the + unprivileged user attempted to save a page. Since queued changes are placed + in a subpage, this action just moves the queued page content into the existing page when approving the changes. @copyright: 2011 Paul Boddie @@ -73,7 +73,7 @@ # Make sure that only suitably privileged users can perform this action. - queued_changes_area = get_queued_changes_area(request) + queued_changes_page = get_queued_changes_page(request) reviewers_group = getattr(request.cfg, "reviewers_group", "PageReviewersGroup") if not request.user.valid or ( @@ -85,7 +85,7 @@ # Edit the target page, using this page's content. # The current page must be a queued page version. - if not is_queued_page(self.pagename, queued_changes_area): + if not is_queued_changes_page(request, self.pagename): return 0, _("This page is not queued for approval.") target_page_name = get_target_page_name(self.pagename) @@ -99,19 +99,13 @@ pass # Delete the current page. + # 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 approved.")) - # Delete the rest of the queue if requested. - - form = get_form(request) - - if form.get("purge"): - for name in get_queue_pages(request, target_page_name, queued_changes_area): - queue_page = PageEditor(request, name) - queue_page.deletePage(_("Changes to page rejected.")) - # Redirect to the target page. request.http_redirect(target_page.url(request)) diff -r 542d8a9bd507 -r 272ec424a987 events/queue_for_review.py --- a/events/queue_for_review.py Mon Oct 10 22:15:09 2011 +0200 +++ b/events/queue_for_review.py Mon Oct 10 22:28:58 2011 +0200 @@ -18,14 +18,18 @@ _ = request.getText approved_editors_group = get_approved_editors_group(request) - queued_changes_area = get_queued_changes_area(request) + queued_changes_page = get_queued_changes_page(request) pagename = event.page_editor.page_name # Saving into queues has to be permitted or the mechanism will keep trying # to save into a queue of the specified page. - if is_queued_page(pagename, queued_changes_area): + if is_queued_changes_page(request, pagename): + + # NOTE: Add ACL to prevent normal users from seeing the page anywhere. + # NOTE: (to-do/hide-queued-pages.txt) + return None # For normal pages, the user has to be approved. Otherwise, the page will be @@ -35,21 +39,11 @@ not request.dicts.has_member(approved_editors_group, request.user.name) and \ not request.user.isSuperUser()): - # Get a queue number by listing the subpages of the queue area and - # finding the highest queue number, then adding one to it. - - queue_number = -1 + # Save the page in the queue. + # NOTE: Record the parent revision. + # NOTE: (to-do/record-parent-for-proper-merges.txt) - for name in get_queue_pages(request, pagename, queued_changes_area): - number = name.split("/")[-1] - if number.isdigit(): - queue_number = max(queue_number, int(number)) - - queue_number += 1 - - # Save the page in the queue. - - new_page = PageEditor(request, "%s/%s/%s" % (pagename, queued_changes_area, queue_number)) + new_page = PageEditor(request, "%s/%s" % (pagename, queued_changes_page)) try: new_page.saveText(event.new_text, 0) diff -r 542d8a9bd507 -r 272ec424a987 to-do/single-subpage.txt --- a/to-do/single-subpage.txt Mon Oct 10 22:15:09 2011 +0200 +++ b/to-do/single-subpage.txt Mon Oct 10 22:28:58 2011 +0200 @@ -1,1 +1,1 @@ -Put queued page versions into a single subpage. +Done! (Put queued page versions into a single subpage.)