From 08602b4279e5c5699a2385e33f4c1b7650348157 Mon Sep 17 00:00:00 2001 From: Ben Rog-Wilhelm Date: Thu, 1 Dec 2022 20:35:11 -0600 Subject: [PATCH] Volunteer Janitor: Minor cleanups. --- files/assets/css/main.css | 2 +- files/assets/js/{volunteer_exit.js => volunteer.js} | 0 files/routes/volunteer.py | 6 +++--- files/routes/volunteer_janitor.py | 2 ++ files/templates/volunteer.html | 6 +++--- files/templates/volunteer_submit.html | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-) rename files/assets/js/{volunteer_exit.js => volunteer.js} (100%) diff --git a/files/assets/css/main.css b/files/assets/css/main.css index 166811414..6241b93ec 100644 --- a/files/assets/css/main.css +++ b/files/assets/css/main.css @@ -5315,4 +5315,4 @@ div[id^="reply-edit-"] li > p:first-child { .volunteer_janitor .choices { margin-top: 1rem; -} \ No newline at end of file +} diff --git a/files/assets/js/volunteer_exit.js b/files/assets/js/volunteer.js similarity index 100% rename from files/assets/js/volunteer_exit.js rename to files/assets/js/volunteer.js diff --git a/files/routes/volunteer.py b/files/routes/volunteer.py index 8633a7ba8..736ed268d 100644 --- a/files/routes/volunteer.py +++ b/files/routes/volunteer.py @@ -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) diff --git a/files/routes/volunteer_janitor.py b/files/routes/volunteer_janitor.py index 155808aa2..1074752b7 100644 --- a/files/routes/volunteer_janitor.py +++ b/files/routes/volunteer_janitor.py @@ -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) \ diff --git a/files/templates/volunteer.html b/files/templates/volunteer.html index 3269cdd63..14d71a349 100644 --- a/files/templates/volunteer.html +++ b/files/templates/volunteer.html @@ -3,7 +3,7 @@ {% block pagetitle %}Volunteer{% endblock %} {% block content %} - + {% if duty == None %} @@ -15,7 +15,7 @@ {% else %} -
+
{% from duty.embed_template() import display with context %} @@ -26,4 +26,4 @@
{% endif %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/files/templates/volunteer_submit.html b/files/templates/volunteer_submit.html index cd571fb83..3e6b4fcfe 100644 --- a/files/templates/volunteer_submit.html +++ b/files/templates/volunteer_submit.html @@ -14,4 +14,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %}