From be0ca45ad487ed642de832b54110e374eddbbcb7 Mon Sep 17 00:00:00 2001 From: Daniel Grams Date: Thu, 12 Aug 2021 23:55:05 +0200 Subject: [PATCH] Suggestion rejection via popup #256 --- cypress/integration/suggestion.js | 18 ++ cypress/support/commands.js | 9 + messages.pot | 162 +++++++++-------- project/cli/test.py | 51 +++++- project/forms/event_suggestion.py | 5 +- .../templates/event_suggestion/review.html | 41 ++++- .../templates/reference_request/review.html | 27 +-- .../translations/de/LC_MESSAGES/messages.mo | Bin 28446 -> 28633 bytes .../translations/de/LC_MESSAGES/messages.po | 164 +++++++++--------- .../translations/en/LC_MESSAGES/messages.mo | Bin 3225 -> 3225 bytes .../translations/en/LC_MESSAGES/messages.po | 162 +++++++++-------- project/views/event_suggestion.py | 3 + 12 files changed, 376 insertions(+), 266 deletions(-) diff --git a/cypress/integration/suggestion.js b/cypress/integration/suggestion.js index 242f54a..1a84355 100644 --- a/cypress/integration/suggestion.js +++ b/cypress/integration/suggestion.js @@ -71,4 +71,22 @@ describe("Suggestion", () => { } ); }); + + it('reject', () => { + cy.login() + cy.createAdminUnit().then(function(adminUnitId) { + cy.createSuggestion(adminUnitId).then(function(suggestionId) { + + cy.visit('/event_suggestion/' + suggestionId + '/review') + cy.get('.decision-container .btn-danger').click() + cy.get('#rejectFormModal select[name=rejection_resaon]').select('Duplikat').should('have.value', '1') + cy.screenshot() + cy.get('#rejectFormModal .btn-danger').click() + cy.url().should('include', '/reviews') + cy.get('div.alert').should('contain', 'Veranstaltungsvorschlag erfolgreich abgelehnt') + cy.get('main .badge-pill').should('contain', 'Abgelehnt') + }) + }) + }) + }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 5d028df..2fab8f5 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -46,6 +46,15 @@ Cypress.Commands.add("createIncomingReferenceRequest", (adminUnitId) => { }); }); +Cypress.Commands.add("createSuggestion", (adminUnitId) => { + return cy + .logexec("flask test suggestion-create " + adminUnitId) + .then(function (result) { + let json = JSON.parse(result.stdout); + return json.event_suggestion_id; + }); +}); + Cypress.Commands.add("assertValid", (fieldId) => { cy.get("#" + fieldId).should("have.class", "is-valid"); cy.get("#" + fieldId + "-error").should("be.empty"); diff --git a/messages.pot b/messages.pot index 47da4a0..2cfd936 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-11 07:54+0200\n" +"POT-Creation-Date: 2021-08-12 23:45+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -175,9 +175,9 @@ msgstr "" msgid "Legal notice" msgstr "" -#: project/forms/admin.py:12 project/templates/_macros.html:1284 +#: project/forms/admin.py:12 project/templates/_macros.html:1322 #: project/templates/layout.html:339 -#: project/templates/widget/event_suggestion/create.html:177 +#: project/templates/widget/event_suggestion/create.html:199 #: project/views/admin_unit.py:36 project/views/root.py:58 msgid "Contact" msgstr "" @@ -268,7 +268,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:1414 +#: project/forms/admin_unit.py:40 project/templates/_macros.html:1452 msgid "Short name must contain only letters numbers or underscore" msgstr "" @@ -282,7 +282,7 @@ msgstr "" #: project/forms/admin_unit_member.py:23 project/forms/admin_unit_member.py:28 #: project/forms/event.py:57 project/forms/event_suggestion.py:38 #: project/forms/organizer.py:27 project/templates/_macros.html:262 -#: project/templates/_macros.html:1374 project/templates/admin/users.html:19 +#: project/templates/_macros.html:1412 project/templates/admin/users.html:19 msgid "Email" msgstr "" @@ -456,9 +456,9 @@ msgstr "" msgid "Indicate when the event will end. An event can last a maximum of 14 days." msgstr "" -#: project/forms/event.py:81 project/templates/event/create.html:298 +#: project/forms/event.py:81 project/templates/event/create.html:244 #: project/templates/event/update.html:135 -#: project/templates/widget/event_suggestion/create.html:212 +#: project/templates/widget/event_suggestion/create.html:234 msgid "Recurring event" msgstr "" @@ -604,7 +604,7 @@ msgid "Choose how people can attend the event." msgstr "" #: project/forms/event.py:191 project/forms/event_place.py:27 -#: project/templates/widget/event_suggestion/create.html:230 +#: project/templates/widget/event_suggestion/create.html:252 msgid "Photo" msgstr "" @@ -641,7 +641,7 @@ msgstr "" #: project/forms/event.py:230 project/forms/reference.py:14 #: project/forms/reference.py:27 project/forms/reference_request.py:75 -#: project/templates/event/create.html:412 +#: project/templates/event/create.html:358 #: project/templates/event/update.html:214 msgid "Rating" msgstr "" @@ -656,7 +656,7 @@ msgstr "" #: project/forms/event.py:242 project/forms/event.py:251 #: project/forms/event.py:315 project/forms/event_suggestion.py:50 #: project/templates/_macros.html:462 project/templates/_macros.html:618 -#: project/templates/event/create.html:337 +#: project/templates/event/create.html:283 #: project/templates/event/update.html:164 #: project/templates/event_place/create.html:21 #: project/templates/event_place/delete.html:13 @@ -675,7 +675,7 @@ msgstr "" #: project/forms/event.py:258 project/forms/event.py:267 #: project/forms/event.py:323 project/forms/event.py:373 #: project/forms/event_suggestion.py:60 project/templates/_macros.html:500 -#: project/templates/_macros.html:655 project/templates/event/create.html:308 +#: project/templates/_macros.html:655 project/templates/event/create.html:254 #: project/templates/event/update.html:155 #: project/templates/organizer/create.html:17 #: project/templates/organizer/delete.html:13 @@ -692,7 +692,7 @@ msgid "Enter new organizer" msgstr "" #: project/forms/event.py:273 project/templates/event/create.html:4 -#: project/templates/event/create.html:275 project/templates/layout.html:256 +#: project/templates/event/create.html:221 project/templates/layout.html:256 #: project/templates/manage/events.html:12 #: project/templates/manage/organizers.html:21 msgid "Create event" @@ -840,13 +840,13 @@ msgstr "" msgid "I would like to be notified by email after the review" msgstr "" -#: project/forms/event_suggestion.py:52 project/templates/event/create.html:342 +#: project/forms/event_suggestion.py:52 project/templates/event/create.html:288 msgid "" "Choose where the event takes place. If the venue is not yet in the list, " "just enter it." msgstr "" -#: project/forms/event_suggestion.py:62 project/templates/event/create.html:312 +#: project/forms/event_suggestion.py:62 project/templates/event/create.html:258 msgid "" "Select the organizer. If the organizer is not yet on the list, just enter" " it." @@ -854,7 +854,7 @@ msgstr "" #: project/forms/event_suggestion.py:78 #: project/templates/widget/event_suggestion/create.html:4 -#: project/templates/widget/event_suggestion/create.html:130 +#: project/templates/widget/event_suggestion/create.html:152 msgid "Create event suggestion" msgstr "" @@ -862,21 +862,27 @@ msgstr "" msgid "Rejection reason" msgstr "" -#: project/forms/event_suggestion.py:122 +#: project/forms/event_suggestion.py:121 +msgid "EventRejectionReason.noreason" +msgstr "" + +#: project/forms/event_suggestion.py:125 msgid "EventRejectionReason.duplicate" msgstr "" -#: project/forms/event_suggestion.py:126 +#: project/forms/event_suggestion.py:129 msgid "EventRejectionReason.untrustworthy" msgstr "" -#: project/forms/event_suggestion.py:130 +#: project/forms/event_suggestion.py:133 msgid "EventRejectionReason.illegal" msgstr "" -#: project/forms/event_suggestion.py:135 +#: project/forms/event_suggestion.py:138 #: project/templates/event_suggestion/reject.html:9 -#: project/templates/event_suggestion/review.html:22 +#: project/templates/event_suggestion/review.html:33 +#: project/templates/event_suggestion/review.html:40 +#: project/templates/event_suggestion/review.html:54 msgid "Reject event suggestion" msgstr "" @@ -948,7 +954,7 @@ msgstr "" msgid "Delete request" msgstr "" -#: project/forms/reference_request.py:27 project/templates/_macros.html:1296 +#: project/forms/reference_request.py:27 project/templates/_macros.html:1334 #: project/templates/event_suggestion/review_status.html:18 #: project/templates/reference_request/review_status.html:12 msgid "Review status" @@ -1053,11 +1059,11 @@ msgstr "" #: project/templates/_macros.html:402 project/templates/_macros.html:578 #: project/templates/event/actions.html:12 -#: project/templates/event/create.html:282 +#: project/templates/event/create.html:228 #: project/templates/event/delete.html:13 #: project/templates/event/update.html:119 #: project/templates/reference/delete.html:13 -#: project/templates/widget/event_suggestion/create.html:202 +#: project/templates/widget/event_suggestion/create.html:224 msgid "Event" msgstr "" @@ -1067,12 +1073,12 @@ msgid "%(count)d event dates" msgstr "" #: project/templates/_macros.html:445 project/templates/_macros.html:600 -#: project/templates/_macros.html:1359 project/templates/event/actions.html:32 +#: project/templates/_macros.html:1397 project/templates/event/actions.html:32 msgid "Share" msgstr "" #: project/templates/_macros.html:449 project/templates/_macros.html:604 -#: project/templates/_macros.html:1389 +#: project/templates/_macros.html:1427 msgid "Add to calendar" msgstr "" @@ -1091,7 +1097,7 @@ msgstr "" #: project/templates/_macros.html:705 project/templates/event_date/list.html:4 #: project/templates/event_date/list.html:258 #: project/templates/event_date/search.html:3 -#: project/templates/reference_request/review.html:55 +#: project/templates/reference_request/review.html:32 msgid "Event Dates" msgstr "" @@ -1101,12 +1107,12 @@ msgstr "" #: project/templates/_macros.html:811 project/templates/_macros.html:813 #: project/templates/event_date/list.html:279 -#: project/templates/widget/event_suggestion/create.html:166 -#: project/templates/widget/event_suggestion/create.html:191 -#: project/templates/widget/event_suggestion/create.html:219 -#: project/templates/widget/event_suggestion/create.html:242 -#: project/templates/widget/event_suggestion/create.html:275 -#: project/templates/widget/event_suggestion/create.html:304 +#: project/templates/widget/event_suggestion/create.html:188 +#: project/templates/widget/event_suggestion/create.html:213 +#: project/templates/widget/event_suggestion/create.html:241 +#: project/templates/widget/event_suggestion/create.html:264 +#: project/templates/widget/event_suggestion/create.html:297 +#: project/templates/widget/event_suggestion/create.html:326 msgid "Previous" msgstr "" @@ -1117,11 +1123,11 @@ msgstr "" #: project/templates/_macros.html:817 project/templates/_macros.html:819 #: project/templates/event_date/list.html:281 -#: project/templates/widget/event_suggestion/create.html:167 -#: project/templates/widget/event_suggestion/create.html:192 -#: project/templates/widget/event_suggestion/create.html:220 -#: project/templates/widget/event_suggestion/create.html:243 -#: project/templates/widget/event_suggestion/create.html:276 +#: project/templates/widget/event_suggestion/create.html:189 +#: project/templates/widget/event_suggestion/create.html:214 +#: project/templates/widget/event_suggestion/create.html:242 +#: project/templates/widget/event_suggestion/create.html:265 +#: project/templates/widget/event_suggestion/create.html:298 msgid "Next" msgstr "" @@ -1157,31 +1163,36 @@ msgstr "" msgid "Please enter a valid time, between 00:00 and 23:59." msgstr "" -#: project/templates/_macros.html:1256 +#: project/templates/_macros.html:1242 +#, python-format +msgid "Just use %(term)s" +msgstr "" + +#: project/templates/_macros.html:1294 msgid "Event suggestion" msgstr "" -#: project/templates/_macros.html:1368 +#: project/templates/_macros.html:1406 msgid "Link copied" msgstr "" -#: project/templates/_macros.html:1368 +#: project/templates/_macros.html:1406 msgid "Copy link" msgstr "" -#: project/templates/_macros.html:1397 +#: project/templates/_macros.html:1435 msgid "Google calendar" msgstr "" -#: project/templates/_macros.html:1398 +#: project/templates/_macros.html:1436 msgid "Apple calendar" msgstr "" -#: project/templates/_macros.html:1399 +#: project/templates/_macros.html:1437 msgid "Yahoo calendar" msgstr "" -#: project/templates/_macros.html:1400 +#: project/templates/_macros.html:1438 msgid "Other calendar" msgstr "" @@ -1346,7 +1357,7 @@ msgstr "" #: project/templates/admin_unit/create.html:49 #: project/templates/admin_unit/update.html:50 -#: project/templates/event/create.html:400 +#: project/templates/event/create.html:346 #: project/templates/event/update.html:202 #: project/templates/event_place/create.html:47 #: project/templates/event_place/update.html:47 @@ -1454,39 +1465,35 @@ msgstr "" #: project/templates/event/create.html:90 #: project/templates/event/update.html:76 +#: project/templates/widget/event_suggestion/create.html:99 msgid "Enter place or address" msgstr "" -#: project/templates/event/create.html:100 -#: project/templates/event/create.html:213 -#, python-format -msgid "Just use %(term)s" -msgstr "" - -#: project/templates/event/create.html:203 +#: project/templates/event/create.html:176 #: project/templates/event/update.html:99 +#: project/templates/widget/event_suggestion/create.html:124 msgid "Enter organizer" msgstr "" -#: project/templates/event/create.html:292 +#: project/templates/event/create.html:238 #: project/templates/event/update.html:129 msgid "Event date" msgstr "" -#: project/templates/event/create.html:329 +#: project/templates/event/create.html:275 msgid "Switch to organizer search" msgstr "" -#: project/templates/event/create.html:362 +#: project/templates/event/create.html:308 msgid "Switch to place search" msgstr "" -#: project/templates/event/create.html:373 +#: project/templates/event/create.html:319 #: project/templates/event/update.html:175 msgid "Access" msgstr "" -#: project/templates/event/create.html:387 +#: project/templates/event/create.html:333 #: project/templates/event/update.html:189 msgid "Target group" msgstr "" @@ -1505,21 +1512,27 @@ msgstr "" msgid "Info" msgstr "" -#: project/templates/event_suggestion/review.html:9 +#: project/templates/event_suggestion/review.html:20 #: project/templates/manage/reviews.html:19 msgid "Review event suggestion" msgstr "" -#: project/templates/event_suggestion/review.html:17 +#: project/templates/event_suggestion/review.html:28 #: project/templates/event_suggestion/review_status.html:24 #: project/templates/reference_request/review_status.html:17 msgid "View event" msgstr "" -#: project/templates/event_suggestion/review.html:21 +#: project/templates/event_suggestion/review.html:32 msgid "Create event from suggestion" msgstr "" +#: project/templates/event_suggestion/review.html:53 +#: project/templates/reference_request/review.html:68 +#: project/templates/reference_request/review.html:93 +msgid "Cancel" +msgstr "" + #: project/templates/event_suggestion/review_status.html:12 msgid "You can visit this page again to check the status." msgstr "" @@ -1658,27 +1671,22 @@ msgstr "" msgid "Update reference to event \"%(name)s\"" msgstr "" -#: project/templates/reference_request/review.html:46 +#: project/templates/reference_request/review.html:23 msgid "Review event reference request" msgstr "" -#: project/templates/reference_request/review.html:66 -#: project/templates/reference_request/review.html:74 -#: project/templates/reference_request/review.html:92 +#: project/templates/reference_request/review.html:43 +#: project/templates/reference_request/review.html:51 +#: project/templates/reference_request/review.html:69 msgid "Accept reference request" msgstr "" -#: project/templates/reference_request/review.html:67 -#: project/templates/reference_request/review.html:102 -#: project/templates/reference_request/review.html:119 +#: project/templates/reference_request/review.html:44 +#: project/templates/reference_request/review.html:79 +#: project/templates/reference_request/review.html:94 msgid "Reject reference request" msgstr "" -#: project/templates/reference_request/review.html:91 -#: project/templates/reference_request/review.html:118 -msgid "Cancel" -msgstr "" - #: project/templates/security/authorize.html:10 #, python-format msgid "\"%(client_name)s\" wants to access your account" @@ -1701,15 +1709,15 @@ msgstr "" msgid "Print" msgstr "" -#: project/templates/widget/event_suggestion/create.html:148 +#: project/templates/widget/event_suggestion/create.html:170 msgid "Continue as guest" msgstr "" -#: project/templates/widget/event_suggestion/create.html:253 +#: project/templates/widget/event_suggestion/create.html:275 msgid "Optional details" msgstr "" -#: project/templates/widget/event_suggestion/create.html:286 +#: project/templates/widget/event_suggestion/create.html:308 msgid "Preview" msgstr "" @@ -1811,11 +1819,11 @@ msgstr "" msgid "Place successfully deleted" msgstr "" -#: project/views/event_suggestion.py:51 +#: project/views/event_suggestion.py:54 msgid "Event suggestion successfully rejected" msgstr "" -#: project/views/event_suggestion.py:84 +#: project/views/event_suggestion.py:87 #: project/views/reference_request_review.py:114 msgid "Event review status updated" msgstr "" diff --git a/project/cli/test.py b/project/cli/test.py index b6139a5..5329137 100644 --- a/project/cli/test.py +++ b/project/cli/test.py @@ -13,10 +13,12 @@ from project.models import ( EventAttendanceMode, EventReferenceRequest, EventReferenceRequestReviewStatus, + EventSuggestion, Location, ) from project.services.admin_unit import get_admin_unit_by_id, insert_admin_unit_for_user from project.services.event import insert_event, upsert_event_category +from project.services.event_suggestion import insert_event_suggestion from project.services.organizer import get_event_organizer from project.services.place import get_event_places from project.services.user import create_user, find_user_by_email, get_user @@ -35,6 +37,15 @@ def _get_now_by_minute(): ) +def _get_default_event_place_id(admin_unit_id): + return get_event_places(admin_unit_id, limit=1)[0].id + + +def _get_default_organizer_id(admin_unit_id): + admin_unit = get_admin_unit_by_id(admin_unit_id) + return get_event_organizer(admin_unit_id, admin_unit.name).id + + def _create_user( email="test@test.de", password="MeinPasswortIstDasBeste", confirm=True ): @@ -112,16 +123,14 @@ def create_admin_unit(user_email, name): def _create_event(admin_unit_id): - admin_unit = get_admin_unit_by_id(admin_unit_id) - event = Event() event.admin_unit_id = admin_unit_id event.categories = [upsert_event_category("Other")] event.name = "Name" event.description = "Beschreibung" event.start = _get_now_by_minute() - event.event_place_id = get_event_places(admin_unit_id, limit=1)[0].id - event.organizer_id = get_event_organizer(admin_unit_id, admin_unit.name).id + event.event_place_id = _get_default_event_place_id(admin_unit_id) + event.organizer_id = _get_default_organizer_id(admin_unit_id) event.ticket_link = "" event.tags = "" event.price_info = "" @@ -185,4 +194,38 @@ def create_incoming_reference_request(admin_unit_id): click.echo(json.dumps(result)) +def _create_event_suggestion(admin_unit_id, free_text=False): + suggestion = EventSuggestion() + suggestion.admin_unit_id = admin_unit_id + suggestion.contact_name = "Vorname Nachname" + suggestion.contact_email = "vorname@nachname.de" + suggestion.contact_email_notice = False + suggestion.name = "Vorschlag" + suggestion.description = "Beschreibung" + suggestion.start = _get_now_by_minute() + suggestion.categories = [upsert_event_category("Other")] + + if free_text: + suggestion.event_place_text = "Freitext Ort" + suggestion.organizer_text = "Freitext Organisator" + else: + suggestion.event_place_id = _get_default_event_place_id(admin_unit_id) + suggestion.organizer_id = _get_default_organizer_id(admin_unit_id) + + insert_event_suggestion(suggestion) + db.session.commit() + return suggestion.id + + +@test_cli.command("suggestion-create") +@click.argument("admin_unit_id") +@click.option("--freetext/--no-freetext", default=False) +def create_event_suggestion(admin_unit_id, freetext): + event_suggestion_id = _create_event_suggestion(admin_unit_id, freetext) + result = { + "event_suggestion_id": event_suggestion_id, + } + click.echo(json.dumps(result)) + + app.cli.add_command(test_cli) diff --git a/project/forms/event_suggestion.py b/project/forms/event_suggestion.py index df4f3f5..8151402 100644 --- a/project/forms/event_suggestion.py +++ b/project/forms/event_suggestion.py @@ -116,7 +116,10 @@ class RejectEventSuggestionForm(FlaskForm): lazy_gettext("Rejection reason"), coerce=int, choices=[ - (0, ""), + ( + 0, + lazy_gettext("EventRejectionReason.noreason"), + ), ( int(EventRejectionReason.duplicate), lazy_gettext("EventRejectionReason.duplicate"), diff --git a/project/templates/event_suggestion/review.html b/project/templates/event_suggestion/review.html index 34c0e2b..c690ce1 100644 --- a/project/templates/event_suggestion/review.html +++ b/project/templates/event_suggestion/review.html @@ -1,9 +1,20 @@ {% extends "layout.html" %} {% set active_id = "reviews" %} -{% from "_macros.html" import render_event_suggestion, render_image, render_radio_buttons, render_phone_prop, render_email_prop, render_string_prop, render_field_with_errors, render_field, render_event_props, render_image_with_link, render_place, render_link_prop %} +{% from "_macros.html" import render_jquery_steps_header, render_event_suggestion, render_image, render_radio_buttons, render_phone_prop, render_email_prop, render_string_prop, render_field_with_errors, render_field, render_event_props, render_image_with_link, render_place, render_link_prop %} {%- block title -%} {{ event_suggestion.name }} {%- endblock -%} +{% block header_before_site_js %} +{{ render_jquery_steps_header() }} + +{% endblock %} {% block content %}

{{ _('Review event suggestion') }}

@@ -17,9 +28,33 @@ {{ _('View event') }} {% else %} -
+ + + {% endif %}
diff --git a/project/templates/reference_request/review.html b/project/templates/reference_request/review.html index f278c8f..3aead71 100644 --- a/project/templates/reference_request/review.html +++ b/project/templates/reference_request/review.html @@ -8,29 +8,6 @@