sohini2689 / gaewiki

Automatically exported from code.google.com/p/gaewiki
0 stars 0 forks source link

Semi-protection: Allow editing to all logined user #59

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
diff --git a/gaewiki/access.py b/gaewiki/access.py
--- a/gaewiki/access.py
+++ b/gaewiki/access.py
@@ -36,16 +36,18 @@ def can_edit_page(title, user=None, is_a
         if parent is None:
             return False

     if settings.get('open-editing') == 'yes':
         if not model.WikiContent.get_by_title(title).is_locked():
             return not is_page_blacklisted(title)
     if user is None:
         return False
+    if settings.get('open-editing') == 'login':
+        return not is_page_blacklisted(title)
     if user.email() in settings.get('editors', []):
         return not is_page_blacklisted(title)
     return False

 def can_read_page(title, user, is_admin):
     """Returns True if the user is allowed to read the specified page.

@@ -64,24 +66,28 @@ def can_read_page(title, user, is_admin)
     page = model.WikiContent.get_by_title(title)
     options = util.parse_page(page.body or '')

     is_open_wiki = settings.get('open-reading', 'yes') == 'yes'
     if is_open_wiki:
         if options.get('private') != 'yes':
             return True
         return user and (user.email() in options.get('readers', []) or user.email() in options.get('editors', []))
+    elif settings.get('open-reading') == 'login':
+        return options.get('public') == 'yes' or user
     else:
         return options.get('public') == 'yes'

 def can_see_most_pages(user, is_admin):
     if is_admin:
         return True
     if settings.get('open-reading', 'yes') == 'yes':
         return True
     if user is None:
         return False
+    if settings.get('open-reading') == 'login':
+        return True
     if user.email() in settings.get('readers', []):
         return True
     if user.email() in settings.get('editors', []):
         return True
     return False

Original issue reported on code.google.com by h.rayflood on 1 Dec 2011 at 1:00

GoogleCodeExporter commented 8 years ago

Original comment by h.rayflood on 4 Dec 2011 at 1:01

GoogleCodeExporter commented 8 years ago
This issue was closed by revision ef36c155ea8b.

Original comment by justin.forest on 4 Dec 2011 at 2:22