changeset 184:8d574f93a6ef

replace textchas_disabled_group by ACL 'notextcha' capability we just call user.may.notextcha(u'') for now (u'' is a fake, non-existing item name). we'll need to make another change to the way this works later, as the ACL it checks right now is the CONTENT ACL (before, item/default, after). We should rather have another ACL for this later, to have a clean separation between content ACLs and view/action ACLs.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 22 Apr 2011 22:57:25 +0200
parents e54c4a0d0da1
children fa88b784cd08
files MoinMoin/config/__init__.py MoinMoin/config/default.py MoinMoin/security/textcha.py docs/admin/configure.rst
diffstat 4 files changed, 5 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/__init__.py	Fri Apr 22 21:30:51 2011 +0200
+++ b/MoinMoin/config/__init__.py	Fri Apr 22 22:57:25 2011 +0200
@@ -62,12 +62,13 @@
 
 # ACL rights that are valid in moin2
 SUPERUSER = 'superuser'
+NOTEXTCHA = 'notextcha'
 ADMIN = 'admin'
 READ = 'read'
 WRITE = 'write'
 CREATE = 'create'
 DESTROY = 'destroy'
-ACL_RIGHTS_VALID = [READ, WRITE, CREATE, ADMIN, DESTROY, SUPERUSER, ]
+ACL_RIGHTS_VALID = [READ, WRITE, CREATE, ADMIN, DESTROY, SUPERUSER, NOTEXTCHA, ]
 
 # metadata keys
 UUID = "uuid"
--- a/MoinMoin/config/default.py	Fri Apr 22 21:30:51 2011 +0200
+++ b/MoinMoin/config/default.py	Fri Apr 22 22:57:25 2011 +0200
@@ -189,7 +189,7 @@
             'interwiki_preferred',
             'item_root', 'item_license', 'mail_from',
             'item_dict_regex', 'item_group_regex',
-            'textchas_disabled_group', 'supplementation_item_names', 'html_pagetitle',
+            'supplementation_item_names', 'html_pagetitle',
             'theme_default', 'timezone_default', 'locale_default',
         )
 
@@ -309,8 +309,6 @@
   (
     ('textchas', None,
      "Spam protection setup using site-specific questions/answers, see HelpOnSpam."),
-    ('textchas_disabled_group', None,
-     "Name of a group of trusted users who do not get asked !TextCha questions. [Unicode]"),
     ('textchas_expiry_time', 600,
      "Time [s] for a !TextCha to expire."),
   )),
--- a/MoinMoin/security/textcha.py	Fri Apr 22 21:30:51 2011 +0200
+++ b/MoinMoin/security/textcha.py	Fri Apr 22 22:57:25 2011 +0200
@@ -62,15 +62,11 @@
 
     def _get_textchas(self):
         """ get textchas from the wiki config for the user's language (or default_language or en) """
-        groups = flaskg.groups
         cfg = app.cfg
         user = flaskg.user
-        disabled_group = cfg.textchas_disabled_group
         textchas = cfg.textchas
 
-        use_textchas = not (disabled_group and user.name and user.name in groups.get(disabled_group, []))
-
-        if textchas and use_textchas:
+        if textchas and not user.may.notextcha(u''):
             locales = [user.locale, cfg.locale_default, 'en', ]
             for locale in locales:
                 logging.debug(u"TextCha: trying locale == '%s'." % locale)
--- a/docs/admin/configure.rst	Fri Apr 22 21:30:51 2011 +0200
+++ b/docs/admin/configure.rst	Fri Apr 22 22:57:25 2011 +0200
@@ -584,7 +584,6 @@
 
 In your wiki config, do something like this::
 
-    textchas_disabled_group = u"TrustedEditorGroup" # members of this don't get textchas
     textchas = {
         'en': { # silly english example textchas (do not use them!)
                 u"Enter the first 9 digits of Pi.": ur"3\.14159265",
@@ -600,7 +599,7 @@
     }
 
 
-Note that TrustedEditorGroup from above example can have groups as members.
+Note that users with 'notextcha' ACL capability won't get TextChas to answer.
 
 
 Secrets