account: Correct can_wiki permissions for trac.

Trac requires None to map to False, where as in new wiki it maps to True
This commit is contained in:
Andre D
2012-10-02 06:04:59 -05:00
committed by Neil Williams
parent 0a5a156760
commit 6a92163e86
3 changed files with 7 additions and 4 deletions

View File

@@ -1228,7 +1228,8 @@ class FormsController(RedditController):
returns their user name"""
c.response_content_type = 'text/plain'
if c.user_is_loggedin:
perm = str(c.user.can_wiki())
# Change cookie based on can_wiki trac permissions
perm = str(c.user.can_wiki(default=False))
c.response.content = c.user.name + "," + perm
else:
c.response.content = ''

View File

@@ -88,7 +88,7 @@ def may_revise(sr, user, page=None):
# Users who are not allowed to view the page may not contribute to the page
return False
if not user.can_wiki():
if not user.can_wiki(default=True):
# Global wiki contributute ban
return False

View File

@@ -182,9 +182,11 @@ class Account(Thing):
karma = self.link_karma
return max(karma, 1) if karma > -1000 else karma
def can_wiki(self):
def can_wiki(self, default=False):
if self.wiki_override is None:
return self.link_karma > 100 or self.comment_karma > 100
if not default:
return self.link_karma > 100 or self.comment_karma > 100
return default
return self.wiki_override
def all_karmas(self):