remotes/1693045480750635534/spooky-22
Aevann1 2021-10-25 20:08:03 +02:00
parent 4d2f8acef8
commit aeac766df3
15 changed files with 132 additions and 40 deletions

View File

@ -21,12 +21,7 @@ class ModAction(Base):
target_post = relationship("Submission", viewonly=True)
def __init__(self, *args, **kwargs):
if "created_utc" not in kwargs:
kwargs["created_utc"] = int(time.time())
if "note" in kwargs:
kwargs["_note"]=kwargs["note"]
if "created_utc" not in kwargs: kwargs["created_utc"] = int(time.time())
super().__init__(*args, **kwargs)
def __repr__(self):
@ -113,6 +108,47 @@ class ModAction(Base):
ACTIONTYPES={
"check": {
"str": "gave {self.target_link} a checkmark",
"icon": "fa-user",
"color": "bg-muted",
},
"uncheck": {
"str": "removed checkmark from {self.target_link}",
"icon": "fa-user-slash",
"color": "bg-muted",
},
"ban_domain": {
"str": "banned a domain",
"icon": "fa-globe",
"color": "bg-danger",
},
"unban_domain": {
"str": "unbanned a domain",
"icon": "fa-globe",
"color": "bg-muted",
},
"approve_app": {
"str": "approved an application by {self.target_link}",
"icon": "fa-robot",
"color": "bg-muted",
},
"revoke_app": {
"str": "revoked an application by {self.target_link}",
"icon": "fa-robot",
"color": "bg-danger",
},
"reject_app": {
"str": "rejected an application request by {self.target_link}",
"icon": "fa-robot",
"color": "bg-danger",
},
"change_rules": {
"str": "changed the <a href='/rules'>rules</a>",
"icon": "fa-balance-scale",
"color": "bg-muted",
},
"ban_user":{
"str":'banned user {self.target_link}',
"icon":"fa-user-slash",

View File

@ -55,7 +55,7 @@ def check_ban_evade(v):
kind="ban_post",
user_id=AUTOJANNY_ACCOUNT,
target_submission_id=post.id,
note="permaban evasion"
_note="permaban evasion"
)
g.db.add(ma)
@ -72,7 +72,7 @@ def check_ban_evade(v):
kind="ban_comment",
user_id=AUTOJANNY_ACCOUNT,
target_comment_id=comment.id,
note="ban evasion"
_note="ban evasion"
)
g.db.add(ma)
except: pass

View File

@ -191,8 +191,7 @@ def monthly(v):
def get_rules(v):
try:
with open(f'./{SITE_NAME} rules.html', 'r') as f:
rules = f.read()
with open(f'./{SITE_NAME} rules.html', 'r') as f: rules = f.read()
except Exception:
rules = None
@ -207,11 +206,17 @@ def post_rules(v):
text = request.values.get('rules', '').strip()
with open(f'./{SITE_NAME} rules.html', 'w+') as f:
f.write(text)
with open(f'./{SITE_NAME} rules.html', 'w+') as f: f.write(text)
with open(f'./{SITE_NAME} rules.html', 'r') as f:
rules = f.read()
with open(f'./{SITE_NAME} rules.html', 'r') as f: rules = f.read()
ma = ModAction(
kind="change_rules",
user_id=v.id,
)
g.db.add(ma)
g.db.commit()
return render_template('admin/rules.html', v=v, rules=rules)
@ -671,6 +676,14 @@ def verify(user_id, v):
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
user.verified = "Verified"
g.db.add(user)
ma = ModAction(
kind="check",
user_id=v.id,
target_user_id=user.id,
)
g.db.add(ma)
g.db.commit()
return {"message": "User verfied!"}
@ -682,6 +695,14 @@ def unverify(user_id, v):
user = g.db.query(User).options(lazyload('*')).filter_by(id=user_id).first()
user.verified = None
g.db.add(user)
ma = ModAction(
kind="uncheck",
user_id=v.id,
target_user_id=user.id,
)
g.db.add(ma)
g.db.commit()
return {"message": "User unverified!"}
@ -713,7 +734,7 @@ def admin_title_change(user_id, v):
kind=kind,
user_id=v.id,
target_user_id=user.id,
note=f'"{new_name}"'
_note=f'"{new_name}"'
)
g.db.add(ma)
g.db.commit()
@ -770,7 +791,7 @@ def ban_user(user_id, v):
kind="ban_user",
user_id=v.id,
target_user_id=user.id,
note=f'reason: "{reason}", duration: {duration}'
_note=f'reason: "{reason}", duration: {duration}'
)
g.db.add(ma)
@ -1065,10 +1086,24 @@ def admin_toggle_ban_domain(v):
reason=request.values.get("reason", "").strip()
d = g.db.query(BannedDomain).options(lazyload('*')).filter_by(domain=domain).first()
if d: g.db.delete(d)
if d:
g.db.delete(d)
ma = ModAction(
kind="unban_domain",
user_id=v.id,
_note=domain
)
g.db.add(ma)
else:
d = BannedDomain(domain=domain, reason=reason)
g.db.add(d)
ma = ModAction(
kind="ban_domain",
user_id=v.id,
_note=f'{domain}, reason: {reason}'
)
g.db.add(ma)
g.db.commit()

View File

@ -242,7 +242,7 @@ def api_comment(v):
user_id=AUTOJANNY_ACCOUNT,
target_comment_id=comment.id,
kind="ban_comment",
note="spam"
_note="spam"
)
g.db.add(ma)

View File

@ -122,6 +122,13 @@ def admin_app_approve(v, aid):
send_notification(user.id, f"Your application `{app.app_name}` has been approved. Here's your access token: `{access_token}`\nPlease check the guide [here](/api) if you don't know what to do next.")
ma = ModAction(
kind="approve_app",
user_id=v.id,
target_user_id=user.id,
)
g.db.add(ma)
g.db.commit()
return {"message": f"{app.app_name} approved"}
@ -141,6 +148,13 @@ def admin_app_revoke(v, aid):
g.db.delete(app)
ma = ModAction(
kind="revoke_app",
user_id=v.id,
target_user_id=app.author.id,
)
g.db.add(ma)
g.db.commit()
return {"message": f"App revoked"}
@ -160,6 +174,13 @@ def admin_app_reject(v, aid):
g.db.delete(app)
ma = ModAction(
kind="reject_app",
user_id=v.id,
target_user_id=app.author.id,
)
g.db.add(ma)
g.db.commit()
return {"message": f"App rejected"}

View File

@ -616,7 +616,7 @@ def submit_post(v):
user_id=AUTOJANNY_ACCOUNT,
target_submission_id=post.id,
kind="ban_post",
note="spam"
_note="spam"
)
g.db.add(ma)
return redirect("/notifications")

View File

@ -15,11 +15,11 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=86">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=86">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=87">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=87">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=86">
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=87">
{% endif %}
</head>

View File

@ -254,12 +254,12 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86">
<link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=86">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=86">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
<link rel="stylesheet" href="/assets/css/main.css?v=87">
<link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=87">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=87">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=86">
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=87">
{% endif %}
{% endblock %}

View File

@ -17,11 +17,11 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=86">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=86">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=87">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=87">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=86">
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=87">
{% endif %}
<div class="row justify-content-around">

View File

@ -12,7 +12,7 @@
<title>2-Step Login - {{'SITE_NAME' | app_config}}</title>
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=86">
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=87">
</head>

View File

@ -55,8 +55,8 @@
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=86">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=86">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=87">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=87">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
<link href="/assets/css/fa.css?v=52" rel="stylesheet">
</head>

View File

@ -40,10 +40,10 @@
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=86">
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=87">
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=86">
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=87">
{% endif %}
<link href="/assets/css/fa.css?v=52" rel="stylesheet">

View File

@ -36,7 +36,7 @@
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600&display=swap" rel="stylesheet">
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=86">
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=87">
</head>

View File

@ -31,7 +31,7 @@
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600&display=swap" rel="stylesheet">
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=86">
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=87">
</head>

View File

@ -25,12 +25,12 @@
{% block stylesheets %}
{% if v %}
<style>:root{--primary:#{{v.themecolor}}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=86">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=86">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
<link rel="stylesheet" href="/assets/css/main.css?v=87"><link rel="stylesheet" href="/assets/css/{{v.theme}}.css?v=87">
{% if v.agendaposter %}<link rel="stylesheet" href="/assets/css/agendaposter.css?v=87">{% elif v.css %}<link rel="stylesheet" href="/@{{v.username}}/css">{% endif %}
{% else %}
<style>:root{--primary:#{{'DEFAULT_COLOR' | app_config}}</style>
<link rel="stylesheet" href="/assets/css/main.css?v=86">
<link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=86">
<link rel="stylesheet" href="/assets/css/main.css?v=87">
<link rel="stylesheet" href="/assets/css/{{'DEFAULT_THEME' | app_config}}.css?v=87">
{% endif %}
{% endblock %}