1.1 --- a/ApproveChangesSupport.py Mon Oct 10 22:15:09 2011 +0200
1.2 +++ b/ApproveChangesSupport.py Mon Oct 10 22:28:58 2011 +0200
1.3 @@ -10,42 +10,24 @@
1.4
1.5 __version__ = "0.1"
1.6
1.7 -def get_queued_changes_area(request):
1.8 - return getattr(request.cfg, "queued_changes_area", "ApprovalQueue")
1.9 +def get_queued_changes_page(request):
1.10 + return getattr(request.cfg, "queued_changes_page", "ApprovalQueue")
1.11
1.12 def get_approved_editors_group(request):
1.13 return getattr(request.cfg, "approved_editors_group", "ApprovedGroup")
1.14
1.15 -def match_queue_pages(pagename, queued_changes_area):
1.16 -
1.17 - "Return a filter function which matches subpages of 'pagename'."
1.18 -
1.19 - return re.compile(ur"^%s/%s/.*$" % (re.escape(pagename), re.escape(queued_changes_area)), re.UNICODE).match
1.20 -
1.21 -def get_queue_pages(request, pagename, queued_changes_area):
1.22 +def is_queued_changes_page(request, pagename):
1.23
1.24 - """
1.25 - Return the queued pages given the 'request', 'pagename' and subpage folder
1.26 - specified by 'queued_changes_area'.
1.27 - """
1.28 -
1.29 - return request.rootpage.getPageList(exists=1, filter=match_queue_pages(pagename, queued_changes_area))
1.30 -
1.31 -def is_queued_page(pagename, queued_changes_area):
1.32 -
1.33 - """
1.34 - Return whether 'pagename' is a queued page by testing for the presence of
1.35 - the 'queued_changes_area' component in its page path.
1.36 - """
1.37 + "Return whether 'pagename' is a queued changes page by testing its name."
1.38
1.39 parts = pagename.split("/")
1.40 - return len(parts) > 2 and parts[-2] == queued_changes_area
1.41 + return len(parts) > 1 and parts[-1] == get_queued_changes_page(request)
1.42
1.43 def get_target_page_name(pagename):
1.44
1.45 - "Return the target page name for the given queued 'pagename'."
1.46 + "Return the target page name for the given queued changes 'pagename'."
1.47
1.48 - return "/".join(pagename.split("/")[:-2])
1.49 + return "/".join(pagename.split("/")[:-1])
1.50
1.51 # Utility classes and associated functions.
1.52 # NOTE: These are a subset of EventAggregatorSupport.
2.1 --- a/actions/ApproveChanges.py Mon Oct 10 22:15:09 2011 +0200
2.2 +++ b/actions/ApproveChanges.py Mon Oct 10 22:28:58 2011 +0200
2.3 @@ -3,8 +3,8 @@
2.4 MoinMoin - ApproveChanges
2.5
2.6 Permit the approval of an edited page queued by the page editor when an
2.7 - unprivileged user attempted to save a page. Since queued pages are placed in
2.8 - a subpage area, this action just moves the queued page content into the
2.9 + unprivileged user attempted to save a page. Since queued changes are placed
2.10 + in a subpage, this action just moves the queued page content into the
2.11 existing page when approving the changes.
2.12
2.13 @copyright: 2011 Paul Boddie <paul@boddie.org.uk>
2.14 @@ -73,7 +73,7 @@
2.15
2.16 # Make sure that only suitably privileged users can perform this action.
2.17
2.18 - queued_changes_area = get_queued_changes_area(request)
2.19 + queued_changes_page = get_queued_changes_page(request)
2.20 reviewers_group = getattr(request.cfg, "reviewers_group", "PageReviewersGroup")
2.21
2.22 if not request.user.valid or (
2.23 @@ -85,7 +85,7 @@
2.24 # Edit the target page, using this page's content.
2.25 # The current page must be a queued page version.
2.26
2.27 - if not is_queued_page(self.pagename, queued_changes_area):
2.28 + if not is_queued_changes_page(request, self.pagename):
2.29 return 0, _("This page is not queued for approval.")
2.30
2.31 target_page_name = get_target_page_name(self.pagename)
2.32 @@ -99,19 +99,13 @@
2.33 pass
2.34
2.35 # Delete the current page.
2.36 + # NOTE: The page could be deleted completely or certain revisions
2.37 + # NOTE: purged.
2.38 + # NOTE: (to-do/proper-queued-page-deletion.txt)
2.39
2.40 current_page = PageEditor(request, self.pagename)
2.41 current_page.deletePage(_("Changes to page approved."))
2.42
2.43 - # Delete the rest of the queue if requested.
2.44 -
2.45 - form = get_form(request)
2.46 -
2.47 - if form.get("purge"):
2.48 - for name in get_queue_pages(request, target_page_name, queued_changes_area):
2.49 - queue_page = PageEditor(request, name)
2.50 - queue_page.deletePage(_("Changes to page rejected."))
2.51 -
2.52 # Redirect to the target page.
2.53
2.54 request.http_redirect(target_page.url(request))
3.1 --- a/events/queue_for_review.py Mon Oct 10 22:15:09 2011 +0200
3.2 +++ b/events/queue_for_review.py Mon Oct 10 22:28:58 2011 +0200
3.3 @@ -18,14 +18,18 @@
3.4 _ = request.getText
3.5
3.6 approved_editors_group = get_approved_editors_group(request)
3.7 - queued_changes_area = get_queued_changes_area(request)
3.8 + queued_changes_page = get_queued_changes_page(request)
3.9
3.10 pagename = event.page_editor.page_name
3.11
3.12 # Saving into queues has to be permitted or the mechanism will keep trying
3.13 # to save into a queue of the specified page.
3.14
3.15 - if is_queued_page(pagename, queued_changes_area):
3.16 + if is_queued_changes_page(request, pagename):
3.17 +
3.18 + # NOTE: Add ACL to prevent normal users from seeing the page anywhere.
3.19 + # NOTE: (to-do/hide-queued-pages.txt)
3.20 +
3.21 return None
3.22
3.23 # For normal pages, the user has to be approved. Otherwise, the page will be
3.24 @@ -35,21 +39,11 @@
3.25 not request.dicts.has_member(approved_editors_group, request.user.name) and \
3.26 not request.user.isSuperUser()):
3.27
3.28 - # Get a queue number by listing the subpages of the queue area and
3.29 - # finding the highest queue number, then adding one to it.
3.30 -
3.31 - queue_number = -1
3.32 + # Save the page in the queue.
3.33 + # NOTE: Record the parent revision.
3.34 + # NOTE: (to-do/record-parent-for-proper-merges.txt)
3.35
3.36 - for name in get_queue_pages(request, pagename, queued_changes_area):
3.37 - number = name.split("/")[-1]
3.38 - if number.isdigit():
3.39 - queue_number = max(queue_number, int(number))
3.40 -
3.41 - queue_number += 1
3.42 -
3.43 - # Save the page in the queue.
3.44 -
3.45 - new_page = PageEditor(request, "%s/%s/%s" % (pagename, queued_changes_area, queue_number))
3.46 + new_page = PageEditor(request, "%s/%s" % (pagename, queued_changes_page))
3.47
3.48 try:
3.49 new_page.saveText(event.new_text, 0)
4.1 --- a/to-do/single-subpage.txt Mon Oct 10 22:15:09 2011 +0200
4.2 +++ b/to-do/single-subpage.txt Mon Oct 10 22:28:58 2011 +0200
4.3 @@ -1,1 +1,1 @@
4.4 -Put queued page versions into a single subpage.
4.5 +Done! (Put queued page versions into a single subpage.)