Volunteer Janitor: Minor cleanups.

This commit is contained in:
Ben Rog-Wilhelm 2022-12-01 20:35:11 -06:00 committed by Ben Rog-Wilhelm
parent 8fd9177711
commit 08602b4279
6 changed files with 10 additions and 8 deletions

View file

@ -5315,4 +5315,4 @@ div[id^="reply-edit-"] li > p:first-child {
.volunteer_janitor .choices {
margin-top: 1rem;
}
}

View file

@ -23,8 +23,8 @@ def volunteer_get_duty(u: Optional[User]) -> Optional[VolunteerDuty]:
if u is None:
return None
# check to make sure it's at least 20h since the last volunteer
if not app.config['DBG_VOLUNTEER_PERMISSIVE']:
# check to make sure it's at least 20h since the last volunteer
if (u.volunteer_last_started_utc is not None) and (datetime.now() - u.volunteer_last_started_utc) < timedelta(hours = 20):
return None
@ -50,7 +50,7 @@ def volunteer(v: User):
return render_template("volunteer.html", v=v, duty=duty)
@app.post("/volunteer_submit")
@app.post("/volunteer/submit")
@auth_required
def volunteer_submit(v: User):
for k in request.values:
@ -61,6 +61,6 @@ def volunteer_submit(v: User):
if k_processed.startswith("janitor-"):
files.routes.volunteer_janitor.submitted(v, k_processed.removeprefix("janitor-"), request.values[k])
else:
raise ValueError("bad key, let's generate an error")
abort(400)
return render_template("volunteer_submit.html", v=v)

View file

@ -42,6 +42,7 @@ def get_duty(u: User) -> VolunteerDutyJanitor:
# find reported comments not made by the current user
reported_comments = g.db.query(Comment) \
.where(Comment.filter_state == 'reported') \
.where(Comment.is_approved == None) \
.where(Comment.author_id != u.id) \
.with_entities(Comment.id)
@ -49,6 +50,7 @@ def get_duty(u: User) -> VolunteerDutyJanitor:
if not app.config['DBG_VOLUNTEER_PERMISSIVE']:
# find distinguished children of those reported comments
# this is a ghastly query and should be fixed when we're doing some kind of cleanup and mod-action formalization
distinguished_children = g.db.query(Comment) \
.where(Comment.parent_comment_id.in_(reported_ids)) \
.where(Comment.distinguish_level > 0) \

View file

@ -3,7 +3,7 @@
{% block pagetitle %}Volunteer{% endblock %}
{% block content %}
<script src="{{ 'js/volunteer_exit.js' | asset }}"></script>
<script src="{{ 'js/volunteer.js' | asset }}"></script>
{% if duty == None %}
<a href="/" class="volunteer_unavailable_wrapper">
@ -15,7 +15,7 @@
</div>
</a>
{% else %}
<form id="volunteer_submit" action="/volunteer_submit" method="post" enctype="multipart/form-data" onsubmit="onFormSubmit()"></form>
<form id="volunteer_submit" action="/volunteer/submit" method="post" enctype="multipart/form-data" onsubmit="onFormSubmit()"></form>
<input form="volunteer_submit" type="hidden" name="formkey" value="{{v.formkey}}">
<div class="volunteer">
{% from duty.embed_template() import display with context %}
@ -26,4 +26,4 @@
</div>
{% endif %}
{% endblock %}
{% endblock %}

View file

@ -14,4 +14,4 @@
</div>
</a>
{% endblock %}
{% endblock %}