Show admin unit verified in admin panel #414

This commit is contained in:
Daniel Grams 2023-04-06 14:10:24 +02:00
parent 68a04a7286
commit 71cda1b917
8 changed files with 298 additions and 141 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-04-05 18:46+0200\n"
"POT-Creation-Date: 2023-04-06 14:02+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -300,27 +300,43 @@ msgstr ""
msgid "Update organization"
msgstr ""
#: project/forms/admin.py:68 project/forms/admin.py:75
#: project/forms/admin.py:68 project/templates/admin/delete_admin_unit.html:6
msgid "Delete organization"
msgstr ""
#: project/forms/admin.py:69 project/forms/admin_unit.py:29
#: project/forms/event.py:85 project/forms/event.py:114
#: project/forms/event_place.py:25 project/forms/event_place.py:50
#: project/forms/event_suggestion.py:26 project/forms/oauth2_client.py:66
#: project/forms/organizer.py:25 project/forms/organizer.py:52
#: project/forms/reference_request.py:23
#: project/templates/admin/admin_units.html:19
#: project/templates/event_place/list.html:19
#: project/templates/oauth2_client/list.html:25
msgid "Name"
msgstr ""
#: project/forms/admin.py:73 project/forms/admin.py:80
msgid "Recipient"
msgstr ""
#: project/forms/admin.py:70
#: project/forms/admin.py:75
msgid "Send test mail synchronously"
msgstr ""
#: project/forms/admin.py:77 project/forms/admin.py:83
#: project/forms/admin.py:82 project/forms/admin.py:88
msgid "Test recipient"
msgstr ""
#: project/forms/admin.py:78
#: project/forms/admin.py:83
msgid "All users with enabled newsletter setting"
msgstr ""
#: project/forms/admin.py:84
#: project/forms/admin.py:89
msgid "Message"
msgstr ""
#: project/forms/admin.py:85
#: project/forms/admin.py:90
msgid "Send newsletter"
msgstr ""
@ -354,17 +370,6 @@ msgstr ""
msgid "Longitude"
msgstr ""
#: project/forms/admin_unit.py:29 project/forms/event.py:85
#: project/forms/event.py:114 project/forms/event_place.py:25
#: project/forms/event_place.py:50 project/forms/event_suggestion.py:26
#: project/forms/oauth2_client.py:66 project/forms/organizer.py:25
#: project/forms/organizer.py:52 project/forms/reference_request.py:23
#: project/templates/admin/admin_units.html:19
#: project/templates/event_place/list.html:19
#: project/templates/oauth2_client/list.html:25
msgid "Name"
msgstr ""
#: project/forms/admin_unit.py:32
msgid "Short name"
msgstr ""
@ -1100,6 +1105,7 @@ msgstr ""
#: project/forms/reference.py:11 project/forms/reference_request.py:16
#: project/templates/_macros.html:491 project/templates/_macros.html:654
#: project/templates/admin/delete_admin_unit.html:13
#: project/templates/admin_unit/create.html:28
#: project/templates/admin_unit/update.html:29
#: project/templates/layout.html:242
@ -1414,7 +1420,7 @@ msgstr ""
msgid "Enter list name"
msgstr ""
#: project/templates/home.html:25
#: project/templates/admin/admin_units.html:32 project/templates/home.html:25
msgid "Manage"
msgstr ""
@ -1603,7 +1609,15 @@ msgstr ""
msgid "Users"
msgstr ""
#: project/templates/admin/admin_units.html:27
#: project/templates/admin/admin_units.html:33
#: project/templates/manage/events.html:59
#: project/templates/manage/organizers.html:21
#: project/templates/manage/references_incoming.html:19
#: project/templates/manage/references_outgoing.html:19
msgid "View"
msgstr ""
#: project/templates/admin/admin_units.html:34
#: project/templates/admin/users.html:34
#: project/templates/manage/events.html:60
#: project/templates/manage/members.html:35
@ -1615,11 +1629,23 @@ msgstr ""
msgid "Edit"
msgstr ""
#: project/templates/admin/admin_units.html:35
#: project/templates/admin/users.html:35
#: project/templates/manage/events.html:61
#: project/templates/manage/members.html:21
#: project/templates/manage/members.html:36
#: project/templates/manage/organizers.html:24
#: project/templates/manage/places.html:28
#: project/templates/manage/references_incoming.html:21
#: project/templates/oauth2_client/list.html:35
msgid "Delete"
msgstr ""
#: project/templates/admin/delete_user.html:13
msgid "User"
msgstr ""
#: project/templates/admin/email.html:47 project/views/admin.py:123
#: project/templates/admin/email.html:47 project/views/admin.py:151
msgid "Mail sent successfully"
msgstr ""
@ -1635,17 +1661,6 @@ msgstr ""
msgid "Mails sent successfully"
msgstr ""
#: project/templates/admin/users.html:35
#: project/templates/manage/events.html:61
#: project/templates/manage/members.html:21
#: project/templates/manage/members.html:36
#: project/templates/manage/organizers.html:24
#: project/templates/manage/places.html:28
#: project/templates/manage/references_incoming.html:21
#: project/templates/oauth2_client/list.html:35
msgid "Delete"
msgstr ""
#: project/templates/admin_unit/create.html:58
#: project/templates/admin_unit/update.html:59
#: project/templates/event/create.html:347
@ -1939,13 +1954,6 @@ msgstr ""
msgid "Verify organization"
msgstr ""
#: project/templates/manage/events.html:59
#: project/templates/manage/organizers.html:21
#: project/templates/manage/references_incoming.html:19
#: project/templates/manage/references_outgoing.html:19
msgid "View"
msgstr ""
#: project/templates/manage/events.html:62
msgid "Duplicate"
msgstr ""
@ -2104,34 +2112,42 @@ msgstr ""
msgid "Preview"
msgstr ""
#: project/views/admin.py:59
#: project/views/admin.py:60
msgid "Organization successfully updated"
msgstr ""
#: project/views/admin.py:83 project/views/manage.py:371
#: project/views/admin.py:82
msgid "Entered name does not match organization name"
msgstr ""
#: project/views/admin.py:87
msgid "Organization successfully deleted"
msgstr ""
#: project/views/admin.py:111 project/views/manage.py:371
#: project/views/user.py:28
msgid "Settings successfully updated"
msgstr ""
#: project/views/admin.py:112
#: project/views/admin.py:140
#, python-format
msgid "Test mail from %(site_name)s"
msgstr ""
#: project/views/admin.py:151
#: project/views/admin.py:179
#, python-format
msgid "Newsletter from %(site_name)s"
msgstr ""
#: project/views/admin.py:201
#: project/views/admin.py:229
msgid "User successfully updated"
msgstr ""
#: project/views/admin.py:221
#: project/views/admin.py:249
msgid "Entered email does not match user email"
msgstr ""
#: project/views/admin.py:226
#: project/views/admin.py:254
msgid "User successfully deleted"
msgstr ""

View File

@ -1,6 +1,6 @@
from flask_babelex import lazy_gettext
from flask_wtf import FlaskForm
from wtforms import BooleanField, RadioField, SubmitField, TextAreaField
from wtforms import BooleanField, RadioField, StringField, SubmitField, TextAreaField
from wtforms.fields.html5 import EmailField
from wtforms.validators import DataRequired, Optional
@ -64,6 +64,11 @@ class UpdateAdminUnitForm(FlaskForm):
submit = SubmitField(lazy_gettext("Update organization"))
class DeleteAdminUnitForm(FlaskForm):
submit = SubmitField(lazy_gettext("Delete organization"))
name = StringField(lazy_gettext("Name"), validators=[DataRequired()])
class AdminTestEmailForm(FlaskForm):
recipient = EmailField(lazy_gettext("Recipient"), validators=[DataRequired()])

View File

@ -1,5 +1,5 @@
{% extends "layout.html" %}
{% from "_macros.html" import render_pagination %}
{% from "_macros.html" import render_admin_unit_badges, render_pagination %}
{%- block title -%}
{{ _('Organizations') }}
{%- endblock -%}
@ -18,13 +18,22 @@
<tr>
<th>{{ _('Name') }}</th>
<th></th>
<th>created_at</th>
<th></th>
</tr>
</thead>
<tbody>
{% for admin_unit in admin_units %}
<tr>
<td>{{ admin_unit.name }}</td>
<td><a href="{{ url_for('admin_admin_unit_update', id=admin_unit.id) }}">{{ _('Edit') }}</a></td>
<td>{{ render_admin_unit_badges(admin_unit) }}</td>
<td>{% if admin_unit.created_at %}{{ admin_unit.created_at | dateformat }}{% endif %}</td>
<td>
<a href="{{ url_for('manage_admin_unit', id=admin_unit.id) }}">{{ _('Manage') }}</a>
<a href="{{ url_for('organizations', path=admin_unit.id) }}">{{ _('View') }}</a>
<a href="{{ url_for('admin_admin_unit_update', id=admin_unit.id) }}">{{ _('Edit') }}</a>
<a href="{{ url_for('admin_admin_unit_delete', id=admin_unit.id) }}">{{ _('Delete') }}</a>
</td>
</tr>
{% endfor %}
</tbody>

View File

@ -0,0 +1,24 @@
{% extends "layout.html" %}
{% from "_macros.html" import render_field_with_errors, render_field %}
{% block content %}
<h1>{{ _('Delete organization') }} &quot;{{ admin_unit.name }}&quot;</h1>
<form action="" method="POST">
{{ form.hidden_tag() }}
<div class="card mb-4">
<div class="card-header">
{{ _('Organization') }}
</div>
<div class="card-body">
{{ render_field_with_errors(form.name) }}
</div>
</div>
{{ render_field(form.submit) }}
</form>
{% endblock %}

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-04-05 18:46+0200\n"
"POT-Creation-Date: 2023-04-06 14:02+0200\n"
"PO-Revision-Date: 2020-06-07 18:51+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: de\n"
@ -309,27 +309,43 @@ msgstr ""
msgid "Update organization"
msgstr "Organisation aktualisieren"
#: project/forms/admin.py:68 project/forms/admin.py:75
#: project/forms/admin.py:68 project/templates/admin/delete_admin_unit.html:6
msgid "Delete organization"
msgstr "Organisation löschen"
#: project/forms/admin.py:69 project/forms/admin_unit.py:29
#: project/forms/event.py:85 project/forms/event.py:114
#: project/forms/event_place.py:25 project/forms/event_place.py:50
#: project/forms/event_suggestion.py:26 project/forms/oauth2_client.py:66
#: project/forms/organizer.py:25 project/forms/organizer.py:52
#: project/forms/reference_request.py:23
#: project/templates/admin/admin_units.html:19
#: project/templates/event_place/list.html:19
#: project/templates/oauth2_client/list.html:25
msgid "Name"
msgstr "Name"
#: project/forms/admin.py:73 project/forms/admin.py:80
msgid "Recipient"
msgstr "Empfänger"
#: project/forms/admin.py:70
#: project/forms/admin.py:75
msgid "Send test mail synchronously"
msgstr "Test-Mail synchron senden"
#: project/forms/admin.py:77 project/forms/admin.py:83
#: project/forms/admin.py:82 project/forms/admin.py:88
msgid "Test recipient"
msgstr "Test-Empfänger"
#: project/forms/admin.py:78
#: project/forms/admin.py:83
msgid "All users with enabled newsletter setting"
msgstr "Alle Nutzer mit aktiviertem Newsletter"
#: project/forms/admin.py:84
#: project/forms/admin.py:89
msgid "Message"
msgstr "Nachricht"
#: project/forms/admin.py:85
#: project/forms/admin.py:90
msgid "Send newsletter"
msgstr "Newsletter senden"
@ -363,17 +379,6 @@ msgstr "Breitengrad"
msgid "Longitude"
msgstr "Längengrad"
#: project/forms/admin_unit.py:29 project/forms/event.py:85
#: project/forms/event.py:114 project/forms/event_place.py:25
#: project/forms/event_place.py:50 project/forms/event_suggestion.py:26
#: project/forms/oauth2_client.py:66 project/forms/organizer.py:25
#: project/forms/organizer.py:52 project/forms/reference_request.py:23
#: project/templates/admin/admin_units.html:19
#: project/templates/event_place/list.html:19
#: project/templates/oauth2_client/list.html:25
msgid "Name"
msgstr "Name"
#: project/forms/admin_unit.py:32
msgid "Short name"
msgstr "Kurzname"
@ -1148,6 +1153,7 @@ msgstr "Wochentage"
#: project/forms/reference.py:11 project/forms/reference_request.py:16
#: project/templates/_macros.html:491 project/templates/_macros.html:654
#: project/templates/admin/delete_admin_unit.html:13
#: project/templates/admin_unit/create.html:28
#: project/templates/admin_unit/update.html:29
#: project/templates/layout.html:242
@ -1471,7 +1477,7 @@ msgstr "Veranstalter eingeben"
msgid "Enter list name"
msgstr "Listenname eingeben"
#: project/templates/home.html:25
#: project/templates/admin/admin_units.html:32 project/templates/home.html:25
msgid "Manage"
msgstr "Verwaltung"
@ -1660,7 +1666,15 @@ msgstr "OAuth2 Clients"
msgid "Users"
msgstr "Nutzer"
#: project/templates/admin/admin_units.html:27
#: project/templates/admin/admin_units.html:33
#: project/templates/manage/events.html:59
#: project/templates/manage/organizers.html:21
#: project/templates/manage/references_incoming.html:19
#: project/templates/manage/references_outgoing.html:19
msgid "View"
msgstr "Anzeigen"
#: project/templates/admin/admin_units.html:34
#: project/templates/admin/users.html:34
#: project/templates/manage/events.html:60
#: project/templates/manage/members.html:35
@ -1672,11 +1686,23 @@ msgstr "Nutzer"
msgid "Edit"
msgstr "Bearbeiten"
#: project/templates/admin/admin_units.html:35
#: project/templates/admin/users.html:35
#: project/templates/manage/events.html:61
#: project/templates/manage/members.html:21
#: project/templates/manage/members.html:36
#: project/templates/manage/organizers.html:24
#: project/templates/manage/places.html:28
#: project/templates/manage/references_incoming.html:21
#: project/templates/oauth2_client/list.html:35
msgid "Delete"
msgstr "Löschen"
#: project/templates/admin/delete_user.html:13
msgid "User"
msgstr "Nutzer"
#: project/templates/admin/email.html:47 project/views/admin.py:123
#: project/templates/admin/email.html:47 project/views/admin.py:151
msgid "Mail sent successfully"
msgstr "Mail erfolgreich gesendet"
@ -1692,17 +1718,6 @@ msgstr "Test-Mail asynchron senden"
msgid "Mails sent successfully"
msgstr "Mails erfolgreich gesendet"
#: project/templates/admin/users.html:35
#: project/templates/manage/events.html:61
#: project/templates/manage/members.html:21
#: project/templates/manage/members.html:36
#: project/templates/manage/organizers.html:24
#: project/templates/manage/places.html:28
#: project/templates/manage/references_incoming.html:21
#: project/templates/oauth2_client/list.html:35
msgid "Delete"
msgstr "Löschen"
#: project/templates/admin_unit/create.html:58
#: project/templates/admin_unit/update.html:59
#: project/templates/event/create.html:347
@ -2005,13 +2020,6 @@ msgstr ""
msgid "Verify organization"
msgstr "Organisation verifizieren"
#: project/templates/manage/events.html:59
#: project/templates/manage/organizers.html:21
#: project/templates/manage/references_incoming.html:19
#: project/templates/manage/references_outgoing.html:19
msgid "View"
msgstr "Anzeigen"
#: project/templates/manage/events.html:62
msgid "Duplicate"
msgstr "Duplizieren"
@ -2172,34 +2180,42 @@ msgstr "Optionale Details"
msgid "Preview"
msgstr "Vorschau"
#: project/views/admin.py:59
#: project/views/admin.py:60
msgid "Organization successfully updated"
msgstr "Organisation erfolgreich aktualisiert"
#: project/views/admin.py:83 project/views/manage.py:371
#: project/views/admin.py:82
msgid "Entered name does not match organization name"
msgstr "Der eingegebene Name entspricht nicht dem Namen der Organisation"
#: project/views/admin.py:87
msgid "Organization successfully deleted"
msgstr "Organisation erfolgreich gelöscht"
#: project/views/admin.py:111 project/views/manage.py:371
#: project/views/user.py:28
msgid "Settings successfully updated"
msgstr "Einstellungen erfolgreich aktualisiert"
#: project/views/admin.py:112
#: project/views/admin.py:140
#, python-format
msgid "Test mail from %(site_name)s"
msgstr "Test-Mail von %(site_name)s"
#: project/views/admin.py:151
#: project/views/admin.py:179
#, python-format
msgid "Newsletter from %(site_name)s"
msgstr "Newsletter von %(site_name)s"
#: project/views/admin.py:201
#: project/views/admin.py:229
msgid "User successfully updated"
msgstr "Nutzer erfolgreich aktualisiert"
#: project/views/admin.py:221
#: project/views/admin.py:249
msgid "Entered email does not match user email"
msgstr "Die eingegebene Email passt nicht zur Email des Nutzers"
#: project/views/admin.py:226
#: project/views/admin.py:254
msgid "User successfully deleted"
msgstr "Nutzer erfolgreich gelöscht"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2023-04-05 18:46+0200\n"
"POT-Creation-Date: 2023-04-06 14:02+0200\n"
"PO-Revision-Date: 2021-04-30 15:04+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: en\n"
@ -301,27 +301,43 @@ msgstr ""
msgid "Update organization"
msgstr ""
#: project/forms/admin.py:68 project/forms/admin.py:75
#: project/forms/admin.py:68 project/templates/admin/delete_admin_unit.html:6
msgid "Delete organization"
msgstr ""
#: project/forms/admin.py:69 project/forms/admin_unit.py:29
#: project/forms/event.py:85 project/forms/event.py:114
#: project/forms/event_place.py:25 project/forms/event_place.py:50
#: project/forms/event_suggestion.py:26 project/forms/oauth2_client.py:66
#: project/forms/organizer.py:25 project/forms/organizer.py:52
#: project/forms/reference_request.py:23
#: project/templates/admin/admin_units.html:19
#: project/templates/event_place/list.html:19
#: project/templates/oauth2_client/list.html:25
msgid "Name"
msgstr ""
#: project/forms/admin.py:73 project/forms/admin.py:80
msgid "Recipient"
msgstr ""
#: project/forms/admin.py:70
#: project/forms/admin.py:75
msgid "Send test mail synchronously"
msgstr ""
#: project/forms/admin.py:77 project/forms/admin.py:83
#: project/forms/admin.py:82 project/forms/admin.py:88
msgid "Test recipient"
msgstr ""
#: project/forms/admin.py:78
#: project/forms/admin.py:83
msgid "All users with enabled newsletter setting"
msgstr ""
#: project/forms/admin.py:84
#: project/forms/admin.py:89
msgid "Message"
msgstr ""
#: project/forms/admin.py:85
#: project/forms/admin.py:90
msgid "Send newsletter"
msgstr ""
@ -355,17 +371,6 @@ msgstr ""
msgid "Longitude"
msgstr ""
#: project/forms/admin_unit.py:29 project/forms/event.py:85
#: project/forms/event.py:114 project/forms/event_place.py:25
#: project/forms/event_place.py:50 project/forms/event_suggestion.py:26
#: project/forms/oauth2_client.py:66 project/forms/organizer.py:25
#: project/forms/organizer.py:52 project/forms/reference_request.py:23
#: project/templates/admin/admin_units.html:19
#: project/templates/event_place/list.html:19
#: project/templates/oauth2_client/list.html:25
msgid "Name"
msgstr ""
#: project/forms/admin_unit.py:32
msgid "Short name"
msgstr ""
@ -1101,6 +1106,7 @@ msgstr ""
#: project/forms/reference.py:11 project/forms/reference_request.py:16
#: project/templates/_macros.html:491 project/templates/_macros.html:654
#: project/templates/admin/delete_admin_unit.html:13
#: project/templates/admin_unit/create.html:28
#: project/templates/admin_unit/update.html:29
#: project/templates/layout.html:242
@ -1422,7 +1428,7 @@ msgstr ""
msgid "Enter list name"
msgstr ""
#: project/templates/home.html:25
#: project/templates/admin/admin_units.html:32 project/templates/home.html:25
msgid "Manage"
msgstr ""
@ -1611,7 +1617,15 @@ msgstr ""
msgid "Users"
msgstr ""
#: project/templates/admin/admin_units.html:27
#: project/templates/admin/admin_units.html:33
#: project/templates/manage/events.html:59
#: project/templates/manage/organizers.html:21
#: project/templates/manage/references_incoming.html:19
#: project/templates/manage/references_outgoing.html:19
msgid "View"
msgstr ""
#: project/templates/admin/admin_units.html:34
#: project/templates/admin/users.html:34
#: project/templates/manage/events.html:60
#: project/templates/manage/members.html:35
@ -1623,11 +1637,23 @@ msgstr ""
msgid "Edit"
msgstr ""
#: project/templates/admin/admin_units.html:35
#: project/templates/admin/users.html:35
#: project/templates/manage/events.html:61
#: project/templates/manage/members.html:21
#: project/templates/manage/members.html:36
#: project/templates/manage/organizers.html:24
#: project/templates/manage/places.html:28
#: project/templates/manage/references_incoming.html:21
#: project/templates/oauth2_client/list.html:35
msgid "Delete"
msgstr ""
#: project/templates/admin/delete_user.html:13
msgid "User"
msgstr ""
#: project/templates/admin/email.html:47 project/views/admin.py:123
#: project/templates/admin/email.html:47 project/views/admin.py:151
msgid "Mail sent successfully"
msgstr ""
@ -1643,17 +1669,6 @@ msgstr ""
msgid "Mails sent successfully"
msgstr ""
#: project/templates/admin/users.html:35
#: project/templates/manage/events.html:61
#: project/templates/manage/members.html:21
#: project/templates/manage/members.html:36
#: project/templates/manage/organizers.html:24
#: project/templates/manage/places.html:28
#: project/templates/manage/references_incoming.html:21
#: project/templates/oauth2_client/list.html:35
msgid "Delete"
msgstr ""
#: project/templates/admin_unit/create.html:58
#: project/templates/admin_unit/update.html:59
#: project/templates/event/create.html:347
@ -1947,13 +1962,6 @@ msgstr ""
msgid "Verify organization"
msgstr ""
#: project/templates/manage/events.html:59
#: project/templates/manage/organizers.html:21
#: project/templates/manage/references_incoming.html:19
#: project/templates/manage/references_outgoing.html:19
msgid "View"
msgstr ""
#: project/templates/manage/events.html:62
msgid "Duplicate"
msgstr ""
@ -2112,34 +2120,42 @@ msgstr ""
msgid "Preview"
msgstr ""
#: project/views/admin.py:59
#: project/views/admin.py:60
msgid "Organization successfully updated"
msgstr ""
#: project/views/admin.py:83 project/views/manage.py:371
#: project/views/admin.py:82
msgid "Entered name does not match organization name"
msgstr ""
#: project/views/admin.py:87
msgid "Organization successfully deleted"
msgstr ""
#: project/views/admin.py:111 project/views/manage.py:371
#: project/views/user.py:28
msgid "Settings successfully updated"
msgstr ""
#: project/views/admin.py:112
#: project/views/admin.py:140
#, python-format
msgid "Test mail from %(site_name)s"
msgstr ""
#: project/views/admin.py:151
#: project/views/admin.py:179
#, python-format
msgid "Newsletter from %(site_name)s"
msgstr ""
#: project/views/admin.py:201
#: project/views/admin.py:229
msgid "User successfully updated"
msgstr ""
#: project/views/admin.py:221
#: project/views/admin.py:249
msgid "Entered email does not match user email"
msgstr ""
#: project/views/admin.py:226
#: project/views/admin.py:254
msgid "User successfully deleted"
msgstr ""

View File

@ -11,6 +11,7 @@ from project.forms.admin import (
AdminNewsletterForm,
AdminSettingsForm,
AdminTestEmailForm,
DeleteAdminUnitForm,
DeleteUserForm,
UpdateAdminUnitForm,
UpdateUserForm,
@ -69,6 +70,33 @@ def admin_admin_unit_update(id):
)
@app.route("/admin/admin_unit/<int:id>/delete", methods=("GET", "POST"))
@roles_required("admin")
def admin_admin_unit_delete(id):
admin_unit = AdminUnit.query.get_or_404(id)
form = DeleteAdminUnitForm()
if form.validate_on_submit():
if non_match_for_deletion(form.name.data, admin_unit.name):
flash(gettext("Entered name does not match organization name"), "danger")
else:
try:
db.session.delete(admin_unit)
db.session.commit()
flash(gettext("Organization successfully deleted"), "success")
return redirect(url_for("admin_admin_units"))
except SQLAlchemyError as e:
db.session.rollback()
flash(handleSqlError(e), "danger")
else:
flash_errors(form)
return render_template(
"admin/delete_admin_unit.html", form=form, admin_unit=admin_unit
)
@app.route("/admin/settings", methods=("GET", "POST"))
@roles_required("admin")
def admin_settings():

View File

@ -242,3 +242,46 @@ def test_admin_admin_unit_update(client, seeder, utils, app, mocker, db, db_erro
assert admin_unit.can_create_other
assert admin_unit.can_invite_other
assert admin_unit.can_verify_other
@pytest.mark.parametrize("db_error", [True, False])
@pytest.mark.parametrize("non_match", [True, False])
def test_admin_unit_delete(client, seeder, utils, app, mocker, db_error, non_match):
user_id, admin_unit_id = seeder.setup_base(True)
url = utils.get_url("admin_admin_unit_delete", id=admin_unit_id)
response = utils.get_ok(url)
if db_error:
utils.mock_db_commit(mocker)
form_name = "Meine Crew"
if non_match:
form_name = "wrong"
response = utils.post_form(
url,
response,
{
"name": form_name,
},
)
if non_match:
utils.assert_response_error_message(
response, "Der eingegebene Name entspricht nicht dem Namen der Organisation"
)
return
if db_error:
utils.assert_response_db_error(response)
return
utils.assert_response_redirect(response, "admin_admin_units")
with app.app_context():
from project.models import AdminUnit
admin_unit = AdminUnit.query.get(admin_unit_id)
assert admin_unit is None