award feature: use feature flag in more places
This commit is contained in:
parent
a863b9c957
commit
f4445fd58e
4 changed files with 15 additions and 12 deletions
|
@ -224,6 +224,7 @@ class User(Base):
|
|||
@property
|
||||
@lazy
|
||||
def user_awards(self):
|
||||
if not FEATURES['AWARDS']: return []
|
||||
return_value = list(AWARDS_ENABLED.values())
|
||||
user_awards = g.db.query(AwardRelationship).filter_by(user_id=self.id)
|
||||
for val in return_value: val['owned'] = user_awards.filter_by(kind=val['kind'], submission_id=None, comment_id=None).count()
|
||||
|
|
|
@ -85,14 +85,18 @@ PERMS = {
|
|||
|
||||
AWARDS = {}
|
||||
|
||||
AWARDS_ENABLED = deepcopy(AWARDS)
|
||||
for k, val in AWARDS.items():
|
||||
if val['description'] == '???': AWARDS_ENABLED.pop(k)
|
||||
if FEATURES['AWARDS']:
|
||||
AWARDS_ENABLED = deepcopy(AWARDS)
|
||||
for k, val in AWARDS.items():
|
||||
if val['description'] == '???': AWARDS_ENABLED.pop(k)
|
||||
|
||||
AWARDS_JL2_PRINTABLE = {}
|
||||
for k, val in AWARDS_ENABLED.items():
|
||||
if val['price'] == 300: AWARDS_JL2_PRINTABLE[k] = val
|
||||
else:
|
||||
AWARDS_ENABLED = {}
|
||||
AWARDS_JL2_PRINTABLE = {}
|
||||
|
||||
AWARDS_JL2_PRINTABLE = {}
|
||||
for k, val in AWARDS_ENABLED.items():
|
||||
if val['price'] == 300: AWARDS_JL2_PRINTABLE[k] = val
|
||||
|
||||
NOTIFIED_USERS = {
|
||||
# format: 'substring' ↦ User ID to notify
|
||||
|
|
|
@ -14,7 +14,8 @@ from .static import *
|
|||
from .users import *
|
||||
from .votes import *
|
||||
from .feeds import *
|
||||
from .awards import *
|
||||
if FEATURES['AWARDS']:
|
||||
from .awards import * # disable entirely pending possible future use of coins
|
||||
from .volunteer import *
|
||||
if app.debug:
|
||||
from .dev import *
|
||||
|
|
|
@ -1225,9 +1225,8 @@ def sticky_post(post_id, v):
|
|||
@limiter.exempt
|
||||
@admin_level_required(2)
|
||||
def unsticky_post(post_id, v):
|
||||
|
||||
post = g.db.query(Submission).filter_by(id=post_id).one_or_none()
|
||||
if post and post.stickied:
|
||||
if FEATURES['AWARDS'] and post and post.stickied:
|
||||
if post.stickied.endswith('(pin award)'): abort(403, "Can't unpin award pins!")
|
||||
|
||||
post.stickied = None
|
||||
|
@ -1252,7 +1251,6 @@ def unsticky_post(post_id, v):
|
|||
@limiter.exempt
|
||||
@admin_level_required(2)
|
||||
def sticky_comment(cid, v):
|
||||
|
||||
comment = get_comment(cid, v=v)
|
||||
|
||||
if not comment.is_pinned:
|
||||
|
@ -1278,10 +1276,9 @@ def sticky_comment(cid, v):
|
|||
@limiter.exempt
|
||||
@admin_level_required(2)
|
||||
def unsticky_comment(cid, v):
|
||||
|
||||
comment = get_comment(cid, v=v)
|
||||
|
||||
if comment.is_pinned:
|
||||
if FEATURES['AWARDS'] and comment.is_pinned:
|
||||
if comment.is_pinned.endswith("(pin award)"): abort(403, "Can't unpin award pins!")
|
||||
|
||||
comment.is_pinned = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue