rename truecoins -> truescore
This commit is contained in:
parent
fb65cf0416
commit
1dfbe754bc
8 changed files with 27 additions and 28 deletions
|
@ -96,7 +96,7 @@ class User(Base):
|
||||||
login_nonce = Column(Integer, default=0, nullable=False)
|
login_nonce = Column(Integer, default=0, nullable=False)
|
||||||
reserved = deferred(Column(String))
|
reserved = deferred(Column(String))
|
||||||
coins = Column(Integer, default=0, nullable=False)
|
coins = Column(Integer, default=0, nullable=False)
|
||||||
truecoins = Column(Integer, default=0, nullable=False)
|
truescore = Column(Integer, default=0, nullable=False)
|
||||||
procoins = Column(Integer, default=0, nullable=False)
|
procoins = Column(Integer, default=0, nullable=False)
|
||||||
mfa_secret = deferred(Column(String))
|
mfa_secret = deferred(Column(String))
|
||||||
is_private = Column(Boolean, default=False, nullable=False)
|
is_private = Column(Boolean, default=False, nullable=False)
|
||||||
|
@ -145,7 +145,6 @@ class User(Base):
|
||||||
notes = relationship("UserNote", foreign_keys='UserNote.reference_user', back_populates="user")
|
notes = relationship("UserNote", foreign_keys='UserNote.reference_user', back_populates="user")
|
||||||
|
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
|
|
||||||
if "password" in kwargs:
|
if "password" in kwargs:
|
||||||
kwargs["passhash"] = self.hash_password(kwargs["password"])
|
kwargs["passhash"] = self.hash_password(kwargs["password"])
|
||||||
kwargs.pop("password")
|
kwargs.pop("password")
|
||||||
|
@ -157,16 +156,22 @@ class User(Base):
|
||||||
|
|
||||||
def can_manage_reports(self):
|
def can_manage_reports(self):
|
||||||
return self.admin_level > 1
|
return self.admin_level > 1
|
||||||
|
|
||||||
|
@property
|
||||||
|
def age_days(self):
|
||||||
|
return (datetime.now() - datetime.fromtimestamp(self.created_utc)).days
|
||||||
|
|
||||||
|
@property
|
||||||
def should_comments_be_filtered(self):
|
def should_comments_be_filtered(self):
|
||||||
if self.admin_level > 0:
|
if self.admin_level > 0:
|
||||||
return False
|
return False
|
||||||
site_settings = app.config['SETTINGS']
|
site_settings = app.config['SETTINGS']
|
||||||
minComments = site_settings.get('FilterCommentsMinComments', 0)
|
min_comments = site_settings.get('FilterCommentsMinComments', 0)
|
||||||
minKarma = site_settings.get('FilterCommentsMinKarma', 0)
|
min_karma = site_settings.get('FilterCommentsMinKarma', 0)
|
||||||
minAge = site_settings.get('FilterCommentsMinAgeDays', 0)
|
min_age = site_settings.get('FilterCommentsMinAgeDays', 0)
|
||||||
accountAgeDays = (datetime.now() - datetime.fromtimestamp(self.created_utc)).days
|
return self.comment_count < min_comments \
|
||||||
return self.comment_count < minComments or accountAgeDays < minAge or self.truecoins < minKarma
|
or self.age_days < min_age \
|
||||||
|
or self.truescore < min_karma
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
def mods(self, sub):
|
def mods(self, sub):
|
||||||
|
@ -239,7 +244,7 @@ class User(Base):
|
||||||
@property
|
@property
|
||||||
@lazy
|
@lazy
|
||||||
def paid_dues(self):
|
def paid_dues(self):
|
||||||
return not self.shadowbanned and not (self.is_banned and not self.unban_utc) and (self.admin_level or self.club_allowed or (self.club_allowed != False and self.truecoins > dues))
|
return not self.shadowbanned and not (self.is_banned and not self.unban_utc) and (self.admin_level or self.club_allowed or (self.club_allowed != False and self.truescore > dues))
|
||||||
|
|
||||||
@lazy
|
@lazy
|
||||||
def any_block_exists(self, other):
|
def any_block_exists(self, other):
|
||||||
|
@ -282,7 +287,6 @@ class User(Base):
|
||||||
|
|
||||||
@cache.memoize(timeout=86400)
|
@cache.memoize(timeout=86400)
|
||||||
def userpagelisting(self, site=None, v=None, page=1, sort="new", t="all"):
|
def userpagelisting(self, site=None, v=None, page=1, sort="new", t="all"):
|
||||||
|
|
||||||
if self.shadowbanned and not (v and (v.admin_level > 1 or v.id == self.id)): return []
|
if self.shadowbanned and not (v and (v.admin_level > 1 or v.id == self.id)): return []
|
||||||
|
|
||||||
posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False)
|
posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False)
|
||||||
|
|
|
@ -608,7 +608,7 @@ def loggedin_list(v):
|
||||||
ids = [x for x, val in cache.get(f'{SITE}_loggedin').items() \
|
ids = [x for x, val in cache.get(f'{SITE}_loggedin').items() \
|
||||||
if (time.time() - val) < LOGGEDIN_ACTIVE_TIME]
|
if (time.time() - val) < LOGGEDIN_ACTIVE_TIME]
|
||||||
users = g.db.query(User).filter(User.id.in_(ids)) \
|
users = g.db.query(User).filter(User.id.in_(ids)) \
|
||||||
.order_by(User.admin_level.desc(), User.truecoins.desc()).all()
|
.order_by(User.admin_level.desc(), User.truescore.desc()).all()
|
||||||
return render_template("admin/loggedin.html", v=v, users=users)
|
return render_template("admin/loggedin.html", v=v, users=users)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ def api_comment(v):
|
||||||
|
|
||||||
abort(403, "Too much spam!")
|
abort(403, "Too much spam!")
|
||||||
|
|
||||||
is_filtered = v.should_comments_be_filtered()
|
is_filtered = v.should_comments_be_filtered
|
||||||
|
|
||||||
c = Comment(author_id=v.id,
|
c = Comment(author_id=v.id,
|
||||||
parent_submission=parent_post.id,
|
parent_submission=parent_post.id,
|
||||||
|
|
|
@ -202,9 +202,9 @@ def patrons(v):
|
||||||
@auth_desired
|
@auth_desired
|
||||||
def admins(v):
|
def admins(v):
|
||||||
if v and v.admin_level > 2:
|
if v and v.admin_level > 2:
|
||||||
admins = g.db.query(User).filter(User.admin_level>1).order_by(User.truecoins.desc()).all()
|
admins = g.db.query(User).filter(User.admin_level>1).order_by(User.truescore.desc()).all()
|
||||||
admins += g.db.query(User).filter(User.admin_level==1).order_by(User.truecoins.desc()).all()
|
admins += g.db.query(User).filter(User.admin_level==1).order_by(User.truescore.desc()).all()
|
||||||
else: admins = g.db.query(User).filter(User.admin_level>0).order_by(User.truecoins.desc()).all()
|
else: admins = g.db.query(User).filter(User.admin_level>0).order_by(User.truescore.desc()).all()
|
||||||
return render_template("admins.html", v=v, admins=admins)
|
return render_template("admins.html", v=v, admins=admins)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -370,7 +370,7 @@ def leaderboard(v:User):
|
||||||
comments = SimpleLeaderboard(v, LeaderboardMeta("Comments", "comment count", "comments", "Comments", "comments"), g.db, users, User.comment_count)
|
comments = SimpleLeaderboard(v, LeaderboardMeta("Comments", "comment count", "comments", "Comments", "comments"), g.db, users, User.comment_count)
|
||||||
received_awards = SimpleLeaderboard(v, LeaderboardMeta("Awards", "received awards", "awards", "Awards", None), g.db, users, User.received_award_count)
|
received_awards = SimpleLeaderboard(v, LeaderboardMeta("Awards", "received awards", "awards", "Awards", None), g.db, users, User.received_award_count)
|
||||||
coins_spent = SimpleLeaderboard(v, LeaderboardMeta("Spent in shop", "coins spent in shop", "spent", "Coins", None), g.db, users, User.coins_spent)
|
coins_spent = SimpleLeaderboard(v, LeaderboardMeta("Spent in shop", "coins spent in shop", "spent", "Coins", None), g.db, users, User.coins_spent)
|
||||||
truescore = SimpleLeaderboard(v, LeaderboardMeta("Truescore", "truescore", "truescore", "Truescore", None), g.db, users, User.truecoins)
|
truescore = SimpleLeaderboard(v, LeaderboardMeta("Truescore", "truescore", "truescore", "Truescore", None), g.db, users, User.truescore)
|
||||||
badges = BadgeMarseyLeaderboard(v, LeaderboardMeta("Badges", "badges", "badges", "Badges", None), g.db, Badge.user_id)
|
badges = BadgeMarseyLeaderboard(v, LeaderboardMeta("Badges", "badges", "badges", "Badges", None), g.db, Badge.user_id)
|
||||||
blocks = UserBlockLeaderboard(v, LeaderboardMeta("Blocked", "most blocked", "blocked", "Blocked By", "blockers"), g.db, UserBlock.target_id)
|
blocks = UserBlockLeaderboard(v, LeaderboardMeta("Blocked", "most blocked", "blocked", "Blocked By", "blockers"), g.db, UserBlock.target_id)
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ def api_vote_post(post_id, new, v):
|
||||||
# remove the old score data
|
# remove the old score data
|
||||||
if points_matter:
|
if points_matter:
|
||||||
post.author.coins -= vote.vote_type
|
post.author.coins -= vote.vote_type
|
||||||
post.author.truecoins -= vote.vote_type
|
post.author.truescore -= vote.vote_type
|
||||||
# we'll be saving later anyway, so don't bother doing so here
|
# we'll be saving later anyway, so don't bother doing so here
|
||||||
else:
|
else:
|
||||||
# create new vote data
|
# create new vote data
|
||||||
|
@ -102,7 +102,7 @@ def api_vote_post(post_id, new, v):
|
||||||
# add relevant points
|
# add relevant points
|
||||||
if points_matter:
|
if points_matter:
|
||||||
post.author.coins += vote.vote_type
|
post.author.coins += vote.vote_type
|
||||||
post.author.truecoins += vote.vote_type
|
post.author.truescore += vote.vote_type
|
||||||
|
|
||||||
# database it up
|
# database it up
|
||||||
g.db.add(post.author)
|
g.db.add(post.author)
|
||||||
|
@ -148,7 +148,7 @@ def api_vote_comment(comment_id, new, v):
|
||||||
# remove the old score data
|
# remove the old score data
|
||||||
if points_matter:
|
if points_matter:
|
||||||
comment.author.coins -= vote.vote_type
|
comment.author.coins -= vote.vote_type
|
||||||
comment.author.truecoins -= vote.vote_type
|
comment.author.truescore -= vote.vote_type
|
||||||
# we'll be saving later anyway, so don't bother doing so here
|
# we'll be saving later anyway, so don't bother doing so here
|
||||||
else:
|
else:
|
||||||
# create new vote data
|
# create new vote data
|
||||||
|
@ -170,7 +170,7 @@ def api_vote_comment(comment_id, new, v):
|
||||||
# add relevant points
|
# add relevant points
|
||||||
if points_matter:
|
if points_matter:
|
||||||
comment.author.coins += vote.vote_type
|
comment.author.coins += vote.vote_type
|
||||||
comment.author.truecoins += vote.vote_type
|
comment.author.truescore += vote.vote_type
|
||||||
|
|
||||||
# database it up
|
# database it up
|
||||||
g.db.add(comment.author)
|
g.db.add(comment.author)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{loop.index}}</td>
|
<td>{{loop.index}}</td>
|
||||||
<td><a style="color:#{{user.name_color}}" href="/@{{user.username}}"><img loading="lazy" src="{{user.profile_url}}" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.name_color}}"{% endif %}>{{user.username}}</span></a></td>
|
<td><a style="color:#{{user.name_color}}" href="/@{{user.username}}"><img loading="lazy" src="{{user.profile_url}}" class="pp20"><span {% if user.patron %}class="patron" style="background-color:#{{user.name_color}}"{% endif %}>{{user.username}}</span></a></td>
|
||||||
<td>{{user.truecoins}}</td>
|
<td>{{user.truescore}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
<p><a href="{{thing.permalink}}">{{thing.permalink}}</a></p>
|
<p><a href="{{thing.permalink}}">{{thing.permalink}}</a></p>
|
||||||
<p><b>Author:</b> <a href="{{thing.author.url}}">@{{thing.author.username}}</a></p>
|
<p><b>Author:</b> <a href="{{thing.author.url}}">@{{thing.author.username}}</a></p>
|
||||||
<p><b>Author Created At:</b> {{thing.author.created_datetime}}</p>
|
<p><b>Author Created At:</b> {{thing.author.created_datetime}}</p>
|
||||||
<p><b>Author Truescore:</b> {{thing.author.truecoins}}</p>
|
<p><b>Author Truescore:</b> {{thing.author.truescore}}</p>
|
||||||
<p><b>Upvotes: </b>{{ups | length}}</p>
|
<p><b>Upvotes: </b>{{ups | length}}</p>
|
||||||
<p><b>Downvotes: </b>{{downs | length}}</p>
|
<p><b>Downvotes: </b>{{downs | length}}</p>
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
{% for vote in ups %}
|
{% for vote in ups %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a style="color:#{{vote.user.namecolor}};font-weight:bold" href="/@{{vote.user.username}}"><img loading="lazy" src="{{vote.user.profile_url}}" class="pp20"><span {% if vote.user.patron %}class="patron" style="background-color:#{{vote.user.namecolor}}"{% endif %}>{{vote.user.username}}</span></a></td>
|
<td><a style="color:#{{vote.user.namecolor}};font-weight:bold" href="/@{{vote.user.username}}"><img loading="lazy" src="{{vote.user.profile_url}}" class="pp20"><span {% if vote.user.patron %}class="patron" style="background-color:#{{vote.user.namecolor}}"{% endif %}>{{vote.user.username}}</span></a></td>
|
||||||
<td>{{vote.user.truecoins}}</td>
|
<td>{{vote.user.truescore}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
@ -44,14 +44,9 @@
|
||||||
{% for vote in downs %}
|
{% for vote in downs %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a style="color:#{{vote.user.namecolor}};font-weight:bold" href="/@{{vote.user.username}}"><img loading="lazy" src="{{vote.user.profile_url}}" class="pp20"><span {% if vote.user.patron %}class="patron" style="background-color:#{{vote.user.namecolor}}"{% endif %}>{{vote.user.username}}</span></a></td>
|
<td><a style="color:#{{vote.user.namecolor}};font-weight:bold" href="/@{{vote.user.username}}"><img loading="lazy" src="{{vote.user.profile_url}}" class="pp20"><span {% if vote.user.patron %}class="patron" style="background-color:#{{vote.user.namecolor}}"{% endif %}>{{vote.user.username}}</span></a></td>
|
||||||
<td>{{vote.user.truecoins}}</td>
|
<td>{{vote.user.truescore}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue