From 13e575a6b5dfc689853b044c78e547fcc91f3e0f Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 19 Feb 2022 23:42:55 +0200 Subject: [PATCH] fgh --- files/__main__.py | 2 -- files/routes/admin.py | 16 +++++++--------- files/routes/awards.py | 8 ++++---- files/routes/front.py | 2 +- files/routes/users.py | 2 +- seed-db.sql | 5 +++-- 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/files/__main__.py b/files/__main__.py index 40d009216..9ab3c9521 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -95,8 +95,6 @@ def before_request(): g.db = db_session() - g.timestamp = int(time.time()) - ua = request.headers.get("User-Agent","").lower() if '; wv) ' in ua: g.webview = True diff --git a/files/routes/admin.py b/files/routes/admin.py index de8ff0fd2..6c3131d46 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -792,11 +792,9 @@ def admin_removed_comments(v): def agendaposter(user_id, v): user = g.db.query(User).filter_by(id=user_id).one_or_none() - expiry = request.values.get("days", 0) - if expiry: - expiry = float(expiry) - expiry = g.timestamp + expiry*60*60*24 - else: expiry = g.timestamp + 2629746 + days = request.values.get("days", 30) + expiry = float(days) + expiry = int(time.time() + expiry*60*60*24) user.agendaposter = expiry g.db.add(user) @@ -806,7 +804,7 @@ def agendaposter(user_id, v): alt.agendaposter = expiry g.db.add(alt) - note = f"for {request.values.get('days')} days" if expiry else "never expires" + note = f"for {days} days" ma = ModAction( kind="agendaposter", @@ -816,8 +814,8 @@ def agendaposter(user_id, v): ) g.db.add(ma) - if not user.has_badge(26): - badge = Badge(user_id=user.id, badge_id=26) + if not user.has_badge(28): + badge = Badge(user_id=user.id, badge_id=28) g.db.add(badge) g.db.flush() send_notification(user.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") @@ -851,7 +849,7 @@ def unagendaposter(user_id, v): g.db.add(ma) - badge = user.has_badge(26) + badge = user.has_badge(28) if badge: g.db.delete(badge) send_repeatable_notification(user.id, "You have been unmarked by an admin as an agendaposter.") diff --git a/files/routes/awards.py b/files/routes/awards.py index 5562faeb5..e611b0680 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -285,8 +285,8 @@ def award_post(pid, v): if author.agendaposter and time.time() < author.agendaposter: author.agendaposter += 86400 else: author.agendaposter = int(time.time()) + 86400 - if not author.has_badge(26): - badge = Badge(user_id=author.id, badge_id=26) + if not author.has_badge(28): + badge = Badge(user_id=author.id, badge_id=28) g.db.add(badge) g.db.flush() send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") @@ -515,8 +515,8 @@ def award_comment(cid, v): if author.agendaposter and time.time() < author.agendaposter: author.agendaposter += 86400 else: author.agendaposter = int(time.time()) + 86400 - if not author.has_badge(26): - badge = Badge(user_id=author.id, badge_id=26) + if not author.has_badge(28): + badge = Badge(user_id=author.id, badge_id=28) g.db.add(badge) g.db.flush() send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") diff --git a/files/routes/front.py b/files/routes/front.py index 43a76bdc4..58e2abbbb 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -206,7 +206,7 @@ def front_all(v, sub=None): v.agendaposter = 0 send_repeatable_notification(v.id, "Your chud theme has expired!") g.db.add(v) - badge = v.has_badge(26) + badge = v.has_badge(28) if badge: g.db.delete(badge) g.db.commit() diff --git a/files/routes/users.py b/files/routes/users.py index 21acf7af1..13e0983b2 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -701,7 +701,7 @@ def u_username(username, v=None): if v and u.id != v.id and u.patron: view = g.db.query(ViewerRelationship).filter_by(viewer_id=v.id, user_id=u.id).one_or_none() - if view: view.last_view_utc = g.timestamp + if view: view.last_view_utc = int(time.time()) else: view = ViewerRelationship(viewer_id=v.id, user_id=u.id) g.db.add(view) diff --git a/seed-db.sql b/seed-db.sql index e63a31f3d..1c5cc1a77 100644 --- a/seed-db.sql +++ b/seed-db.sql @@ -53,9 +53,10 @@ INSERT INTO public.badge_defs VALUES (22,'Renthog','Contributed at least $10'), (23,'Landchad','Contributed at least $20'), (24,'Terminally online turboautist','Contributed at least $50'), -(25,'Rich Bich','Contributed at least $100'), -(26,'Chud','Forced to use the chud theme'), +(25,'Footpig','Contributed at least $100'), +(26,'Rich Bich','Contributed at least $250'), (27,'Lolcow','Beautiful and valid milk provider'), +(28,'Chud','Forced to use the chud theme'), (60,'Unironically Retarded','Demonstrated a wholesale inability to read the room'), (61,'Lab Rat','Helped test features in development'), (62,'Master Baiter','For outstanding achievement in the field of catching fish'),