diff --git a/run.sh b/run.sh index 94ef6dd..f72b0b3 100755 --- a/run.sh +++ b/run.sh @@ -4,7 +4,7 @@ set -u main() { kill -9 $(pgrep python3) || true - kill -9 $(pgrep memcached) || true + kill -9 $(pgrep gunicorn) || true cd src python3 -m pip install gunicorn diff --git a/src/aw/views.py b/src/aw/views.py index 391333c..0c4b1bd 100644 --- a/src/aw/views.py +++ b/src/aw/views.py @@ -96,7 +96,22 @@ Comment: ```""", ) - flask.flash(f"Comment #{comment_id} confirmed.") + flask.flash(f"Comment #{comment.id} confirmed.") + + return flask.redirect(flask.url_for("views.index")) + + +@views.get("/delete///", alias=True) +@views.get("/delete//") +def delete(comment_id: int, token: str): + """delete a comment""" + + comment: models.Comment = models.Comment.query.filter_by(id=comment_id, token=token).first_or_404() + + models.db.session.delete(comment) + models.db.session.commit() + + flask.flash(f"Comment #{comment.id} deleted.") return flask.redirect(flask.url_for("views.index")) @@ -157,7 +172,11 @@ Visit the following URL to *confirm* your email: {flask.request.url.rstrip("/")}{flask.url_for("views.confirm", comment_id=comment.id, token=comment.token)} -...Or paste it into your browser.""", +Or you may delete the comment: + +{flask.request.url.rstrip("/")}{flask.url_for("views.delete", comment_id=comment.id, token=comment.token)} + +If clicking doesn't work - try pasting it into your browser, or running `curl`/`wget`/`axel` on it :)""", ) except Exception: models.db.session.delete(comment) diff --git a/src/templates/base.j2 b/src/templates/base.j2 index 53476ac..de0596d 100644 --- a/src/templates/base.j2 +++ b/src/templates/base.j2 @@ -42,7 +42,7 @@
messages from the server {% for category, message in messages %} -
{{ message | escape }}
+
[{{ category | escape }}] {{ message | escape }}
{% endfor %}
{% endif %} diff --git a/src/templates/index.j2 b/src/templates/index.j2 index e98be9b..89358dd 100644 --- a/src/templates/index.j2 +++ b/src/templates/index.j2 @@ -450,7 +450,7 @@
- Report any impersonation to the owner of this website: Ari Archer. + Report any impersonation, illegal/graphic content, and/or anything disturbing to the owner of this website: Ari Archer.