user/submission/comment: avoid queries if awards are disabled
This commit is contained in:
parent
97c9300a6f
commit
026a9efe2b
5 changed files with 9 additions and 3 deletions
|
@ -295,6 +295,7 @@ class Comment(Base):
|
|||
return data
|
||||
|
||||
def award_count(self, kind):
|
||||
if not FEATURES['AWARDS']: return 0
|
||||
return len([x for x in self.awards if x.kind == kind])
|
||||
|
||||
@property
|
||||
|
|
|
@ -336,6 +336,7 @@ class Submission(Base):
|
|||
return data
|
||||
|
||||
def award_count(self, kind):
|
||||
if not FEATURES['AWARDS']: return 0
|
||||
return len([x for x in self.awards if x.kind == kind])
|
||||
|
||||
@lazy
|
||||
|
|
|
@ -376,7 +376,7 @@ class User(Base):
|
|||
@property
|
||||
@lazy
|
||||
def received_awards(self):
|
||||
|
||||
if not FEATURES['AWARDS']: return []
|
||||
awards = {}
|
||||
|
||||
posts_idlist = [x[0] for x in g.db.query(Submission.id).filter_by(author_id=self.id).all()]
|
||||
|
|
|
@ -75,6 +75,10 @@ VIDEO_FORMATS = ['mp4','webm','mov','avi','mkv','flv','m4v','3gp']
|
|||
AUDIO_FORMATS = ['mp3','wav','ogg','aac','m4a','flac']
|
||||
NO_TITLE_EXTENSIONS = IMAGE_FORMATS + VIDEO_FORMATS + AUDIO_FORMATS
|
||||
|
||||
FEATURES = {
|
||||
"AWARDS": False,
|
||||
}
|
||||
|
||||
PERMS = {
|
||||
"DEBUG_LOGIN_TO_OTHERS": 3,
|
||||
}
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
{{u.enemies_html | safe}}
|
||||
{% endif %}
|
||||
|
||||
{% if u.received_awards %}
|
||||
{% if FEATURES['AWARDS'] and u.received_awards %}
|
||||
<div class="text-white rounded p-2 mb-3" style="background-color: rgba(50, 50, 50, 0.6); width: 30%;">
|
||||
<p class="text-uppercase my-0" style="font-weight: bold; font-size: 12px;">Awards received</p>
|
||||
{% for a in u.received_awards %}
|
||||
|
@ -379,7 +379,7 @@
|
|||
{{u.enemies_html | safe}}
|
||||
{% endif %}
|
||||
|
||||
{% if u.received_awards %}
|
||||
{% if FEATURES['AWARDS'] and u.received_awards %}
|
||||
<div class="text-white rounded p-2 my-3 text-center" style="background-color: rgba(50, 50, 50, 0.6);">
|
||||
<p class="text-uppercase my-0" style="font-weight: bold; font-size: 12px;">Awards received</p>
|
||||
{% for a in u.received_awards %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue