ApproveChanges

Changeset

32:d8385e3c215f
2013-11-06 Paul Boddie raw files shortlog changelog graph Added usage of MoinSupport for common extension functionality.
ApproveChangesSupport.py (file) README.txt (file)
     1.1 --- a/ApproveChangesSupport.py	Tue Nov 05 23:19:02 2013 +0100
     1.2 +++ b/ApproveChangesSupport.py	Wed Nov 06 17:20:30 2013 +0100
     1.3 @@ -18,6 +18,7 @@
     1.4  from MoinMoin.Page import Page
     1.5  from MoinMoin.PageEditor import PageEditor
     1.6  from MoinMoin.wikiutil import escape
     1.7 +from MoinSupport import Form, ActionSupport, get_form, escattr, groupHasMember
     1.8  import re
     1.9  
    1.10  __version__ = "0.2"
    1.11 @@ -44,7 +45,7 @@
    1.12  
    1.13  def is_reviewer(request):
    1.14      return request.user.valid and (
    1.15 -        has_member(request, get_page_reviewers_group(request), request.user.name) or \
    1.16 +        groupHasMember(request, get_page_reviewers_group(request), request.user.name) or \
    1.17          request.user.isSuperUser())
    1.18  
    1.19  def is_approved(request):
    1.20 @@ -53,7 +54,7 @@
    1.21          request.user.isSuperUser())
    1.22  
    1.23  def user_is_approved(request, username):
    1.24 -    return has_member(request, get_approved_editors_group(request), username)
    1.25 +    return groupHasMember(request, get_approved_editors_group(request), username)
    1.26  
    1.27  def is_queued_changes_page(request, pagename):
    1.28  
    1.29 @@ -206,57 +207,4 @@
    1.30  
    1.31      page.saveText(body, 0, comment=_("Added %s to the approved editors group.") % username)
    1.32  
    1.33 -# Utility classes and associated functions.
    1.34 -# NOTE: These are now present in MoinSupport which should be used in future.
    1.35 -
    1.36 -class Form:
    1.37 -
    1.38 -    """
    1.39 -    A wrapper preserving MoinMoin 1.8.x (and earlier) behaviour in a 1.9.x
    1.40 -    environment.
    1.41 -    """
    1.42 -
    1.43 -    def __init__(self, form):
    1.44 -        self.form = form
    1.45 -
    1.46 -    def get(self, name, default=None):
    1.47 -        values = self.form.getlist(name)
    1.48 -        if not values:
    1.49 -            return default
    1.50 -        else:
    1.51 -            return values
    1.52 -
    1.53 -    def __getitem__(self, name):
    1.54 -        return self.form.getlist(name)
    1.55 -
    1.56 -class ActionSupport:
    1.57 -
    1.58 -    """
    1.59 -    Work around disruptive MoinMoin changes in 1.9, and also provide useful
    1.60 -    convenience methods.
    1.61 -    """
    1.62 -
    1.63 -    def get_form(self):
    1.64 -        return get_form(self.request)
    1.65 -
    1.66 -def get_form(request):
    1.67 -
    1.68 -    "Work around disruptive MoinMoin changes in 1.9."
    1.69 -
    1.70 -    if hasattr(request, "values"):
    1.71 -        return Form(request.values)
    1.72 -    else:
    1.73 -        return request.form
    1.74 -
    1.75 -def escattr(s):
    1.76 -    return escape(s, 1)
    1.77 -
    1.78 -# More Moin 1.9 compatibility functions.
    1.79 -
    1.80 -def has_member(request, groupname, username):
    1.81 -    if hasattr(request.dicts, "has_member"):
    1.82 -        return request.dicts.has_member(groupname, username)
    1.83 -    else:
    1.84 -        return username in request.groups.get(groupname, [])
    1.85 -
    1.86  # vim: tabstop=4 expandtab shiftwidth=4
     2.1 --- a/README.txt	Tue Nov 05 23:19:02 2013 +0100
     2.2 +++ b/README.txt	Wed Nov 06 17:20:30 2013 +0100
     2.3 @@ -131,6 +131,8 @@
     2.4  Recommended Software
     2.5  --------------------
     2.6  
     2.7 +See the "Dependencies" section below for essential software.
     2.8 +
     2.9  The moinsetup tool is recommended for installation since it aims to support
    2.10  all versions of MoinMoin that are supported for use with this software.
    2.11  
    2.12 @@ -152,6 +154,17 @@
    2.13  Copyright and licence information can be found in the docs directory - see
    2.14  docs/COPYING.txt and docs/LICENCE.txt for more information.
    2.15  
    2.16 +Dependencies
    2.17 +------------
    2.18 +
    2.19 +ApproveChanges has the following basic dependencies:
    2.20 +
    2.21 +Packages                    Release Information
    2.22 +--------                    -------------------
    2.23 +
    2.24 +MoinSupport                 Tested with 0.4.2
    2.25 +                            Source: http://hgweb.boddie.org.uk/MoinSupport
    2.26 +
    2.27  New in ApproveChanges 0.2 (Changes since ApproveChanges 0.1.1)
    2.28  --------------------------------------------------------------
    2.29  
    2.30 @@ -159,6 +172,7 @@
    2.31    * Removed the special ApprovalQueueUser. This user can be removed from
    2.32      existing installations since the software no longer needs it to perform
    2.33      the queuing of unapproved contributions.
    2.34 +  * Added usage of MoinSupport for common extension functionality.
    2.35  
    2.36  New in ApproveChanges 0.1.1 (Changes since ApproveChanges 0.1)
    2.37  --------------------------------------------------------------