From 0bb4605a533dcb8c3a232200cdfdba191a7847a9 Mon Sep 17 00:00:00 2001 From: Andre D Date: Fri, 22 Feb 2013 13:23:15 -0500 Subject: [PATCH] wiki: Use global karma for frontpage wiki. --- r2/r2/lib/validator/wiki.py | 9 +++++++-- r2/r2/models/subreddit.py | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/r2/r2/lib/validator/wiki.py b/r2/r2/lib/validator/wiki.py index 736d8ac20..f8814c7aa 100644 --- a/r2/r2/lib/validator/wiki.py +++ b/r2/r2/lib/validator/wiki.py @@ -112,8 +112,13 @@ def may_revise(sr, user, page=None): # If the user can not submit to the subreddit # They should not be able to contribute return False - - karma = max(user.karma('link', sr), user.karma('comment', sr)) + + # Use global karma for the frontpage wiki + karma_sr = sr if sr.wiki_use_subreddit_karma else None + + # Use link or comment karma, whichever is greater + karma = max(user.karma('link', karma_sr), user.karma('comment', karma_sr)) + if karma < (sr.wiki_edit_karma or 0): # If the user has too few karma, they should not contribute return False diff --git a/r2/r2/models/subreddit.py b/r2/r2/models/subreddit.py index 0445627c2..3d6e5492f 100644 --- a/r2/r2/models/subreddit.py +++ b/r2/r2/models/subreddit.py @@ -303,6 +303,10 @@ class Subreddit(Thing, Printable): def accounts_active(self): return self.get_accounts_active()[0] + @property + def wiki_use_subreddit_karma(self): + return True + def get_accounts_active(self): fuzzed = False count = AccountsActiveBySR.get_count(self) @@ -1117,6 +1121,10 @@ class DefaultSR(_DefaultSR): except NotFound: self._base = None + @property + def wiki_use_subreddit_karma(self): + return False + @property def _should_wiki(self): return True