1.1 --- a/ApproveChangesSupport.py Tue Sep 03 00:33:30 2013 +0200
1.2 +++ b/ApproveChangesSupport.py Tue Nov 05 20:33:53 2013 +0100
1.3 @@ -24,11 +24,19 @@
1.4 from MoinMoin.wikiutil import escape
1.5 import re
1.6
1.7 -__version__ = "0.1.1"
1.8 +__version__ = "0.2"
1.9
1.10 space_pattern = re.compile("(\s+)")
1.11 group_member_pattern = re.compile(ur'^ \* +(?:\[\[)?(?P<member>.+?)(?:\]\])? *$', re.MULTILINE | re.UNICODE)
1.12
1.13 +def have_user_specific_queue(request):
1.14 + return getattr(request.cfg, "queued_changes_per_user", False)
1.15 +
1.16 +def get_user_specific_queue(request):
1.17 + return have_user_specific_queue(request) and \
1.18 + request.user.valid and ("%s/" % request.user.name) or \
1.19 + ""
1.20 +
1.21 def get_queued_changes_page(request):
1.22 return getattr(request.cfg, "queued_changes_page", "ApprovalQueue")
1.23
1.24 @@ -64,11 +72,14 @@
1.25 parts = pagename.split("/")
1.26 return len(parts) > 1 and parts[-1] == get_queued_changes_page(request)
1.27
1.28 -def get_target_page_name(pagename):
1.29 +def get_target_page_name(page):
1.30 +
1.31 + "Return the target page name for the given queued changes 'page'."
1.32
1.33 - "Return the target page name for the given queued changes 'pagename'."
1.34 -
1.35 - return "/".join(pagename.split("/")[:-1])
1.36 + directive = "unapproved-user-queue"
1.37 + body, directives = remove_directives(page.get_raw_body(), [directive])
1.38 + extra_parts = directives.has_key(directive) and 2 or 1
1.39 + return "/".join(page.page_name.split("/")[:-extra_parts])
1.40
1.41 def get_user_for_saving(request):
1.42
1.43 @@ -127,6 +138,18 @@
1.44 else:
1.45 return ""
1.46
1.47 +def get_user_queue_directive(request):
1.48 +
1.49 + """
1.50 + Using the 'request', return a user directive for use in a page body in order
1.51 + to record who saved the changes originally.
1.52 + """
1.53 +
1.54 + if request.user.valid and have_user_specific_queue(request):
1.55 + return "#unapproved-user-queue"
1.56 + else:
1.57 + return ""
1.58 +
1.59 def add_directives(body, directives):
1.60
1.61 "Add to the page 'body' the given 'directives'."