1.1 --- a/actions/ApproveChanges.py Sat Oct 15 01:45:27 2011 +0200
1.2 +++ b/actions/ApproveChanges.py Sat Oct 15 01:48:48 2011 +0200
1.3 @@ -101,7 +101,7 @@
1.4
1.5 # Remove any introduced directives.
1.6
1.7 - body, directives = remove_directives(body, ["acl", "parent-revision"])
1.8 + body, directives = remove_directives(body, ["acl", "parent-revision", "unapproved-user"])
1.9
1.10 # Get the target page's parent revision for the queued changes.
1.11
1.12 @@ -151,10 +151,32 @@
1.13 # Save the target page, but only if there is no conflict.
1.14
1.15 if not conflict:
1.16 +
1.17 + # Switch user if a specific user was recorded.
1.18 +
1.19 + username = directives.get("unapproved-user")
1.20 + if username:
1.21 + new_user = get_user(request, username)
1.22 + else:
1.23 + new_user = None
1.24 +
1.25 + if new_user:
1.26 + user = request.user
1.27 + request.user = new_user
1.28 +
1.29 + # Save the page.
1.30 +
1.31 try:
1.32 - target_page.saveText(body, 0, comment=comment)
1.33 - except PageEditor.Unchanged:
1.34 - pass
1.35 + try:
1.36 + target_page.saveText(body, 0, comment=comment)
1.37 + except PageEditor.Unchanged:
1.38 + pass
1.39 +
1.40 + # Restore the user.
1.41 +
1.42 + finally:
1.43 + if new_user:
1.44 + request.user = user
1.45
1.46 # Redirect to the target page.
1.47