From 04884c9dee5e3e48b4f813d4225b85121add8aa2 Mon Sep 17 00:00:00 2001 From: Daniel Grams Date: Fri, 20 Aug 2021 09:43:53 +0200 Subject: [PATCH] Introduce switch suggestions_enabled for Organizations #273 --- messages.pot | 106 +++++++++-------- migrations/versions/924071080036_.py | 31 +++++ package-lock.json | 14 +-- package.json | 2 +- project/access.py | 5 + project/cli/test.py | 1 + project/forms/admin.py | 5 + project/models.py | 8 ++ project/static/infoscreen.css | 44 ------- .../templates/admin/update_admin_unit.html | 1 + project/templates/layout.html | 14 ++- project/templates/manage/widgets.html | 6 +- project/templates/widget/infoscreen/read.html | 104 ----------------- .../translations/de/LC_MESSAGES/messages.mo | Bin 29083 -> 29212 bytes .../translations/de/LC_MESSAGES/messages.po | 109 ++++++++++-------- .../translations/en/LC_MESSAGES/messages.mo | Bin 3225 -> 3225 bytes .../translations/en/LC_MESSAGES/messages.po | 109 ++++++++++-------- project/views/manage.py | 2 + project/views/widget.py | 29 ++--- tests/api/test_event_date.py | 4 + tests/seeder.py | 3 +- tests/views/test_admin.py | 3 + tests/views/test_widget.py | 27 ++--- 23 files changed, 270 insertions(+), 357 deletions(-) create mode 100644 migrations/versions/924071080036_.py delete mode 100644 project/static/infoscreen.css delete mode 100644 project/templates/widget/infoscreen/read.html diff --git a/messages.pot b/messages.pot index 2cf03dc..5e219d3 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: 2021-08-15 14:50+0200\n" +"POT-Creation-Date: 2021-08-20 08:42+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -165,24 +165,24 @@ msgstr "" msgid "." msgstr "" -#: project/forms/admin.py:10 project/templates/layout.html:331 +#: project/forms/admin.py:10 project/templates/layout.html:335 #: project/views/root.py:42 msgid "Terms of service" msgstr "" -#: project/forms/admin.py:11 project/templates/layout.html:335 +#: project/forms/admin.py:11 project/templates/layout.html:339 #: project/views/root.py:50 msgid "Legal notice" msgstr "" #: project/forms/admin.py:12 project/templates/_macros.html:1328 -#: project/templates/layout.html:339 +#: project/templates/layout.html:343 #: project/templates/widget/event_suggestion/create.html:199 #: project/views/admin_unit.py:36 project/views/root.py:58 msgid "Contact" msgstr "" -#: project/forms/admin.py:13 project/templates/layout.html:343 +#: project/forms/admin.py:13 project/templates/layout.html:347 #: project/views/root.py:66 msgid "Privacy" msgstr "" @@ -211,7 +211,15 @@ msgid "" "event." msgstr "" -#: project/forms/admin.py:31 project/templates/admin/update_admin_unit.html:4 +#: project/forms/admin.py:32 +msgid "Suggestions enabled" +msgstr "" + +#: project/forms/admin.py:33 +msgid "If set, the organization can work with suggestions." +msgstr "" + +#: project/forms/admin.py:36 project/templates/admin/update_admin_unit.html:4 #: project/templates/admin/update_admin_unit.html:8 msgid "Update organization" msgstr "" @@ -268,7 +276,7 @@ msgstr "" msgid "The short name is used to create a unique identifier for your events" msgstr "" -#: project/forms/admin_unit.py:40 project/templates/_macros.html:1458 +#: project/forms/admin_unit.py:40 project/templates/_macros.html:1464 msgid "Short name must contain only letters numbers or underscore" msgstr "" @@ -282,7 +290,7 @@ msgstr "" #: project/forms/admin_unit_member.py:23 project/forms/admin_unit_member.py:28 #: project/forms/event.py:58 project/forms/event_suggestion.py:38 #: project/forms/organizer.py:27 project/templates/_macros.html:262 -#: project/templates/_macros.html:1418 project/templates/admin/users.html:19 +#: project/templates/_macros.html:1424 project/templates/admin/users.html:19 msgid "Email" msgstr "" @@ -642,7 +650,7 @@ msgstr "" #: project/forms/event.py:231 project/forms/reference.py:14 #: project/forms/reference.py:27 project/forms/reference_request.py:75 #: project/templates/event/create.html:358 -#: project/templates/event/update.html:214 +#: project/templates/event/update.html:215 msgid "Rating" msgstr "" @@ -657,7 +665,7 @@ msgstr "" #: project/forms/event.py:321 project/forms/event_suggestion.py:50 #: project/templates/_macros.html:468 project/templates/_macros.html:624 #: project/templates/event/create.html:283 -#: project/templates/event/update.html:164 +#: project/templates/event/update.html:165 #: project/templates/event_place/create.html:21 #: project/templates/event_place/delete.html:13 #: project/templates/event_place/update.html:21 @@ -676,7 +684,7 @@ msgstr "" #: project/forms/event.py:329 project/forms/event.py:389 #: project/forms/event_suggestion.py:60 project/templates/_macros.html:506 #: project/templates/_macros.html:661 project/templates/event/create.html:254 -#: project/templates/event/update.html:155 +#: project/templates/event/update.html:156 #: project/templates/organizer/create.html:17 #: project/templates/organizer/delete.html:13 #: project/templates/organizer/update.html:17 @@ -818,7 +826,7 @@ msgid "Distance" msgstr "" #: project/forms/event_date.py:30 project/forms/planing.py:34 -#: project/templates/widget/event_date/list.html:42 +#: project/templates/widget/event_date/list.html:53 msgid "Find" msgstr "" @@ -946,7 +954,7 @@ msgstr "" #: project/templates/_macros.html:527 project/templates/_macros.html:687 #: project/templates/admin_unit/create.html:19 #: project/templates/admin_unit/update.html:20 -#: project/templates/layout.html:286 +#: project/templates/layout.html:289 msgid "Organization" msgstr "" @@ -1090,12 +1098,12 @@ msgid "%(count)d event dates" msgstr "" #: project/templates/_macros.html:451 project/templates/_macros.html:606 -#: project/templates/_macros.html:1403 project/templates/event/actions.html:32 +#: project/templates/_macros.html:1409 project/templates/event/actions.html:32 msgid "Share" msgstr "" #: project/templates/_macros.html:455 project/templates/_macros.html:610 -#: project/templates/_macros.html:1433 +#: project/templates/_macros.html:1439 msgid "Add to calendar" msgstr "" @@ -1189,27 +1197,27 @@ msgstr "" msgid "Event suggestion" msgstr "" -#: project/templates/_macros.html:1412 +#: project/templates/_macros.html:1418 msgid "Link copied" msgstr "" -#: project/templates/_macros.html:1412 +#: project/templates/_macros.html:1418 msgid "Copy link" msgstr "" -#: project/templates/_macros.html:1441 +#: project/templates/_macros.html:1447 msgid "Google calendar" msgstr "" -#: project/templates/_macros.html:1442 +#: project/templates/_macros.html:1448 msgid "Apple calendar" msgstr "" -#: project/templates/_macros.html:1443 +#: project/templates/_macros.html:1449 msgid "Yahoo calendar" msgstr "" -#: project/templates/_macros.html:1444 +#: project/templates/_macros.html:1450 msgid "Other calendar" msgstr "" @@ -1218,12 +1226,12 @@ msgid "Manage" msgstr "" #: project/templates/home.html:29 project/templates/security/login_user.html:35 -#: project/views/widget.py:180 +#: project/views/widget.py:165 msgid "Register for free" msgstr "" #: project/templates/event_place/read.html:22 project/templates/layout.html:206 -#: project/templates/layout.html:249 project/templates/manage/events.html:5 +#: project/templates/layout.html:250 project/templates/manage/events.html:5 #: project/templates/manage/events.html:9 msgid "Events" msgstr "" @@ -1264,60 +1272,60 @@ msgstr "" msgid "Logout" msgstr "" -#: project/templates/layout.html:255 +#: project/templates/layout.html:256 msgid "Show events" msgstr "" #: project/templates/event/create.html:4 -#: project/templates/event/create.html:221 project/templates/layout.html:256 +#: project/templates/event/create.html:221 project/templates/layout.html:257 #: project/templates/manage/events.html:12 #: project/templates/manage/organizers.html:21 msgid "Create event" msgstr "" -#: project/templates/layout.html:258 +#: project/templates/layout.html:260 msgid "Review suggestions" msgstr "" -#: project/templates/layout.html:267 +#: project/templates/layout.html:270 #: project/templates/manage/references_incoming.html:5 #: project/templates/manage/references_outgoing.html:5 msgid "References" msgstr "" -#: project/templates/layout.html:273 +#: project/templates/layout.html:276 #: project/templates/manage/references_incoming.html:9 msgid "Incoming references" msgstr "" -#: project/templates/layout.html:274 +#: project/templates/layout.html:277 #: project/templates/manage/references_outgoing.html:9 msgid "Outgoing references" msgstr "" -#: project/templates/layout.html:276 +#: project/templates/layout.html:279 #: project/templates/manage/reference_requests_incoming.html:9 msgid "Incoming reference requests" msgstr "" -#: project/templates/layout.html:281 +#: project/templates/layout.html:284 #: project/templates/manage/reference_requests_outgoing.html:9 msgid "Outgoing reference requests" msgstr "" -#: project/templates/layout.html:289 project/templates/manage/organizers.html:5 +#: project/templates/layout.html:292 project/templates/manage/organizers.html:5 #: project/templates/manage/organizers.html:9 msgid "Organizers" msgstr "" #: project/templates/event_place/list.html:3 -#: project/templates/event_place/list.html:7 project/templates/layout.html:290 +#: project/templates/event_place/list.html:7 project/templates/layout.html:293 #: project/templates/manage/places.html:5 #: project/templates/manage/places.html:9 msgid "Places" msgstr "" -#: project/templates/layout.html:292 project/templates/manage/members.html:5 +#: project/templates/layout.html:295 project/templates/manage/members.html:5 #: project/templates/manage/members.html:28 msgid "Members" msgstr "" @@ -1326,22 +1334,22 @@ msgstr "" #: project/templates/admin/settings.html:4 #: project/templates/admin/settings.html:8 #: project/templates/admin_unit/update.html:14 -#: project/templates/layout.html:293 project/templates/manage/widgets.html:12 +#: project/templates/layout.html:296 project/templates/manage/widgets.html:12 #: project/templates/profile.html:19 msgid "Settings" msgstr "" -#: project/templates/layout.html:294 project/templates/manage/reviews.html:10 +#: project/templates/layout.html:297 project/templates/manage/reviews.html:10 #: project/templates/manage/widgets.html:5 #: project/templates/manage/widgets.html:9 msgid "Widgets" msgstr "" -#: project/templates/layout.html:304 +#: project/templates/layout.html:307 msgid "Switch organization" msgstr "" -#: project/templates/developer/read.html:4 project/templates/layout.html:353 +#: project/templates/developer/read.html:4 project/templates/layout.html:357 #: project/templates/profile.html:29 msgid "Developer" msgstr "" @@ -1382,7 +1390,7 @@ msgstr "" #: project/templates/admin_unit/create.html:49 #: project/templates/admin_unit/update.html:50 #: project/templates/event/create.html:346 -#: project/templates/event/update.html:202 +#: project/templates/event/update.html:203 #: project/templates/event_place/create.html:47 #: project/templates/event_place/update.html:47 #: project/templates/organizer/create.html:46 @@ -1513,12 +1521,12 @@ msgid "Switch to place search" msgstr "" #: project/templates/event/create.html:319 -#: project/templates/event/update.html:175 +#: project/templates/event/update.html:176 msgid "Access" msgstr "" #: project/templates/event/create.html:333 -#: project/templates/event/update.html:189 +#: project/templates/event/update.html:190 msgid "Target group" msgstr "" @@ -1627,14 +1635,10 @@ msgstr "" msgid "Veranstaltungen als iFrame einbetten" msgstr "" -#: project/templates/manage/widgets.html:32 +#: project/templates/manage/widgets.html:33 msgid "Link, um Veranstaltungen vorzuschlagen" msgstr "" -#: project/templates/manage/widgets.html:36 -msgid "URL für Infoscreen" -msgstr "" - #: project/templates/oauth2_client/create.html:4 #: project/templates/oauth2_client/create.html:8 #: project/templates/oauth2_client/list.html:17 @@ -1729,7 +1733,7 @@ msgstr "" msgid "Widget" msgstr "" -#: project/templates/widget/event_date/list.html:105 +#: project/templates/widget/event_date/list.html:116 msgid "Print" msgstr "" @@ -1749,7 +1753,7 @@ msgstr "" msgid "Organization successfully updated" msgstr "" -#: project/views/admin.py:68 project/views/manage.py:260 +#: project/views/admin.py:68 project/views/manage.py:270 msgid "Settings successfully updated" msgstr "" @@ -1961,17 +1965,17 @@ msgstr "" msgid "You do not have permission for this action" msgstr "" -#: project/views/widget.py:172 +#: project/views/widget.py:157 msgid "Thank you so much! The event is being verified." msgstr "" -#: project/views/widget.py:176 +#: project/views/widget.py:161 msgid "" "For more options and your own calendar of events, you can register for " "free." msgstr "" -#: project/views/widget.py:239 +#: project/views/widget.py:224 msgid "New event review" msgstr "" diff --git a/migrations/versions/924071080036_.py b/migrations/versions/924071080036_.py new file mode 100644 index 0000000..4f2a08e --- /dev/null +++ b/migrations/versions/924071080036_.py @@ -0,0 +1,31 @@ +"""empty message + +Revision ID: 924071080036 +Revises: 6893de0cb15b +Create Date: 2021-08-20 08:15:53.480243 + +""" +import sqlalchemy as sa +import sqlalchemy_utils +from alembic import op + +from project import dbtypes + +# revision identifiers, used by Alembic. +revision = "924071080036" +down_revision = "6893de0cb15b" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column( + "adminunit", + sa.Column( + "suggestions_enabled", sa.Boolean(), nullable=False, server_default="0" + ), + ) + + +def downgrade(): + op.drop_column("adminunit", "suggestions_enabled") diff --git a/package-lock.json b/package-lock.json index 0e445bd..c3b8d25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "devDependencies": { - "cypress": "^8.1.0" + "cypress": "^8.3.0" } }, "node_modules/@cypress/request": { @@ -498,9 +498,9 @@ } }, "node_modules/cypress": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-8.1.0.tgz", - "integrity": "sha512-GXjlqPjY/6HPbQwAp3AvlA1Mk/NoJTAmqVSUhQsuM/1xDpd/FQHkxVuq5h6O6RrAoCXSgpZPXFsVtdqE+FwEJw==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-8.3.0.tgz", + "integrity": "sha512-zA5Rcq8AZIfRfPXU0CCcauofF+YpaU9HYbfqkunFTmFV0Kdlo14tNjH2E3++MkjXKFnv3/pXq+HgxWtw8CSe8Q==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -2209,9 +2209,9 @@ } }, "cypress": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/cypress/-/cypress-8.1.0.tgz", - "integrity": "sha512-GXjlqPjY/6HPbQwAp3AvlA1Mk/NoJTAmqVSUhQsuM/1xDpd/FQHkxVuq5h6O6RrAoCXSgpZPXFsVtdqE+FwEJw==", + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-8.3.0.tgz", + "integrity": "sha512-zA5Rcq8AZIfRfPXU0CCcauofF+YpaU9HYbfqkunFTmFV0Kdlo14tNjH2E3++MkjXKFnv3/pXq+HgxWtw8CSe8Q==", "dev": true, "requires": { "@cypress/request": "^2.88.5", diff --git a/package.json b/package.json index 50ca69b..4a3629a 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,6 @@ }, "homepage": "https://github.com/DanielGrams/gsevpt#readme", "devDependencies": { - "cypress": "^8.1.0" + "cypress": "^8.3.0" } } diff --git a/project/access.py b/project/access.py index 561bb61..0732bab 100644 --- a/project/access.py +++ b/project/access.py @@ -171,6 +171,11 @@ def get_admin_unit_for_manage_or_404(admin_unit_id): return admin_unit +def admin_unit_suggestions_enabled_or_404(admin_unit: AdminUnit): + if not admin_unit.suggestions_enabled: + abort(404) + + def can_create_admin_unit(): if not current_user.is_authenticated: # pragma: no cover return False diff --git a/project/cli/test.py b/project/cli/test.py index 5329137..d433f3d 100644 --- a/project/cli/test.py +++ b/project/cli/test.py @@ -103,6 +103,7 @@ def _create_admin_unit(user_id, name): admin_unit.name = name admin_unit.short_name = name.lower().replace(" ", "") admin_unit.incoming_reference_requests_allowed = True + admin_unit.suggestions_enabled = True admin_unit.location = Location() admin_unit.location.postalCode = "38640" admin_unit.location.city = "Goslar" diff --git a/project/forms/admin.py b/project/forms/admin.py index 3f4b88e..35cc1d1 100644 --- a/project/forms/admin.py +++ b/project/forms/admin.py @@ -28,4 +28,9 @@ class UpdateAdminUnitForm(FlaskForm): ), validators=[Optional()], ) + suggestions_enabled = BooleanField( + lazy_gettext("Suggestions enabled"), + description=lazy_gettext("If set, the organization can work with suggestions."), + validators=[Optional()], + ) submit = SubmitField(lazy_gettext("Update organization")) diff --git a/project/models.py b/project/models.py index a13b1c4..1e33b69 100644 --- a/project/models.py +++ b/project/models.py @@ -323,6 +323,14 @@ class AdminUnit(db.Model, TrackableMixin): widget_primary_color = deferred(Column(ColorType), group="widget") widget_link_color = deferred(Column(ColorType), group="widget") incoming_reference_requests_allowed = deferred(Column(Boolean())) + suggestions_enabled = deferred( + Column( + Boolean(), + nullable=False, + default=False, + server_default="0", + ) + ) @listens_for(AdminUnit, "before_insert") diff --git a/project/static/infoscreen.css b/project/static/infoscreen.css deleted file mode 100644 index f41cf05..0000000 --- a/project/static/infoscreen.css +++ /dev/null @@ -1,44 +0,0 @@ -html, body { - width: 100vw; - height: 100vh; - max-height: -webkit-fill-available; - margin: 0; - font-size: 2.5vmin; -} - - -.body-content { - width: 100vw; - height: 100vh; - max-height: -webkit-fill-available; - padding: 0; -} - -h1 { - font-size: 1.8rem; - margin: 0; -} - -h2 { - margin: 0.4rem 0 0rem; -} - -h3 { - font-size: 1.4rem; - margin: 0rem 0 1rem; -} - -h4 { - font-size: 1.1rem; -} - -/* Add an extra .carousel parent class to increase specificity - avoiding the use of !important flag. */ -.carousel .carousel-indicators li { -background-color: #fff; -background-color: rgba(70, 70, 70, 0.25); -} - -.carousel .carousel-indicators .active { -background-color: #444; -} \ No newline at end of file diff --git a/project/templates/admin/update_admin_unit.html b/project/templates/admin/update_admin_unit.html index 27b69d0..00baf8d 100644 --- a/project/templates/admin/update_admin_unit.html +++ b/project/templates/admin/update_admin_unit.html @@ -16,6 +16,7 @@
{{ render_field_with_errors(form.incoming_reference_requests_allowed, ri="switch") }} + {{ render_field_with_errors(form.suggestions_enabled, ri="switch") }}
diff --git a/project/templates/layout.html b/project/templates/layout.html index 72b33ca..2e6fc8d 100644 --- a/project/templates/layout.html +++ b/project/templates/layout.html @@ -255,12 +255,14 @@