From 60f9e3f382a88f5c848aa8027f8fc865959315d0 Mon Sep 17 00:00:00 2001 From: Daniel Grams Date: Sun, 4 Oct 2020 13:32:32 +0200 Subject: [PATCH] =?UTF-8?q?Ort=20l=C3=B6schen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- forms/event_place.py | 4 +++ templates/event_place/delete.html | 24 ++++++++++++++++++ templates/manage/places.html | 1 + translations/de/LC_MESSAGES/messages.mo | Bin 13946 -> 14170 bytes translations/de/LC_MESSAGES/messages.po | 32 ++++++++++++++++-------- views/event_place.py | 30 +++++++++++++++++++++- 6 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 templates/event_place/delete.html diff --git a/forms/event_place.py b/forms/event_place.py index 9a6139d..81b820b 100644 --- a/forms/event_place.py +++ b/forms/event_place.py @@ -37,6 +37,10 @@ class UpdateEventPlaceForm(BaseEventPlaceForm): public = BooleanField(lazy_gettext('Other organizers can use this location'), validators=[Optional()]) submit = SubmitField(lazy_gettext("Update place")) +class DeleteEventPlaceForm(FlaskForm): + submit = SubmitField(lazy_gettext("Delete place")) + name = StringField(lazy_gettext('Name'), validators=[DataRequired()]) + class FindEventPlaceForm(FlaskForm): class Meta: csrf = False diff --git a/templates/event_place/delete.html b/templates/event_place/delete.html new file mode 100644 index 0000000..3b6b2d1 --- /dev/null +++ b/templates/event_place/delete.html @@ -0,0 +1,24 @@ +{% extends "layout.html" %} +{% from "_macros.html" import render_field_with_errors, render_field %} + +{% block content %} + +

{{ _('Delete place') }} "{{ place.name }}"

+ +
+ {{ form.hidden_tag() }} + +
+
+ {{ _('Place') }} +
+
+ {{ render_field_with_errors(form.name) }} +
+
+ + {{ render_field(form.submit) }} + +
+ +{% endblock %} diff --git a/templates/manage/places.html b/templates/manage/places.html index 87e2155..c5446fb 100644 --- a/templates/manage/places.html +++ b/templates/manage/places.html @@ -32,6 +32,7 @@ diff --git a/translations/de/LC_MESSAGES/messages.mo b/translations/de/LC_MESSAGES/mess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LC_MESSAGES/messages.po +++ b/translations/de/LC_MESSAGES/messages.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2020-10-04 12:59+0200\n" +"POT-Creation-Date: 2020-10-04 13:28+0200\n" "PO-Revision-Date: 2020-06-07 18:51+0200\n" "Last-Translator: FULL NAME \n" "Language: de\n" @@ -142,11 +142,11 @@ msgid "Longitude" msgstr "Längengrad" #: forms/admin_unit.py:19 forms/event.py:18 forms/event.py:36 forms/event.py:41 -#: forms/event.py:118 forms/event_place.py:20 forms/organizer.py:19 -#: forms/organizer.py:41 forms/reference.py:18 forms/reference_request.py:14 -#: templates/_macros.html:97 templates/admin/admin_units.html:18 -#: templates/event_place/list.html:19 templates/profile.html:16 -#: templates/profile.html:36 +#: forms/event.py:118 forms/event_place.py:20 forms/event_place.py:42 +#: forms/organizer.py:19 forms/organizer.py:41 forms/reference.py:18 +#: forms/reference_request.py:14 templates/_macros.html:97 +#: templates/admin/admin_units.html:18 templates/event_place/list.html:19 +#: templates/profile.html:16 templates/profile.html:36 msgid "Name" msgstr "Name" @@ -278,7 +278,7 @@ msgstr "Vorheriges Startdatum" msgid "Tags" msgstr "Stichworte" -#: forms/event.py:51 forms/event.py:141 forms/event_place.py:44 +#: forms/event.py:51 forms/event.py:141 forms/event_place.py:48 #: templates/_macros.html:363 templates/event/create.html:59 #: templates/event/update.html:46 templates/manage/events.html:17 #: templates/manage/places.html:17 templates/organizer/create.html:16 @@ -351,7 +351,7 @@ msgstr "Bewertung" #: forms/event.py:73 forms/event.py:74 forms/event.py:105 #: templates/_macros.html:333 templates/event/create.html:84 #: templates/event/update.html:55 templates/event_place/create.html:20 -#: templates/event_place/update.html:20 +#: templates/event_place/delete.html:13 templates/event_place/update.html:20 msgid "Place" msgstr "Ort" @@ -475,7 +475,11 @@ msgstr "Ort hinzufügen" msgid "Update place" msgstr "Ort aktualisieren" -#: forms/event_place.py:43 +#: forms/event_place.py:41 templates/event_place/delete.html:6 +msgid "Delete place" +msgstr "Ort löschen" + +#: forms/event_place.py:47 msgid "Find places" msgstr "Orte finden" @@ -845,7 +849,7 @@ msgstr "Bearbeiten" #: templates/manage/events.html:47 templates/manage/members.html:21 #: templates/manage/members.html:36 templates/manage/organizers.html:23 -#: templates/manage/references_incoming.html:20 +#: templates/manage/places.html:35 templates/manage/references_incoming.html:20 msgid "Delete" msgstr "Löschen" @@ -980,6 +984,14 @@ msgstr "Ort erfolgreich erstellt" msgid "Place successfully updated" msgstr "Ort erfolgreich aktualisiert" +#: views/event_place.py:70 +msgid "Entered name does not match place name" +msgstr "Der eingegebene Name entspricht nicht dem Namen des Ortes" + +#: views/event_place.py:75 +msgid "Place successfully deleted" +msgstr "Ort erfolgreich gelöscht" + #: views/event_review.py:55 views/reference_request_review.py:76 msgid "Event review status updated" msgstr "Prüfungsstatus aktualisiert" diff --git a/views/event_place.py b/views/event_place.py index 7d8038e..515bd37 100644 --- a/views/event_place.py +++ b/views/event_place.py @@ -4,7 +4,7 @@ from flask import render_template, flash, url_for, redirect, request, jsonify from flask_babelex import gettext from flask_security import auth_required from access import has_access, access_or_401, get_admin_unit_for_manage_or_404 -from forms.event_place import UpdateEventPlaceForm, CreateEventPlaceForm +from forms.event_place import UpdateEventPlaceForm, CreateEventPlaceForm, DeleteEventPlaceForm from .utils import flash_errors, upsert_image_with_data, send_mail, handleSqlError from sqlalchemy.sql import asc, func from sqlalchemy.exc import SQLAlchemyError @@ -57,6 +57,34 @@ def event_place_update(id): form=form, place=place) +@app.route('/event_place//delete', methods=('GET', 'POST')) +@auth_required() +def event_place_delete(id): + place = EventPlace.query.get_or_404(id) + access_or_401(place.adminunit, 'place:delete') + + form = DeleteEventPlaceForm() + + if form.validate_on_submit(): + if form.name.data != place.name: + flash(gettext('Entered name does not match place name'), 'danger') + else: + try: + organizer_id=place.organizer.id + db.session.delete(place) + db.session.commit() + flash(gettext('Place successfully deleted'), 'success') + return redirect(url_for('manage_organizer_event_places', organizer_id=organizer_id)) + except SQLAlchemyError as e: + db.session.rollback() + flash(handleSqlError(e), 'danger') + else: + flash_errors(form) + + return render_template('event_place/delete.html', + form=form, + place=place) + def update_event_place_with_form(place, form): form.populate_obj(place)