From 9f45f0851a05662e53f9902a4bdc965db11d1776 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 16 Jul 2017 17:28:44 -0700 Subject: [PATCH] Allow renaming the tag via /tag/x/edit. --- .../etiquette_flask/etiquette_flask.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py b/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py index 80cafcc..0798e46 100644 --- a/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py +++ b/frontends/etiquette_flask/etiquette_flask/etiquette_flask.py @@ -812,6 +812,19 @@ def get_tags_json(specific_tag=None): @site.route('/tag//edit', methods=['POST']) def post_tag_edit(specific_tag): tag = P_tag(specific_tag) + name = request.form.get('name', '').strip() + if name: + try: + tag.rename(name, commit=False) + except etiquette.exceptions.EtiquetteException as e: + if isinstance(e, etiquette.exceptions.NoSuch): + status = 404 + else: + status = 400 + response = etiquette.jsonify.exception(e) + response = jsonify.make_json_response(response, status=status) + flask.abort(response) + description = request.form.get('description', None) tag.edit(description=description)