make is_banned fkey on user id
parent
8075c5e81f
commit
c10c00473a
|
@ -107,7 +107,7 @@ class User(Base):
|
||||||
friends_html = deferred(Column(String))
|
friends_html = deferred(Column(String))
|
||||||
enemies = deferred(Column(String))
|
enemies = deferred(Column(String))
|
||||||
enemies_html = deferred(Column(String))
|
enemies_html = deferred(Column(String))
|
||||||
is_banned = Column(Integer, default=0)
|
is_banned = Column(Integer, ForeignKey("users.id"))
|
||||||
unban_utc = Column(Integer, default=0)
|
unban_utc = Column(Integer, default=0)
|
||||||
ban_reason = deferred(Column(String))
|
ban_reason = deferred(Column(String))
|
||||||
is_muted = Column(Boolean, default=False, nullable=False)
|
is_muted = Column(Boolean, default=False, nullable=False)
|
||||||
|
|
|
@ -18,7 +18,7 @@ def award_timers(v, bot=False):
|
||||||
v.patron_utc = 0
|
v.patron_utc = 0
|
||||||
notify_if_not_bot(f"Your {patron} status has expired!")
|
notify_if_not_bot(f"Your {patron} status has expired!")
|
||||||
if v.unban_utc and v.unban_utc < now:
|
if v.unban_utc and v.unban_utc < now:
|
||||||
v.is_banned = 0
|
v.is_banned = None
|
||||||
v.unban_utc = 0
|
v.unban_utc = 0
|
||||||
v.ban_reason = None
|
v.ban_reason = None
|
||||||
notify_if_not_bot("You have been unbanned!")
|
notify_if_not_bot("You have been unbanned!")
|
||||||
|
|
|
@ -104,7 +104,7 @@ def stats(site=None):
|
||||||
"marseys": "{:,}".format(g.db.query(Marsey).filter(Marsey.submitter_id==None).count()),
|
"marseys": "{:,}".format(g.db.query(Marsey).filter(Marsey.submitter_id==None).count()),
|
||||||
"users": "{:,}".format(g.db.query(User).count()),
|
"users": "{:,}".format(g.db.query(User).count()),
|
||||||
"private users": "{:,}".format(g.db.query(User).filter_by(is_private=True).count()),
|
"private users": "{:,}".format(g.db.query(User).filter_by(is_private=True).count()),
|
||||||
"banned users": "{:,}".format(g.db.query(User).filter(User.is_banned > 0).count()),
|
"banned users": "{:,}".format(g.db.query(User).filter(User.is_banned != None).count()),
|
||||||
"verified email users": "{:,}".format(g.db.query(User).filter_by(is_activated=True).count()),
|
"verified email users": "{:,}".format(g.db.query(User).filter_by(is_activated=True).count()),
|
||||||
"coins in circulation": "{:,}".format(g.db.query(func.sum(User.coins)).scalar()),
|
"coins in circulation": "{:,}".format(g.db.query(func.sum(User.coins)).scalar()),
|
||||||
"total shop sales": "{:,}".format(g.db.query(func.sum(User.coins_spent)).scalar()),
|
"total shop sales": "{:,}".format(g.db.query(func.sum(User.coins_spent)).scalar()),
|
||||||
|
|
|
@ -319,7 +319,7 @@ def revert_actions(v:User, username):
|
||||||
user.unban_utc = 0
|
user.unban_utc = 0
|
||||||
user.ban_reason = None
|
user.ban_reason = None
|
||||||
if user.is_banned:
|
if user.is_banned:
|
||||||
user.is_banned = 0
|
user.is_banned = None
|
||||||
send_repeatable_notification(user.id, f"@{v.username} (a site admin) has unbanned you!")
|
send_repeatable_notification(user.id, f"@{v.username} (a site admin) has unbanned you!")
|
||||||
g.db.add(user)
|
g.db.add(user)
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ def revert_actions(v:User, username):
|
||||||
u.unban_utc = 0
|
u.unban_utc = 0
|
||||||
u.ban_reason = None
|
u.ban_reason = None
|
||||||
if u.is_banned:
|
if u.is_banned:
|
||||||
u.is_banned = 0
|
u.is_banned = None
|
||||||
send_repeatable_notification(u.id, f"@{v.username} (a site admin) has unbanned you!")
|
send_repeatable_notification(u.id, f"@{v.username} (a site admin) has unbanned you!")
|
||||||
g.db.add(u)
|
g.db.add(u)
|
||||||
|
|
||||||
|
@ -1135,7 +1135,7 @@ def unban_user(user_id, v):
|
||||||
if FEATURES['AWARDS'] and user.ban_reason and user.ban_reason.startswith('1-Day ban award'):
|
if FEATURES['AWARDS'] and user.ban_reason and user.ban_reason.startswith('1-Day ban award'):
|
||||||
abort(403, "You can't undo a ban award!")
|
abort(403, "You can't undo a ban award!")
|
||||||
|
|
||||||
user.is_banned = 0
|
user.is_banned = None
|
||||||
user.unban_utc = 0
|
user.unban_utc = 0
|
||||||
user.ban_reason = None
|
user.ban_reason = None
|
||||||
send_repeatable_notification(user.id, f"@{v.username} (a site admin) has unbanned you!")
|
send_repeatable_notification(user.id, f"@{v.username} (a site admin) has unbanned you!")
|
||||||
|
@ -1143,7 +1143,7 @@ def unban_user(user_id, v):
|
||||||
|
|
||||||
for x in user.alts:
|
for x in user.alts:
|
||||||
if x.is_banned: send_repeatable_notification(x.id, f"@{v.username} (a site admin) has unbanned you!")
|
if x.is_banned: send_repeatable_notification(x.id, f"@{v.username} (a site admin) has unbanned you!")
|
||||||
x.is_banned = 0
|
x.is_banned = None
|
||||||
x.unban_utc = 0
|
x.unban_utc = 0
|
||||||
x.ban_reason = None
|
x.ban_reason = None
|
||||||
g.db.add(x)
|
g.db.add(x)
|
||||||
|
|
|
@ -228,7 +228,7 @@ def award_thing(v, thing_type, id):
|
||||||
send_repeatable_notification(author.id, "Your ban duration has been reduced by 1 day!")
|
send_repeatable_notification(author.id, "Your ban duration has been reduced by 1 day!")
|
||||||
else:
|
else:
|
||||||
author.unban_utc = 0
|
author.unban_utc = 0
|
||||||
author.is_banned = 0
|
author.is_banned = None
|
||||||
author.ban_reason = None
|
author.ban_reason = None
|
||||||
send_repeatable_notification(author.id, "You have been unbanned!")
|
send_repeatable_notification(author.id, "You have been unbanned!")
|
||||||
elif kind == "grass":
|
elif kind == "grass":
|
||||||
|
|
|
@ -172,7 +172,7 @@ def user_voted_comments(v:User, username):
|
||||||
@auth_required
|
@auth_required
|
||||||
def banned(v:User):
|
def banned(v:User):
|
||||||
users = g.db.query(User).filter(
|
users = g.db.query(User).filter(
|
||||||
User.is_banned > 0,
|
User.is_banned != None,
|
||||||
User.truescore > 0,
|
User.truescore > 0,
|
||||||
or_(User.unban_utc == 0, User.unban_utc > time.time()),
|
or_(User.unban_utc == 0, User.unban_utc > time.time()),
|
||||||
not_(and_(
|
not_(and_(
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
alter table users alter column is_banned drop default;
|
||||||
|
alter table users alter column is_banned drop not null;
|
||||||
|
update users set is_banned=null where is_banned=0;
|
||||||
|
create index fki_user_is_banned_fkey on public.users using btree (is_banned);
|
|
@ -944,7 +944,7 @@ CREATE TABLE public.users (
|
||||||
bio character varying(1500),
|
bio character varying(1500),
|
||||||
bio_html character varying(10000),
|
bio_html character varying(10000),
|
||||||
referred_by integer,
|
referred_by integer,
|
||||||
is_banned integer DEFAULT 0 NOT NULL,
|
is_banned integer,
|
||||||
ban_reason character varying(256),
|
ban_reason character varying(256),
|
||||||
login_nonce integer DEFAULT 0 NOT NULL,
|
login_nonce integer DEFAULT 0 NOT NULL,
|
||||||
reserved character varying(256),
|
reserved character varying(256),
|
||||||
|
@ -2752,4 +2752,3 @@ ALTER TABLE ONLY public.comments
|
||||||
--
|
--
|
||||||
-- PostgreSQL database dump complete
|
-- PostgreSQL database dump complete
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue