fix shit with hole logs

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-09-29 12:18:27 +02:00
parent 2f5ae40574
commit 51d7cd6d7e
9 changed files with 107 additions and 98 deletions

View File

@ -70,10 +70,6 @@ class ModAction(Base):
else:
return self._note or ""
@note.setter
def note(self, x):
self._note=x
@property
@lazy
def string(self):
@ -295,7 +291,7 @@ ACTIONTYPES = {
"color": 'bg-danger'
},
'pin_comment': {
"str": 'pinned a {self.target_link}',
"str": 'pinned {self.target_link}',
"icon": 'fa-thumbtack fa-rotate--45',
"color": 'bg-success'
},
@ -395,7 +391,7 @@ ACTIONTYPES = {
"color": 'bg-success'
},
'unpin_comment': {
"str": 'unpinned a {self.target_link}',
"str": 'unpinned {self.target_link}',
"icon": 'fa-thumbtack fa-rotate--45',
"color": 'bg-muted'
},

View File

@ -60,26 +60,13 @@ class SubAction(Base):
years = int(months / 12)
return f"{years}yr ago"
@property
def note(self):
if self.kind=="ban_user":
if self.target_post: return f'for <a href="{self.target_post.permalink}">post</a>'
else: return self._note
else:
return self._note or ""
@note.setter
def note(self, x):
self._note=x
@property
@lazy
def string(self):
output = ACTIONTYPES[self.kind]["str"].format(self=self, cc=CC_TITLE)
if self.note: output += f" <i>({self.note})</i>"
if self._note: output += f" <i>({self._note})</i>"
return output
@ -90,6 +77,7 @@ class SubAction(Base):
elif self.target_post:
if self.target_post.club: return f'<a href="{self.target_post.permalink}">{CC} ONLY</a>'
return censor_slurs(f'<a href="{self.target_post.permalink}">{self.target_post.title_html}</a>', None)
elif self.target_comment_id: return f'<a href="/comment/{self.target_comment_id}?context=8#context">comment</a>'
@property
@lazy
@ -113,12 +101,12 @@ ACTIONTYPES = {
"color": 'bg-danger'
},
'unexile_user': {
"str": 'unexile user {self.target_link}',
"str": 'unexiled user {self.target_link}',
"icon": 'fa-user',
"color": 'bg-success'
},
'make_mod': {
"str": 'made {self.target_link} mod',
"str": 'made {self.target_link} a mod',
"icon": 'fa-user-crown',
"color": 'bg-success'
},
@ -133,7 +121,7 @@ ACTIONTYPES = {
"color": 'bg-danger'
},
'move_chudrama': {
"str": 'moved post {self.target_link} to /h/chudrama',
"str": 'moved post {self.target_link} to <a href="/h/chudrama">/h/chudrama</a>',
"icon": 'fa-feather-alt',
"color": 'bg-danger'
},
@ -142,13 +130,13 @@ ACTIONTYPES = {
"icon": 'fa-tag',
"color": 'bg-primary'
},
'change_sidebar': {
"str": 'changed the sidebar',
'edit_sidebar': {
"str": 'edited the sidebar',
"icon": 'fa-columns',
"color": 'bg-primary'
},
'change_css': {
"str": 'changed the css',
'edit_css': {
"str": 'edited the css',
"icon": 'fa-css3-alt',
"color": 'bg-primary'
},
@ -178,12 +166,12 @@ ACTIONTYPES = {
"color": 'bg-muted'
},
'pin_comment': {
"str": 'pinned comment {self.target_link}',
"str": 'pinned {self.target_link}',
"icon": 'fa-thumbtack fa-rotate--45',
"color": 'bg-success'
},
'unpin_comment': {
"str": 'unpinned comment {self.target_link}',
"str": 'unpinned {self.target_link}',
"icon": 'fa-thumbtack fa-rotate--45',
"color": 'bg-muted'
},

View File

@ -862,7 +862,7 @@ def agendaposter(user_id, v):
kind="agendaposter",
user_id=v.id,
target_user_id=user.id,
note=note
_note=note
)
g.db.add(ma)

View File

@ -303,7 +303,7 @@ def award_thing(v, thing_type, id):
kind="agendaposter",
user_id=v.id,
target_user_id=author.id,
note=f"for 1 day"
_note=f"for 1 day"
)
g.db.add(ma)
elif kind == "flairlock":

View File

@ -42,9 +42,11 @@ def flag_post(pid, v):
g.db.add(ma)
else:
ma = SubAction(
sub=post.sub,
kind="flair_post",
user_id=v.id,
target_submission_id=post.id
target_submission_id=post.id,
_note=f'"{post.flair}"'
)
g.db.add(ma)
@ -84,6 +86,7 @@ def flag_post(pid, v):
g.db.add(ma)
else:
ma = SubAction(
sub=sub_from,
kind='move_chudrama',
user_id=v.id,
target_submission_id=post.id

View File

@ -31,6 +31,7 @@ def exile_post(v, pid):
send_notification(u.id, f"@{v.username} has exiled you from /h/{sub} for [{p.title}]({p.shortlink})")
ma = SubAction(
sub=sub,
kind='exile_user',
user_id=v.id,
target_user_id=u.id,
@ -65,6 +66,7 @@ def exile_comment(v, cid):
send_notification(u.id, f"@{v.username} has exiled you from /h/{sub} for [{c.permalink}]({c.shortlink})")
ma = SubAction(
sub=sub,
kind='exile_user',
user_id=v.id,
target_user_id=u.id,
@ -89,6 +91,7 @@ def unexile(v, sub, uid):
send_notification(u.id, f"@{v.username} has revoked your exile from /h/{sub}")
ma = SubAction(
sub=sub,
kind='unexile_user',
user_id=v.id,
target_user_id=u.id
@ -280,6 +283,7 @@ def add_mod(v, sub):
send_repeatable_notification(user.id, f"@{v.username} has added you as a mod to /h/{sub}")
ma = SubAction(
sub=sub,
kind='make_mod',
user_id=v.id,
target_user_id=user.id
@ -320,6 +324,7 @@ def remove_mod(v, sub):
send_repeatable_notification(user.id, f"@{v.username} has removed you as a mod from /h/{sub}")
ma = SubAction(
sub=sub,
kind='remove_mod',
user_id=v.id,
target_user_id=user.id
@ -395,6 +400,7 @@ def kick(v, pid):
g.db.add(ma)
else:
ma = SubAction(
sub=old,
kind='kick_post',
user_id=v.id,
target_submission_id=post.id
@ -441,7 +447,8 @@ def post_sub_sidebar(v, sub):
g.db.add(sub)
ma = SubAction(
kind='change_sidebar',
sub=sub.name,
kind='edit_sidebar',
user_id=v.id
)
g.db.add(ma)
@ -472,7 +479,8 @@ def post_sub_css(v, sub):
g.db.add(sub)
ma = SubAction(
kind='change_css',
sub=sub.name,
kind='edit_css',
user_id=v.id
)
g.db.add(ma)
@ -515,6 +523,7 @@ def sub_banner(v, sub):
g.db.add(sub)
ma = SubAction(
sub=sub.name,
kind='change_banner',
user_id=v.id
)
@ -547,6 +556,7 @@ def sub_sidebar(v, sub):
g.db.add(sub)
ma = SubAction(
sub=sub.name,
kind='change_sidebar_image',
user_id=v.id
)
@ -579,6 +589,7 @@ def sub_marsey(v, sub):
g.db.add(sub)
ma = SubAction(
sub=sub.name,
kind='change_marsey',
user_id=v.id
)
@ -609,6 +620,7 @@ def hole_pin(v, pid):
send_repeatable_notification(p.author_id, message)
ma = SubAction(
sub=p.sub,
kind='pin_post',
user_id=v.id,
target_submission_id=p.id
@ -634,6 +646,7 @@ def hole_unpin(v, pid):
send_repeatable_notification(p.author_id, message)
ma = SubAction(
sub=p.sub,
kind='unpin_post',
user_id=v.id,
target_submission_id=p.id
@ -659,6 +672,7 @@ def sub_stealth(v, sub):
if sub.stealth:
ma = SubAction(
sub=sub.name,
kind='enable_stealth',
user_id=v.id
)
@ -666,6 +680,7 @@ def sub_stealth(v, sub):
return {"message": f"Stealth mode has been enabled for /h/{sub} successfully!"}
else:
ma = SubAction(
sub=sub.name,
kind='disable_stealth',
user_id=v.id
)
@ -688,6 +703,7 @@ def mod_pin(cid, v):
g.db.add(comment)
ma = SubAction(
sub=comment.post.sub,
kind="pin_comment",
user_id=v.id,
target_comment_id=comment.id
@ -700,7 +716,7 @@ def mod_pin(cid, v):
return {"message": "Comment pinned!"}
@app.post("/mod_unpin/<cid>")
@app.post("/unmod_pin/<cid>")
@is_not_permabanned
def mod_unpin(cid, v):
@ -713,6 +729,7 @@ def mod_unpin(cid, v):
g.db.add(comment)
ma = SubAction(
sub=comment.post.sub,
kind="unpin_comment",
user_id=v.id,
target_comment_id=comment.id
@ -731,7 +748,7 @@ def mod_unpin(cid, v):
def hole_log(v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub.name
sub = sub
try: page = max(int(request.values.get("page", 1)), 1)
except: page = 1
@ -748,7 +765,7 @@ def hole_log(v, sub):
kind = None
actions = []
else:
actions = g.db.query(SubAction).filter_by(sub=sub)
actions = g.db.query(SubAction).filter_by(sub=sub.name)
if mod_id:
actions = actions.filter_by(user_id=mod_id)
@ -763,14 +780,17 @@ def hole_log(v, sub):
next_exists=len(actions)>25
actions=actions[:25]
mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub).all()]
mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub.name).all()]
mods = [x[0] for x in g.db.query(User.username).filter(User.id.in_(mods)).order_by(User.username).all()]
return render_template("log.html", v=v, mods=mods, types=types, mod=mod, type=kind, actions=actions, next_exists=next_exists, page=page)
return render_template("log.html", v=v, admins=mods, types=types, admin=mod, type=kind, actions=actions, next_exists=next_exists, page=page, sub=sub)
@app.get("/h/<sub>/log/<id>")
@auth_required
def hole_log_item(id, v, sub):
sub = g.db.get(Sub, sub.strip().lower())
if not sub: abort(404)
sub = sub
try: id = int(id)
except: abort(404)
@ -779,9 +799,9 @@ def hole_log_item(id, v, sub):
if not action: abort(404)
mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub).all()]
mods = [x[0] for x in g.db.query(Mod.user_id).filter_by(sub=sub.name).all()]
mods = [x[0] for x in g.db.query(User.username).filter(User.id.in_(mods)).order_by(User.username).all()]
types = ACTIONTYPES
return render_template("log.html", v=v, actions=[action], next_exists=False, page=1, action=action, mods=mods, types=types)
return render_template("log.html", v=v, actions=[action], next_exists=False, page=1, action=action, admins=mods, types=types, sub=sub)

View File

@ -335,7 +335,7 @@
</div>
{% block sidebar %}
{% if has_sidebar and (home or p) %}
{% if has_sidebar and (home or p or request.path.startswith('/h/')) %}
{% include "sidebar_" + SITE_NAME + ".html" %}
{% endif %}
{% endblock %}

View File

@ -40,9 +40,9 @@
<div class="col h-100">
<div class="d-md-flex justify-content-between mt-4">
<div class="d-md-flex justify-content-between mt-4 ml-1">
<div>
<h5>Moderation Log</h5>
<h5>{% if sub %}<a href="/h/{{sub.name}}">/h/{{sub.name}}</a> {% endif %}Moderation Log</h5>
</div>
</div>

View File

@ -54,70 +54,72 @@
{% block subNav %}
{% set mod = (v and v.admin_level > 1) %}
<div class="container-fluid bg-white sticky d-none d-md-block" style="padding-top: 50px; padding-bottom: 0 !important;">
<div class="row box-shadow-bottom">
<div class="col">
<div class="container" style="padding-bottom: 0;">
<div class="row box-shadow-bottom bg-white pt-3">
<div class="col">
<div class="d-flex flex-row-reverse justify-content-end">
<ul class="nav settings-nav" style="margin-left: -15px;">
<li class="nav-item">
<a class="nav-link{% if request.path == '/leaderboard' %} active{% endif %}" href="/leaderboard"><i class="fas fa-trophy pr-2"></i>Leaderboard</a>
</li>
<li class="nav-item">
<a class="nav-link{% if request.path == '/admins' %} active{% endif %}" href="/admins"><i class="fas fa-crown pr-2"></i>Admins</a>
</li>
<li class="nav-item">
<a class="nav-link{% if request.path == '/log' %} active{% endif %}" href="/log"><i class="fas fa-scroll-old pr-2"></i>Moderation Log</a>
</li>
<li class="nav-item">
<a class="nav-link{% if request.path == '/banned' %} active{% endif %}" href="/banned"><i class="fas fa-user-slash pr-2"></i>Permabanned Users</a>
</li>
{% if v and v.admin_level >= PERMS['USER_BLOCKS_VISIBLE'] -%}
<li class="nav-item">
<a class="nav-link{% if request.path == '/blocks' %} active{% endif %}" href="/blocks"><i class="fas fa-user-slash pr-2"></i>Blocks</a>
</li>
{%- endif %}
<li class="nav-item">
<a class="nav-link{% if request.path == '/h/changelog' %} active{% endif %}" href="https://rdrama.net/h/changelog"><i class="fas fa-clipboard pr-2"></i>Changelog</a>
</li>
</ul>
{% if not request.path.startswith('/h/') %}
<div class="container-fluid bg-white sticky d-none d-md-block" style="padding-top: 50px; padding-bottom: 0 !important;">
<div class="row box-shadow-bottom">
<div class="col">
<div class="container" style="padding-bottom: 0;">
<div class="row box-shadow-bottom bg-white pt-3">
<div class="col">
<div class="d-flex flex-row-reverse justify-content-end">
<ul class="nav settings-nav" style="margin-left: -15px;">
<li class="nav-item">
<a class="nav-link{% if request.path == '/leaderboard' %} active{% endif %}" href="/leaderboard"><i class="fas fa-trophy pr-2"></i>Leaderboard</a>
</li>
<li class="nav-item">
<a class="nav-link{% if request.path == '/admins' %} active{% endif %}" href="/admins"><i class="fas fa-crown pr-2"></i>Admins</a>
</li>
<li class="nav-item">
<a class="nav-link{% if request.path == '/log' %} active{% endif %}" href="/log"><i class="fas fa-scroll-old pr-2"></i>Moderation Log</a>
</li>
<li class="nav-item">
<a class="nav-link{% if request.path == '/banned' %} active{% endif %}" href="/banned"><i class="fas fa-user-slash pr-2"></i>Permabanned Users</a>
</li>
{% if v and v.admin_level >= PERMS['USER_BLOCKS_VISIBLE'] -%}
<li class="nav-item">
<a class="nav-link{% if request.path == '/blocks' %} active{% endif %}" href="/blocks"><i class="fas fa-user-slash pr-2"></i>Blocks</a>
</li>
{%- endif %}
<li class="nav-item">
<a class="nav-link{% if request.path == '/h/changelog' %} active{% endif %}" href="https://rdrama.net/h/changelog"><i class="fas fa-clipboard pr-2"></i>Changelog</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid bg-white sticky d-md-none" style="padding-top: 20px; padding-bottom: 0; margin-bottom: 20px;">
<div class="row box-shadow-bottom">
<div class="col px-0">
<div class="d-flex flex-row-reverse justify-content-center">
<ul class="nav settings-nav">
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/leaderboard' %} active{% endif %}" href="/leaderboard"><i class="fas fa-trophy text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/admins' %} active{% endif %}" href="/admins"><i class="fas fa-crown text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/log' %} active{% endif %}" href="/log"><i class="fas fa-scroll-old text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/banned' %} active{% endif %}" href="/banned"><i class="fas fa-user-slash text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/blocks' %} active{% endif %}" href="/blocks"><i class="fas fa-eye-slash text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/h/changelog' %} active{% endif %}" href="https://rdrama.net/h/changelog"><i class="fas fa-clipboard text-lg mr-0"></i></a>
</li>
</ul>
<div class="row box-shadow-bottom">
<div class="col px-0">
<div class="d-flex flex-row-reverse justify-content-center">
<ul class="nav settings-nav">
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/leaderboard' %} active{% endif %}" href="/leaderboard"><i class="fas fa-trophy text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/admins' %} active{% endif %}" href="/admins"><i class="fas fa-crown text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/log' %} active{% endif %}" href="/log"><i class="fas fa-scroll-old text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/banned' %} active{% endif %}" href="/banned"><i class="fas fa-user-slash text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/blocks' %} active{% endif %}" href="/blocks"><i class="fas fa-eye-slash text-lg mr-0"></i></a>
</li>
<li class="nav-item">
<a style="padding: 0.75rem 1rem"class="nav-link{% if request.path == '/h/changelog' %} active{% endif %}" href="https://rdrama.net/h/changelog"><i class="fas fa-clipboard text-lg mr-0"></i></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% endblock %}
<div class="{% if request.path == '/banned' or request.path == '/blocks' %}container-fluid{% else %}container{% endif %} {% if request.path in ['/leaderboard', '/paypigs', '/patrons'] %}px-0{% endif %}">