diff --git a/messages.pot b/messages.pot index d1df246..7c648dd 100644 --- a/messages.pot +++ b/messages.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-04-03 23:59+0200\n" +"POT-Creation-Date: 2023-04-05 18:46+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -208,7 +208,7 @@ msgstr "" msgid "Legal notice" msgstr "" -#: project/forms/admin.py:13 project/templates/_macros.html:1397 +#: project/forms/admin.py:13 project/templates/_macros.html:1401 #: project/templates/layout.html:302 #: project/templates/widget/event_suggestion/create.html:204 #: project/views/admin_unit.py:73 project/views/root.py:69 @@ -239,74 +239,88 @@ msgstr "" msgid "Update user" msgstr "" -#: project/forms/admin.py:27 +#: project/forms/admin.py:26 project/templates/admin/delete_user.html:6 +msgid "Delete user" +msgstr "" + +#: project/forms/admin.py:27 project/forms/admin_unit.py:48 +#: project/forms/admin_unit_member.py:11 project/forms/admin_unit_member.py:23 +#: project/forms/admin_unit_member.py:28 project/forms/event.py:107 +#: project/forms/event_suggestion.py:38 project/forms/organizer.py:27 +#: project/templates/_macros.html:237 project/templates/_macros.html:1497 +#: project/templates/admin/admin.html:27 project/templates/admin/email.html:4 +#: project/templates/admin/email.html:66 project/templates/admin/users.html:19 +msgid "Email" +msgstr "" + +#: project/forms/admin.py:32 msgid "Incoming reference requests allowed" msgstr "" -#: project/forms/admin.py:28 +#: project/forms/admin.py:33 msgid "" "If set, other organizations can ask this organization to reference their " "event." msgstr "" -#: project/forms/admin.py:34 +#: project/forms/admin.py:39 msgid "Suggestions enabled" msgstr "" -#: project/forms/admin.py:35 +#: project/forms/admin.py:40 msgid "If set, the organization can work with suggestions." msgstr "" -#: project/forms/admin.py:39 +#: project/forms/admin.py:44 msgid "Create other organizations" msgstr "" -#: project/forms/admin.py:40 +#: project/forms/admin.py:45 msgid "If set, members of the organization can create other organizations." msgstr "" -#: project/forms/admin.py:46 +#: project/forms/admin.py:51 msgid "Invite other organizations" msgstr "" -#: project/forms/admin.py:47 +#: project/forms/admin.py:52 msgid "If set, members of the organization can invite other organizations." msgstr "" -#: project/forms/admin.py:53 +#: project/forms/admin.py:58 msgid "Verify other organizations" msgstr "" -#: project/forms/admin.py:54 +#: project/forms/admin.py:59 msgid "If set, members of the organization can verify other organizations." msgstr "" -#: project/forms/admin.py:59 project/templates/admin/update_admin_unit.html:4 +#: project/forms/admin.py:64 project/templates/admin/update_admin_unit.html:4 #: project/templates/admin/update_admin_unit.html:8 msgid "Update organization" msgstr "" -#: project/forms/admin.py:63 project/forms/admin.py:70 +#: project/forms/admin.py:68 project/forms/admin.py:75 msgid "Recipient" msgstr "" -#: project/forms/admin.py:65 +#: project/forms/admin.py:70 msgid "Send test mail synchronously" msgstr "" -#: project/forms/admin.py:72 project/forms/admin.py:78 +#: project/forms/admin.py:77 project/forms/admin.py:83 msgid "Test recipient" msgstr "" -#: project/forms/admin.py:73 +#: project/forms/admin.py:78 msgid "All users with enabled newsletter setting" msgstr "" -#: project/forms/admin.py:79 +#: project/forms/admin.py:84 msgid "Message" msgstr "" -#: project/forms/admin.py:80 +#: project/forms/admin.py:85 msgid "Send newsletter" msgstr "" @@ -359,7 +373,7 @@ msgstr "" msgid "The short name is used to create a unique identifier for your events" msgstr "" -#: project/forms/admin_unit.py:41 project/templates/_macros.html:1535 +#: project/forms/admin_unit.py:41 project/templates/_macros.html:1539 msgid "Short name must contain only letters numbers or underscore" msgstr "" @@ -369,16 +383,6 @@ msgstr "" msgid "Link URL" msgstr "" -#: project/forms/admin_unit.py:48 project/forms/admin_unit_member.py:11 -#: project/forms/admin_unit_member.py:23 project/forms/admin_unit_member.py:28 -#: project/forms/event.py:107 project/forms/event_suggestion.py:38 -#: project/forms/organizer.py:27 project/templates/_macros.html:237 -#: project/templates/_macros.html:1493 project/templates/admin/admin.html:27 -#: project/templates/admin/email.html:4 project/templates/admin/email.html:66 -#: project/templates/admin/users.html:19 -msgid "Email" -msgstr "" - #: project/forms/admin_unit.py:49 project/forms/event.py:108 #: project/forms/event_suggestion.py:31 project/forms/organizer.py:28 #: project/templates/_macros.html:290 @@ -584,16 +588,16 @@ msgstr "" msgid "All-day" msgstr "" -#: project/forms/event.py:54 project/templates/_macros.html:1715 +#: project/forms/event.py:54 project/templates/_macros.html:1719 #: project/templates/widget/event_suggestion/create.html:240 msgid "Recurring event" msgstr "" -#: project/forms/event.py:61 project/templates/_macros.html:1254 +#: project/forms/event.py:61 project/templates/_macros.html:1258 msgid "The start must be before the end." msgstr "" -#: project/forms/event.py:67 project/templates/_macros.html:1271 +#: project/forms/event.py:67 project/templates/_macros.html:1275 msgid "An event can last a maximum of 14 days." msgstr "" @@ -803,9 +807,9 @@ msgid "Invalid co-organizer." msgstr "" #: project/forms/event.py:286 project/forms/event.py:295 -#: project/forms/event.py:368 project/forms/event_suggestion.py:50 -#: project/templates/_macros.html:438 project/templates/_macros.html:601 -#: project/templates/event/create.html:284 +#: project/forms/event.py:368 project/forms/event.py:442 +#: project/forms/event_suggestion.py:50 project/templates/_macros.html:438 +#: project/templates/_macros.html:601 project/templates/event/create.html:284 #: project/templates/event/update.html:166 #: project/templates/event_place/create.html:31 #: project/templates/event_place/delete.html:13 @@ -922,7 +926,7 @@ msgstr "" msgid "Update event" msgstr "" -#: project/forms/event.py:423 project/templates/_macros.html:1226 +#: project/forms/event.py:423 project/templates/_macros.html:1230 #: project/templates/event/actions.html:66 #: project/templates/event/delete.html:6 msgid "Delete event" @@ -947,7 +951,7 @@ msgstr "" msgid "Category" msgstr "" -#: project/forms/event.py:442 +#: project/forms/event.py:445 msgid "Find events" msgstr "" @@ -1123,7 +1127,7 @@ msgstr "" msgid "Delete request" msgstr "" -#: project/forms/reference_request.py:28 project/templates/_macros.html:1409 +#: project/forms/reference_request.py:28 project/templates/_macros.html:1413 #: project/templates/event_suggestion/review_status.html:18 #: project/templates/reference_request/review_status.html:12 msgid "Review status" @@ -1248,12 +1252,12 @@ msgid "Date" msgstr "" #: project/templates/_macros.html:420 project/templates/_macros.html:579 -#: project/templates/_macros.html:1478 project/templates/event/actions.html:51 +#: project/templates/_macros.html:1482 project/templates/event/actions.html:51 msgid "Share" msgstr "" #: project/templates/_macros.html:424 project/templates/_macros.html:583 -#: project/templates/_macros.html:1508 +#: project/templates/_macros.html:1512 msgid "Add to calendar" msgstr "" @@ -1334,79 +1338,79 @@ msgstr "" msgid "Radius" msgstr "" -#: project/templates/_macros.html:1155 +#: project/templates/_macros.html:1159 msgid "Edit image" msgstr "" -#: project/templates/_macros.html:1176 +#: project/templates/_macros.html:1180 msgid "Close" msgstr "" -#: project/templates/_macros.html:1177 +#: project/templates/_macros.html:1181 msgid "Okay" msgstr "" -#: project/templates/_macros.html:1189 +#: project/templates/_macros.html:1193 msgid "Choose image file" msgstr "" -#: project/templates/_macros.html:1225 project/templates/event/actions.html:65 +#: project/templates/_macros.html:1229 project/templates/event/actions.html:65 #: project/templates/event/delete.html:12 msgid "Edit event" msgstr "" -#: project/templates/_macros.html:1228 project/templates/manage/events.html:66 +#: project/templates/_macros.html:1232 project/templates/manage/events.html:66 msgid "More" msgstr "" -#: project/templates/_macros.html:1275 +#: project/templates/_macros.html:1279 msgid "Please enter a valid time, between 00:00 and 23:59." msgstr "" -#: project/templates/_macros.html:1303 +#: project/templates/_macros.html:1307 #, python-format msgid "Just use %(term)s" msgstr "" -#: project/templates/_macros.html:1369 +#: project/templates/_macros.html:1373 msgid "Event suggestion" msgstr "" -#: project/templates/_macros.html:1487 +#: project/templates/_macros.html:1491 msgid "Link copied" msgstr "" -#: project/templates/_macros.html:1487 +#: project/templates/_macros.html:1491 msgid "Copy link" msgstr "" -#: project/templates/_macros.html:1517 +#: project/templates/_macros.html:1521 msgid "Google calendar" msgstr "" -#: project/templates/_macros.html:1519 +#: project/templates/_macros.html:1523 msgid "Apple calendar" msgstr "" -#: project/templates/_macros.html:1520 +#: project/templates/_macros.html:1524 msgid "Yahoo calendar" msgstr "" -#: project/templates/_macros.html:1521 +#: project/templates/_macros.html:1525 msgid "Other calendar" msgstr "" -#: project/templates/_macros.html:1716 +#: project/templates/_macros.html:1720 msgid "Remove event date" msgstr "" -#: project/templates/_macros.html:1745 project/templates/event/create.html:176 +#: project/templates/_macros.html:1749 project/templates/event/create.html:176 #: project/templates/event/update.html:99 #: project/templates/widget/event_suggestion/create.html:129 msgid "Enter organizer" msgstr "" -#: project/templates/_macros.html:1769 +#: project/templates/_macros.html:1773 msgid "Enter list name" msgstr "" @@ -1600,7 +1604,7 @@ msgid "Users" msgstr "" #: project/templates/admin/admin_units.html:27 -#: project/templates/admin/users.html:27 +#: project/templates/admin/users.html:34 #: project/templates/manage/events.html:60 #: project/templates/manage/members.html:35 #: project/templates/manage/organizers.html:23 @@ -1611,7 +1615,11 @@ msgstr "" msgid "Edit" msgstr "" -#: project/templates/admin/email.html:47 project/views/admin.py:121 +#: project/templates/admin/delete_user.html:13 +msgid "User" +msgstr "" + +#: project/templates/admin/email.html:47 project/views/admin.py:123 msgid "Mail sent successfully" msgstr "" @@ -1627,6 +1635,17 @@ 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 @@ -1927,16 +1946,6 @@ msgstr "" msgid "View" msgstr "" -#: 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/manage/events.html:62 msgid "Duplicate" msgstr "" @@ -2095,29 +2104,37 @@ msgstr "" msgid "Preview" msgstr "" -#: project/views/admin.py:57 +#: project/views/admin.py:59 msgid "Organization successfully updated" msgstr "" -#: project/views/admin.py:81 project/views/manage.py:361 +#: project/views/admin.py:83 project/views/manage.py:371 #: project/views/user.py:28 msgid "Settings successfully updated" msgstr "" -#: project/views/admin.py:110 +#: project/views/admin.py:112 #, python-format msgid "Test mail from %(site_name)s" msgstr "" -#: project/views/admin.py:149 +#: project/views/admin.py:151 #, python-format msgid "Newsletter from %(site_name)s" msgstr "" -#: project/views/admin.py:199 +#: project/views/admin.py:201 msgid "User successfully updated" msgstr "" +#: project/views/admin.py:221 +msgid "Entered email does not match user email" +msgstr "" + +#: project/views/admin.py:226 +msgid "User successfully deleted" +msgstr "" + #: project/views/admin_unit.py:69 msgid "" "Organizations cannot currently be created. The project is in a closed " diff --git a/migrations/versions/421660a4a792_.py b/migrations/versions/421660a4a792_.py new file mode 100644 index 0000000..0df40e1 --- /dev/null +++ b/migrations/versions/421660a4a792_.py @@ -0,0 +1,26 @@ +"""empty message + +Revision ID: 421660a4a792 +Revises: 47c334ba5b86 +Create Date: 2023-04-05 18:09:03.913610 + +""" +import sqlalchemy as sa +import sqlalchemy_utils +from alembic import op + +from project import dbtypes + +# revision identifiers, used by Alembic. +revision = "421660a4a792" +down_revision = "47c334ba5b86" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column("user", sa.Column("created_at", sa.DateTime(), nullable=True)) + + +def downgrade(): + op.drop_column("user", "created_at") diff --git a/project/forms/admin.py b/project/forms/admin.py index 2899fa8..758b04f 100644 --- a/project/forms/admin.py +++ b/project/forms/admin.py @@ -22,6 +22,11 @@ class UpdateUserForm(FlaskForm): submit = SubmitField(lazy_gettext("Update user")) +class DeleteUserForm(FlaskForm): + submit = SubmitField(lazy_gettext("Delete user")) + email = EmailField(lazy_gettext("Email"), validators=[DataRequired()]) + + class UpdateAdminUnitForm(FlaskForm): incoming_reference_requests_allowed = BooleanField( lazy_gettext("Incoming reference requests allowed"), diff --git a/project/models/user.py b/project/models/user.py index eeb1dff..ef7c206 100644 --- a/project/models/user.py +++ b/project/models/user.py @@ -1,3 +1,5 @@ +import datetime + from flask_dance.consumer.storage.sqla import OAuthConsumerMixin from flask_security import RoleMixin, UserMixin from sqlalchemy import ( @@ -62,6 +64,7 @@ class User(db.Model, UserMixin): server_default="1", ) ) + created_at = Column(DateTime, default=datetime.datetime.utcnow) def get_user_id(self): return self.id diff --git a/project/templates/admin/delete_user.html b/project/templates/admin/delete_user.html new file mode 100644 index 0000000..394ae40 --- /dev/null +++ b/project/templates/admin/delete_user.html @@ -0,0 +1,24 @@ +{% extends "layout.html" %} +{% from "_macros.html" import render_field_with_errors, render_field %} + +{% block content %} + +

{{ _('Delete user') }} "{{ user.email }}"

+ +
+ {{ form.hidden_tag() }} + +
+
+ {{ _('User') }} +
+
+ {{ render_field_with_errors(form.email) }} +
+
+ + {{ render_field(form.submit) }} + +
+ +{% endblock %} diff --git a/project/templates/admin/users.html b/project/templates/admin/users.html index a3c89db..321e22c 100644 --- a/project/templates/admin/users.html +++ b/project/templates/admin/users.html @@ -17,6 +17,9 @@ {{ _('Email') }} + created_at + confirmed_at + current_login_at @@ -24,7 +27,13 @@ {% for user in users %} {{ user.email }} - {{ _('Edit') }} + {% if user.created_at %}{{ user.created_at | dateformat }}{% endif %} + {% if user.confirmed_at %}{{ user.confirmed_at | dateformat }}{% endif %} + {% if user.current_login_at %}{{ user.current_login_at | dateformat }}{% endif %} + + {{ _('Edit') }} + {{ _('Delete') }} + {% endfor %} diff --git a/project/translations/de/LC_MESSAGES/messages.mo b/project/translations/de/LC_MESSAGES/messages.mo index b606a7d..42ed4aa 100644 Binary files a/project/translations/de/LC_MESSAGES/messages.mo and b/project/translations/de/LC_MESSAGES/messages.mo differ diff --git a/project/translations/de/LC_MESSAGES/messages.po b/project/translations/de/LC_MESSAGES/messages.po index 5c51c79..765cf5f 100644 --- a/project/translations/de/LC_MESSAGES/messages.po +++ b/project/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: 2023-04-03 23:59+0200\n" +"POT-Creation-Date: 2023-04-05 18:46+0200\n" "PO-Revision-Date: 2020-06-07 18:51+0200\n" "Last-Translator: FULL NAME \n" "Language: de\n" @@ -209,7 +209,7 @@ msgstr "Nutzungsbedingungen" msgid "Legal notice" msgstr "Impressum" -#: project/forms/admin.py:13 project/templates/_macros.html:1397 +#: project/forms/admin.py:13 project/templates/_macros.html:1401 #: project/templates/layout.html:302 #: project/templates/widget/event_suggestion/create.html:204 #: project/views/admin_unit.py:73 project/views/root.py:69 @@ -240,11 +240,25 @@ msgstr "Rollen" msgid "Update user" msgstr "Nutzer aktualisieren" -#: project/forms/admin.py:27 +#: project/forms/admin.py:26 project/templates/admin/delete_user.html:6 +msgid "Delete user" +msgstr "Nutzer löschen" + +#: project/forms/admin.py:27 project/forms/admin_unit.py:48 +#: project/forms/admin_unit_member.py:11 project/forms/admin_unit_member.py:23 +#: project/forms/admin_unit_member.py:28 project/forms/event.py:107 +#: project/forms/event_suggestion.py:38 project/forms/organizer.py:27 +#: project/templates/_macros.html:237 project/templates/_macros.html:1497 +#: project/templates/admin/admin.html:27 project/templates/admin/email.html:4 +#: project/templates/admin/email.html:66 project/templates/admin/users.html:19 +msgid "Email" +msgstr "Email" + +#: project/forms/admin.py:32 msgid "Incoming reference requests allowed" msgstr "Eingehende Empfehlungsanfragen erlauben" -#: project/forms/admin.py:28 +#: project/forms/admin.py:33 msgid "" "If set, other organizations can ask this organization to reference their " "event." @@ -252,70 +266,70 @@ msgstr "" "Wenn gesetzt, können andere Organisationen diese Organisation bitten, " "deren Veranstaltungen zu empfehlen." -#: project/forms/admin.py:34 +#: project/forms/admin.py:39 msgid "Suggestions enabled" msgstr "Vorschläge aktiv" -#: project/forms/admin.py:35 +#: project/forms/admin.py:40 msgid "If set, the organization can work with suggestions." msgstr "Wenn gesetzt, kann die Organisation mit Vorschlägen arbeiten." -#: project/forms/admin.py:39 +#: project/forms/admin.py:44 msgid "Create other organizations" msgstr "Andere Organisationen erstellen" -#: project/forms/admin.py:40 +#: project/forms/admin.py:45 msgid "If set, members of the organization can create other organizations." msgstr "" "Wenn gesetzt, können Mitglieder der Organisation andere Organisationen " "erstellen." -#: project/forms/admin.py:46 +#: project/forms/admin.py:51 msgid "Invite other organizations" msgstr "Andere Organisationen einladen" -#: project/forms/admin.py:47 +#: project/forms/admin.py:52 msgid "If set, members of the organization can invite other organizations." msgstr "" "Wenn gesetzt, können Mitglieder der Organisation andere Organisationen " "einladen." -#: project/forms/admin.py:53 +#: project/forms/admin.py:58 msgid "Verify other organizations" msgstr "Andere Organisationen verifizieren" -#: project/forms/admin.py:54 +#: project/forms/admin.py:59 msgid "If set, members of the organization can verify other organizations." msgstr "" "Wenn gesetzt, können Mitglieder der Organisation andere Organisationen " "verifizieren." -#: project/forms/admin.py:59 project/templates/admin/update_admin_unit.html:4 +#: project/forms/admin.py:64 project/templates/admin/update_admin_unit.html:4 #: project/templates/admin/update_admin_unit.html:8 msgid "Update organization" msgstr "Organisation aktualisieren" -#: project/forms/admin.py:63 project/forms/admin.py:70 +#: project/forms/admin.py:68 project/forms/admin.py:75 msgid "Recipient" msgstr "Empfänger" -#: project/forms/admin.py:65 +#: project/forms/admin.py:70 msgid "Send test mail synchronously" msgstr "Test-Mail synchron senden" -#: project/forms/admin.py:72 project/forms/admin.py:78 +#: project/forms/admin.py:77 project/forms/admin.py:83 msgid "Test recipient" msgstr "Test-Empfänger" -#: project/forms/admin.py:73 +#: project/forms/admin.py:78 msgid "All users with enabled newsletter setting" msgstr "Alle Nutzer mit aktiviertem Newsletter" -#: project/forms/admin.py:79 +#: project/forms/admin.py:84 msgid "Message" msgstr "Nachricht" -#: project/forms/admin.py:80 +#: project/forms/admin.py:85 msgid "Send newsletter" msgstr "Newsletter senden" @@ -371,7 +385,7 @@ msgstr "" "eindeutig zu identifizieren. Der Kurzname darf nur Buchstaben, Nummern " "und Unterstriche enthalten." -#: project/forms/admin_unit.py:41 project/templates/_macros.html:1535 +#: project/forms/admin_unit.py:41 project/templates/_macros.html:1539 msgid "Short name must contain only letters numbers or underscore" msgstr "Der Kurzname darf nur Buchstaben, Nummern und Unterstriche enthalten" @@ -381,16 +395,6 @@ msgstr "Der Kurzname darf nur Buchstaben, Nummern und Unterstriche enthalten" msgid "Link URL" msgstr "Link URL" -#: project/forms/admin_unit.py:48 project/forms/admin_unit_member.py:11 -#: project/forms/admin_unit_member.py:23 project/forms/admin_unit_member.py:28 -#: project/forms/event.py:107 project/forms/event_suggestion.py:38 -#: project/forms/organizer.py:27 project/templates/_macros.html:237 -#: project/templates/_macros.html:1493 project/templates/admin/admin.html:27 -#: project/templates/admin/email.html:4 project/templates/admin/email.html:66 -#: project/templates/admin/users.html:19 -msgid "Email" -msgstr "Email" - #: project/forms/admin_unit.py:49 project/forms/event.py:108 #: project/forms/event_suggestion.py:31 project/forms/organizer.py:28 #: project/templates/_macros.html:290 @@ -607,16 +611,16 @@ msgstr "Gib an, wann der Termin endet. Ein Termin darf maximal 14 Tage dauern." msgid "All-day" msgstr "Ganztägig" -#: project/forms/event.py:54 project/templates/_macros.html:1715 +#: project/forms/event.py:54 project/templates/_macros.html:1719 #: project/templates/widget/event_suggestion/create.html:240 msgid "Recurring event" msgstr "Serientermin" -#: project/forms/event.py:61 project/templates/_macros.html:1254 +#: project/forms/event.py:61 project/templates/_macros.html:1258 msgid "The start must be before the end." msgstr "Der Start muss vor dem Ende sein." -#: project/forms/event.py:67 project/templates/_macros.html:1271 +#: project/forms/event.py:67 project/templates/_macros.html:1275 msgid "An event can last a maximum of 14 days." msgstr "Eine Veranstaltung darf maximal 14 Tage dauern." @@ -843,9 +847,9 @@ msgid "Invalid co-organizer." msgstr "Ungültiger Mitveranstalter." #: project/forms/event.py:286 project/forms/event.py:295 -#: project/forms/event.py:368 project/forms/event_suggestion.py:50 -#: project/templates/_macros.html:438 project/templates/_macros.html:601 -#: project/templates/event/create.html:284 +#: project/forms/event.py:368 project/forms/event.py:442 +#: project/forms/event_suggestion.py:50 project/templates/_macros.html:438 +#: project/templates/_macros.html:601 project/templates/event/create.html:284 #: project/templates/event/update.html:166 #: project/templates/event_place/create.html:31 #: project/templates/event_place/delete.html:13 @@ -966,7 +970,7 @@ msgstr "Wähle den öffentlichen Status der Veranstaltung." msgid "Update event" msgstr "Veranstaltung aktualisieren" -#: project/forms/event.py:423 project/templates/_macros.html:1226 +#: project/forms/event.py:423 project/templates/_macros.html:1230 #: project/templates/event/actions.html:66 #: project/templates/event/delete.html:6 msgid "Delete event" @@ -991,7 +995,7 @@ msgstr "Stichwort" msgid "Category" msgstr "Kategorie" -#: project/forms/event.py:442 +#: project/forms/event.py:445 msgid "Find events" msgstr "Veranstaltungen finden" @@ -1171,7 +1175,7 @@ msgstr "Anfrage speichern" msgid "Delete request" msgstr "Anfrage löschen" -#: project/forms/reference_request.py:28 project/templates/_macros.html:1409 +#: project/forms/reference_request.py:28 project/templates/_macros.html:1413 #: project/templates/event_suggestion/review_status.html:18 #: project/templates/reference_request/review_status.html:12 msgid "Review status" @@ -1230,7 +1234,11 @@ msgstr "" #: project/forms/security.py:43 msgid "login_confirmation_required" -msgstr "Beachte, dass du deine E-Mail-Adresse bestätigen muss. Dazu wird dir nach der Registrierung eine Bestätigungsanleitung an deine E-Mail-Adresse geschickt. Bitte beachte, dass es einige Minuten dauern kann, bis die Mail bei dir eintrifft. Schaue zur Sicherheit auch im Spam-Ordner nach." +msgstr "" +"Beachte, dass du deine E-Mail-Adresse bestätigen muss. Dazu wird dir nach" +" der Registrierung eine Bestätigungsanleitung an deine E-Mail-Adresse " +"geschickt. Bitte beachte, dass es einige Minuten dauern kann, bis die " +"Mail bei dir eintrifft. Schaue zur Sicherheit auch im Spam-Ordner nach." #: project/forms/security.py:53 msgid "Allow" @@ -1299,12 +1307,12 @@ msgid "Date" msgstr "Datum" #: project/templates/_macros.html:420 project/templates/_macros.html:579 -#: project/templates/_macros.html:1478 project/templates/event/actions.html:51 +#: project/templates/_macros.html:1482 project/templates/event/actions.html:51 msgid "Share" msgstr "Teilen" #: project/templates/_macros.html:424 project/templates/_macros.html:583 -#: project/templates/_macros.html:1508 +#: project/templates/_macros.html:1512 msgid "Add to calendar" msgstr "Zum Kalender" @@ -1387,79 +1395,79 @@ msgstr "Erste" msgid "Radius" msgstr "Umkreis" -#: project/templates/_macros.html:1155 +#: project/templates/_macros.html:1159 msgid "Edit image" msgstr "Bild bearbeiten" -#: project/templates/_macros.html:1176 +#: project/templates/_macros.html:1180 msgid "Close" msgstr "Schließen" -#: project/templates/_macros.html:1177 +#: project/templates/_macros.html:1181 msgid "Okay" msgstr "OK" -#: project/templates/_macros.html:1189 +#: project/templates/_macros.html:1193 msgid "Choose image file" msgstr "Bild-Datei auswählen" -#: project/templates/_macros.html:1225 project/templates/event/actions.html:65 +#: project/templates/_macros.html:1229 project/templates/event/actions.html:65 #: project/templates/event/delete.html:12 msgid "Edit event" msgstr "Veranstaltung bearbeiten" -#: project/templates/_macros.html:1228 project/templates/manage/events.html:66 +#: project/templates/_macros.html:1232 project/templates/manage/events.html:66 msgid "More" msgstr "Mehr" -#: project/templates/_macros.html:1275 +#: project/templates/_macros.html:1279 msgid "Please enter a valid time, between 00:00 and 23:59." msgstr "Bitte gib eine gültige Uhrzeit zwischen 00:00 und 23:59 ein." -#: project/templates/_macros.html:1303 +#: project/templates/_macros.html:1307 #, python-format msgid "Just use %(term)s" msgstr "Verwende einfach %(term)s" -#: project/templates/_macros.html:1369 +#: project/templates/_macros.html:1373 msgid "Event suggestion" msgstr "Veranstaltungsvorschlag" -#: project/templates/_macros.html:1487 +#: project/templates/_macros.html:1491 msgid "Link copied" msgstr "Link kopiert" -#: project/templates/_macros.html:1487 +#: project/templates/_macros.html:1491 msgid "Copy link" msgstr "Link kopieren" -#: project/templates/_macros.html:1517 +#: project/templates/_macros.html:1521 msgid "Google calendar" msgstr "Google Kalender" -#: project/templates/_macros.html:1519 +#: project/templates/_macros.html:1523 msgid "Apple calendar" msgstr "Apple Kalender" -#: project/templates/_macros.html:1520 +#: project/templates/_macros.html:1524 msgid "Yahoo calendar" msgstr "Yahoo Kalender" -#: project/templates/_macros.html:1521 +#: project/templates/_macros.html:1525 msgid "Other calendar" msgstr "Anderer Kalender" -#: project/templates/_macros.html:1716 +#: project/templates/_macros.html:1720 msgid "Remove event date" msgstr "Termin entfernen" -#: project/templates/_macros.html:1745 project/templates/event/create.html:176 +#: project/templates/_macros.html:1749 project/templates/event/create.html:176 #: project/templates/event/update.html:99 #: project/templates/widget/event_suggestion/create.html:129 msgid "Enter organizer" msgstr "Veranstalter eingeben" -#: project/templates/_macros.html:1769 +#: project/templates/_macros.html:1773 msgid "Enter list name" msgstr "Listenname eingeben" @@ -1650,10 +1658,10 @@ msgstr "OAuth2 Clients" #: project/templates/admin/admin.html:23 project/templates/admin/users.html:4 #: project/templates/admin/users.html:11 msgid "Users" -msgstr "Benutzer" +msgstr "Nutzer" #: project/templates/admin/admin_units.html:27 -#: project/templates/admin/users.html:27 +#: project/templates/admin/users.html:34 #: project/templates/manage/events.html:60 #: project/templates/manage/members.html:35 #: project/templates/manage/organizers.html:23 @@ -1664,7 +1672,11 @@ msgstr "Benutzer" msgid "Edit" msgstr "Bearbeiten" -#: project/templates/admin/email.html:47 project/views/admin.py:121 +#: project/templates/admin/delete_user.html:13 +msgid "User" +msgstr "Nutzer" + +#: project/templates/admin/email.html:47 project/views/admin.py:123 msgid "Mail sent successfully" msgstr "Mail erfolgreich gesendet" @@ -1680,6 +1692,17 @@ 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 @@ -1989,16 +2012,6 @@ msgstr "Organisation verifizieren" msgid "View" msgstr "Anzeigen" -#: 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/manage/events.html:62 msgid "Duplicate" msgstr "Duplizieren" @@ -2159,29 +2172,37 @@ msgstr "Optionale Details" msgid "Preview" msgstr "Vorschau" -#: project/views/admin.py:57 +#: project/views/admin.py:59 msgid "Organization successfully updated" msgstr "Organisation erfolgreich aktualisiert" -#: project/views/admin.py:81 project/views/manage.py:361 +#: project/views/admin.py:83 project/views/manage.py:371 #: project/views/user.py:28 msgid "Settings successfully updated" msgstr "Einstellungen erfolgreich aktualisiert" -#: project/views/admin.py:110 +#: project/views/admin.py:112 #, python-format msgid "Test mail from %(site_name)s" msgstr "Test-Mail von %(site_name)s" -#: project/views/admin.py:149 +#: project/views/admin.py:151 #, python-format msgid "Newsletter from %(site_name)s" msgstr "Newsletter von %(site_name)s" -#: project/views/admin.py:199 +#: project/views/admin.py:201 msgid "User successfully updated" msgstr "Nutzer erfolgreich aktualisiert" +#: project/views/admin.py:221 +msgid "Entered email does not match user email" +msgstr "Die eingegebene Email passt nicht zur Email des Nutzers" + +#: project/views/admin.py:226 +msgid "User successfully deleted" +msgstr "Nutzer erfolgreich gelöscht" + #: project/views/admin_unit.py:69 msgid "" "Organizations cannot currently be created. The project is in a closed " diff --git a/project/translations/en/LC_MESSAGES/messages.mo b/project/translations/en/LC_MESSAGES/messages.mo index 73d5467..10b72dd 100644 Binary files a/project/translations/en/LC_MESSAGES/messages.mo and b/project/translations/en/LC_MESSAGES/messages.mo differ diff --git a/project/translations/en/LC_MESSAGES/messages.po b/project/translations/en/LC_MESSAGES/messages.po index bb0c79b..80f3215 100644 --- a/project/translations/en/LC_MESSAGES/messages.po +++ b/project/translations/en/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: 2023-04-03 23:59+0200\n" +"POT-Creation-Date: 2023-04-05 18:46+0200\n" "PO-Revision-Date: 2021-04-30 15:04+0200\n" "Last-Translator: FULL NAME \n" "Language: en\n" @@ -209,7 +209,7 @@ msgstr "" msgid "Legal notice" msgstr "" -#: project/forms/admin.py:13 project/templates/_macros.html:1397 +#: project/forms/admin.py:13 project/templates/_macros.html:1401 #: project/templates/layout.html:302 #: project/templates/widget/event_suggestion/create.html:204 #: project/views/admin_unit.py:73 project/views/root.py:69 @@ -240,74 +240,88 @@ msgstr "" msgid "Update user" msgstr "" -#: project/forms/admin.py:27 +#: project/forms/admin.py:26 project/templates/admin/delete_user.html:6 +msgid "Delete user" +msgstr "" + +#: project/forms/admin.py:27 project/forms/admin_unit.py:48 +#: project/forms/admin_unit_member.py:11 project/forms/admin_unit_member.py:23 +#: project/forms/admin_unit_member.py:28 project/forms/event.py:107 +#: project/forms/event_suggestion.py:38 project/forms/organizer.py:27 +#: project/templates/_macros.html:237 project/templates/_macros.html:1497 +#: project/templates/admin/admin.html:27 project/templates/admin/email.html:4 +#: project/templates/admin/email.html:66 project/templates/admin/users.html:19 +msgid "Email" +msgstr "" + +#: project/forms/admin.py:32 msgid "Incoming reference requests allowed" msgstr "" -#: project/forms/admin.py:28 +#: project/forms/admin.py:33 msgid "" "If set, other organizations can ask this organization to reference their " "event." msgstr "" -#: project/forms/admin.py:34 +#: project/forms/admin.py:39 msgid "Suggestions enabled" msgstr "" -#: project/forms/admin.py:35 +#: project/forms/admin.py:40 msgid "If set, the organization can work with suggestions." msgstr "" -#: project/forms/admin.py:39 +#: project/forms/admin.py:44 msgid "Create other organizations" msgstr "" -#: project/forms/admin.py:40 +#: project/forms/admin.py:45 msgid "If set, members of the organization can create other organizations." msgstr "" -#: project/forms/admin.py:46 +#: project/forms/admin.py:51 msgid "Invite other organizations" msgstr "" -#: project/forms/admin.py:47 +#: project/forms/admin.py:52 msgid "If set, members of the organization can invite other organizations." msgstr "" -#: project/forms/admin.py:53 +#: project/forms/admin.py:58 msgid "Verify other organizations" msgstr "" -#: project/forms/admin.py:54 +#: project/forms/admin.py:59 msgid "If set, members of the organization can verify other organizations." msgstr "" -#: project/forms/admin.py:59 project/templates/admin/update_admin_unit.html:4 +#: project/forms/admin.py:64 project/templates/admin/update_admin_unit.html:4 #: project/templates/admin/update_admin_unit.html:8 msgid "Update organization" msgstr "" -#: project/forms/admin.py:63 project/forms/admin.py:70 +#: project/forms/admin.py:68 project/forms/admin.py:75 msgid "Recipient" msgstr "" -#: project/forms/admin.py:65 +#: project/forms/admin.py:70 msgid "Send test mail synchronously" msgstr "" -#: project/forms/admin.py:72 project/forms/admin.py:78 +#: project/forms/admin.py:77 project/forms/admin.py:83 msgid "Test recipient" msgstr "" -#: project/forms/admin.py:73 +#: project/forms/admin.py:78 msgid "All users with enabled newsletter setting" msgstr "" -#: project/forms/admin.py:79 +#: project/forms/admin.py:84 msgid "Message" msgstr "" -#: project/forms/admin.py:80 +#: project/forms/admin.py:85 msgid "Send newsletter" msgstr "" @@ -360,7 +374,7 @@ msgstr "" msgid "The short name is used to create a unique identifier for your events" msgstr "" -#: project/forms/admin_unit.py:41 project/templates/_macros.html:1535 +#: project/forms/admin_unit.py:41 project/templates/_macros.html:1539 msgid "Short name must contain only letters numbers or underscore" msgstr "" @@ -370,16 +384,6 @@ msgstr "" msgid "Link URL" msgstr "" -#: project/forms/admin_unit.py:48 project/forms/admin_unit_member.py:11 -#: project/forms/admin_unit_member.py:23 project/forms/admin_unit_member.py:28 -#: project/forms/event.py:107 project/forms/event_suggestion.py:38 -#: project/forms/organizer.py:27 project/templates/_macros.html:237 -#: project/templates/_macros.html:1493 project/templates/admin/admin.html:27 -#: project/templates/admin/email.html:4 project/templates/admin/email.html:66 -#: project/templates/admin/users.html:19 -msgid "Email" -msgstr "" - #: project/forms/admin_unit.py:49 project/forms/event.py:108 #: project/forms/event_suggestion.py:31 project/forms/organizer.py:28 #: project/templates/_macros.html:290 @@ -585,16 +589,16 @@ msgstr "" msgid "All-day" msgstr "" -#: project/forms/event.py:54 project/templates/_macros.html:1715 +#: project/forms/event.py:54 project/templates/_macros.html:1719 #: project/templates/widget/event_suggestion/create.html:240 msgid "Recurring event" msgstr "" -#: project/forms/event.py:61 project/templates/_macros.html:1254 +#: project/forms/event.py:61 project/templates/_macros.html:1258 msgid "The start must be before the end." msgstr "" -#: project/forms/event.py:67 project/templates/_macros.html:1271 +#: project/forms/event.py:67 project/templates/_macros.html:1275 msgid "An event can last a maximum of 14 days." msgstr "" @@ -804,9 +808,9 @@ msgid "Invalid co-organizer." msgstr "" #: project/forms/event.py:286 project/forms/event.py:295 -#: project/forms/event.py:368 project/forms/event_suggestion.py:50 -#: project/templates/_macros.html:438 project/templates/_macros.html:601 -#: project/templates/event/create.html:284 +#: project/forms/event.py:368 project/forms/event.py:442 +#: project/forms/event_suggestion.py:50 project/templates/_macros.html:438 +#: project/templates/_macros.html:601 project/templates/event/create.html:284 #: project/templates/event/update.html:166 #: project/templates/event_place/create.html:31 #: project/templates/event_place/delete.html:13 @@ -923,7 +927,7 @@ msgstr "" msgid "Update event" msgstr "" -#: project/forms/event.py:423 project/templates/_macros.html:1226 +#: project/forms/event.py:423 project/templates/_macros.html:1230 #: project/templates/event/actions.html:66 #: project/templates/event/delete.html:6 msgid "Delete event" @@ -948,7 +952,7 @@ msgstr "" msgid "Category" msgstr "" -#: project/forms/event.py:442 +#: project/forms/event.py:445 msgid "Find events" msgstr "" @@ -1124,7 +1128,7 @@ msgstr "" msgid "Delete request" msgstr "" -#: project/forms/reference_request.py:28 project/templates/_macros.html:1409 +#: project/forms/reference_request.py:28 project/templates/_macros.html:1413 #: project/templates/event_suggestion/review_status.html:18 #: project/templates/reference_request/review_status.html:12 msgid "Review status" @@ -1183,7 +1187,11 @@ msgstr "" #: project/forms/security.py:43 msgid "login_confirmation_required" -msgstr "Note that you will need to confirm your email address. Confirmation instructions will be sent to your email address after registration. Please note that it may take a few minutes for the email to reach you. To be on the safe side, also check the spam folder." +msgstr "" +"Note that you will need to confirm your email address. Confirmation " +"instructions will be sent to your email address after registration. " +"Please note that it may take a few minutes for the email to reach you. To" +" be on the safe side, also check the spam folder." #: project/forms/security.py:53 msgid "Allow" @@ -1252,12 +1260,12 @@ msgid "Date" msgstr "" #: project/templates/_macros.html:420 project/templates/_macros.html:579 -#: project/templates/_macros.html:1478 project/templates/event/actions.html:51 +#: project/templates/_macros.html:1482 project/templates/event/actions.html:51 msgid "Share" msgstr "" #: project/templates/_macros.html:424 project/templates/_macros.html:583 -#: project/templates/_macros.html:1508 +#: project/templates/_macros.html:1512 msgid "Add to calendar" msgstr "" @@ -1338,79 +1346,79 @@ msgstr "" msgid "Radius" msgstr "" -#: project/templates/_macros.html:1155 +#: project/templates/_macros.html:1159 msgid "Edit image" msgstr "" -#: project/templates/_macros.html:1176 +#: project/templates/_macros.html:1180 msgid "Close" msgstr "" -#: project/templates/_macros.html:1177 +#: project/templates/_macros.html:1181 msgid "Okay" msgstr "" -#: project/templates/_macros.html:1189 +#: project/templates/_macros.html:1193 msgid "Choose image file" msgstr "" -#: project/templates/_macros.html:1225 project/templates/event/actions.html:65 +#: project/templates/_macros.html:1229 project/templates/event/actions.html:65 #: project/templates/event/delete.html:12 msgid "Edit event" msgstr "" -#: project/templates/_macros.html:1228 project/templates/manage/events.html:66 +#: project/templates/_macros.html:1232 project/templates/manage/events.html:66 msgid "More" msgstr "" -#: project/templates/_macros.html:1275 +#: project/templates/_macros.html:1279 msgid "Please enter a valid time, between 00:00 and 23:59." msgstr "" -#: project/templates/_macros.html:1303 +#: project/templates/_macros.html:1307 #, python-format msgid "Just use %(term)s" msgstr "" -#: project/templates/_macros.html:1369 +#: project/templates/_macros.html:1373 msgid "Event suggestion" msgstr "" -#: project/templates/_macros.html:1487 +#: project/templates/_macros.html:1491 msgid "Link copied" msgstr "" -#: project/templates/_macros.html:1487 +#: project/templates/_macros.html:1491 msgid "Copy link" msgstr "" -#: project/templates/_macros.html:1517 +#: project/templates/_macros.html:1521 msgid "Google calendar" msgstr "" -#: project/templates/_macros.html:1519 +#: project/templates/_macros.html:1523 msgid "Apple calendar" msgstr "" -#: project/templates/_macros.html:1520 +#: project/templates/_macros.html:1524 msgid "Yahoo calendar" msgstr "" -#: project/templates/_macros.html:1521 +#: project/templates/_macros.html:1525 msgid "Other calendar" msgstr "" -#: project/templates/_macros.html:1716 +#: project/templates/_macros.html:1720 msgid "Remove event date" msgstr "" -#: project/templates/_macros.html:1745 project/templates/event/create.html:176 +#: project/templates/_macros.html:1749 project/templates/event/create.html:176 #: project/templates/event/update.html:99 #: project/templates/widget/event_suggestion/create.html:129 msgid "Enter organizer" msgstr "" -#: project/templates/_macros.html:1769 +#: project/templates/_macros.html:1773 msgid "Enter list name" msgstr "" @@ -1604,7 +1612,7 @@ msgid "Users" msgstr "" #: project/templates/admin/admin_units.html:27 -#: project/templates/admin/users.html:27 +#: project/templates/admin/users.html:34 #: project/templates/manage/events.html:60 #: project/templates/manage/members.html:35 #: project/templates/manage/organizers.html:23 @@ -1615,7 +1623,11 @@ msgstr "" msgid "Edit" msgstr "" -#: project/templates/admin/email.html:47 project/views/admin.py:121 +#: project/templates/admin/delete_user.html:13 +msgid "User" +msgstr "" + +#: project/templates/admin/email.html:47 project/views/admin.py:123 msgid "Mail sent successfully" msgstr "" @@ -1631,6 +1643,17 @@ 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 @@ -1931,16 +1954,6 @@ msgstr "" msgid "View" msgstr "" -#: 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/manage/events.html:62 msgid "Duplicate" msgstr "" @@ -2099,29 +2112,37 @@ msgstr "" msgid "Preview" msgstr "" -#: project/views/admin.py:57 +#: project/views/admin.py:59 msgid "Organization successfully updated" msgstr "" -#: project/views/admin.py:81 project/views/manage.py:361 +#: project/views/admin.py:83 project/views/manage.py:371 #: project/views/user.py:28 msgid "Settings successfully updated" msgstr "" -#: project/views/admin.py:110 +#: project/views/admin.py:112 #, python-format msgid "Test mail from %(site_name)s" msgstr "" -#: project/views/admin.py:149 +#: project/views/admin.py:151 #, python-format msgid "Newsletter from %(site_name)s" msgstr "" -#: project/views/admin.py:199 +#: project/views/admin.py:201 msgid "User successfully updated" msgstr "" +#: project/views/admin.py:221 +msgid "Entered email does not match user email" +msgstr "" + +#: project/views/admin.py:226 +msgid "User successfully deleted" +msgstr "" + #: project/views/admin_unit.py:69 msgid "" "Organizations cannot currently be created. The project is in a closed " diff --git a/project/views/admin.py b/project/views/admin.py index e36c89e..c01c395 100644 --- a/project/views/admin.py +++ b/project/views/admin.py @@ -5,12 +5,13 @@ from flask_security import roles_required from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.sql import func -from project import app, celery, db +from project import app, celery, db, user_datastore from project.base_tasks import send_mail_task from project.forms.admin import ( AdminNewsletterForm, AdminSettingsForm, AdminTestEmailForm, + DeleteUserForm, UpdateAdminUnitForm, UpdateUserForm, ) @@ -21,6 +22,7 @@ from project.views.utils import ( flash_errors, get_pagination_urls, handleSqlError, + non_match_for_deletion, send_mail, ) @@ -205,3 +207,28 @@ def admin_user_update(id): form.roles.data = [c.name for c in user.roles] return render_template("admin/update_user.html", user=user, form=form) + + +@app.route("/admin/user//delete", methods=("GET", "POST")) +@roles_required("admin") +def admin_user_delete(id): + user = User.query.get_or_404(id) + + form = DeleteUserForm() + + if form.validate_on_submit(): + if non_match_for_deletion(form.email.data, user.email): + flash(gettext("Entered email does not match user email"), "danger") + else: + try: + user_datastore.delete_user(user) + db.session.commit() + flash(gettext("User successfully deleted"), "success") + return redirect(url_for("admin_users")) + except SQLAlchemyError as e: + db.session.rollback() + flash(handleSqlError(e), "danger") + else: + flash_errors(form) + + return render_template("admin/delete_user.html", form=form, user=user) diff --git a/tests/views/test_admin.py b/tests/views/test_admin.py index 37aec2a..04da2a7 100644 --- a/tests/views/test_admin.py +++ b/tests/views/test_admin.py @@ -150,6 +150,50 @@ def test_admin_user_update(client, seeder, utils, app, mocker, db, db_error): assert any(r.name == "admin" for r in user.roles) +@pytest.mark.parametrize("db_error", [True, False]) +@pytest.mark.parametrize("non_match", [True, False]) +def test_user_delete(client, seeder, utils, app, mocker, db_error, non_match): + user_id, admin_unit_id = seeder.setup_base(True) + other_user_id = seeder.create_user("other@test.de") + + url = utils.get_url("admin_user_delete", id=other_user_id) + response = utils.get_ok(url) + + if db_error: + utils.mock_db_commit(mocker) + + form_email = "other@test.de" + + if non_match: + form_email = "wrong@test.de" + + response = utils.post_form( + url, + response, + { + "email": form_email, + }, + ) + + if non_match: + utils.assert_response_error_message( + response, "Die eingegebene Email passt nicht zur Email des Nutzers" + ) + return + + if db_error: + utils.assert_response_db_error(response) + return + + utils.assert_response_redirect(response, "admin_users") + + with app.app_context(): + from project.models import User + + user = User.query.get(other_user_id) + assert user is None + + @pytest.mark.parametrize("db_error", [True, False]) def test_admin_admin_unit_update(client, seeder, utils, app, mocker, db, db_error): user_id, admin_unit_id = seeder.setup_base(True)