Hide votes for posts and comments under 24 hours old

This commit is contained in:
Inire 2022-10-27 21:40:30 +11:00 committed by Ben Rog-Wilhelm
parent 120e299f46
commit 4e2047624b
7 changed files with 53 additions and 17 deletions

View file

@ -6,7 +6,7 @@ from urllib.parse import urlparse
from flask import render_template
from sqlalchemy import *
from sqlalchemy.orm import relationship, deferred
from files.__main__ import Base
from files.__main__ import Base, app
from files.helpers.const import *
from files.helpers.lazy import lazy
from files.helpers.assetcache import assetcache_path
@ -84,6 +84,13 @@ class Submission(Base):
def __repr__(self):
return f"<Submission(id={self.id})>"
@property
@lazy
def should_hide_score(self):
submission_age_seconds = int(time.time()) - self.created_utc
submission_age_hours = submission_age_seconds / (60*60)
return submission_age_hours < app.config['SCORE_HIDING_TIME_HOURS']
@property
@lazy
def controversial(self):