From 302e2ec95996e4b9ed1c88cbfd4e3e7d50c00b8d Mon Sep 17 00:00:00 2001 From: Daniel Grams Date: Sat, 7 Aug 2021 12:45:24 +0200 Subject: [PATCH] Optimize organizer input #250 --- cypress/integration/event.js | 30 ++++++ cypress/support/commands.js | 16 ++++ messages.pot | 58 ++++++----- project/static/site.js | 7 ++ project/templates/_macros.html | 2 +- project/templates/event/create.html | 90 +++++++++++++++++- project/templates/event/update.html | 27 +++++- .../translations/de/LC_MESSAGES/messages.mo | Bin 28736 -> 28864 bytes .../translations/de/LC_MESSAGES/messages.po | 58 ++++++----- .../translations/en/LC_MESSAGES/messages.mo | Bin 3225 -> 3225 bytes .../translations/en/LC_MESSAGES/messages.po | 58 ++++++----- project/views/event.py | 25 ++--- 12 files changed, 280 insertions(+), 91 deletions(-) create mode 100644 cypress/integration/event.js diff --git a/cypress/integration/event.js b/cypress/integration/event.js new file mode 100644 index 0000000..784ea6a --- /dev/null +++ b/cypress/integration/event.js @@ -0,0 +1,30 @@ +describe('Event', () => { + it('creates event', () => { + cy.login() + cy.createAdminUnit().then(function(adminUnitId) { + cy.visit('/admin_unit/' + adminUnitId + '/events/create') + + cy.get('#name').type("Stadtfest") + + cy.select2('event_place_id', 'Neu') + cy.get('#new_event_place-location-city').type("Goslar") + cy.get('#new_place_container_search_link').click() + cy.select2('event_place_id', 'Gos', 'Goslar, 38640 Goslar') + + cy.select2('organizer_id', 'Neu') + cy.get('#new_organizer-location-city').type("Goslar") + cy.get('#new_organizer_container_search_link').click() + cy.select2('organizer_id', 'Mei', 'Meine Crew') + + cy.get('#submit').click() + cy.url().should('include', '/actions') + cy.get('div.alert').should('contain', 'Veranstaltung erfolgreich erstellt') + + cy.contains('a', 'Veranstaltung bearbeiten').click() + cy.url().should('include', '/update') + cy.get('#submit').click() + cy.url().should('include', '/manage/admin_unit/' + adminUnitId + '/events') + cy.get('div.alert').should('contain', 'Veranstaltung erfolgreich aktualisiert') + }) + }) + }) \ No newline at end of file diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 17fad94..f4aa8a4 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -60,3 +60,19 @@ Cypress.Commands.add('login', (email = "test@test.de", password = "password") => cy.url().should('include', '/manage') cy.getCookie('session').should('exist') }) + +Cypress.Commands.add('select2', (selectId, textToEnter, expectedText = null, expectedValue = null) => { + cy.get('#select2-' + selectId + '-container').click() + cy.get('input[aria-controls="select2-' + selectId + '-results"]') + .type(textToEnter + '{enter}', { + delay: 500, + }) + + if (expectedText) { + cy.get('#select2-' + selectId + '-container').should('have.text', expectedText) + } + + if (expectedValue) { + cy.get('#' + selectId).should('have.value', expectedValue) + } +}) \ No newline at end of file diff --git a/messages.pot b/messages.pot index b0ea7ea..af6336b 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-06 13:48+0200\n" +"POT-Creation-Date: 2021-08-07 11:28+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -647,8 +647,8 @@ msgstr "" #: project/forms/event.py:233 project/forms/reference.py:14 #: project/forms/reference.py:27 project/forms/reference_request.py:75 -#: project/templates/event/create.html:323 -#: project/templates/event/update.html:183 +#: project/templates/event/create.html:403 +#: project/templates/event/update.html:206 msgid "Rating" msgstr "" @@ -662,8 +662,8 @@ msgstr "" #: project/forms/event.py:245 project/forms/event.py:254 #: project/forms/event.py:318 project/forms/event_suggestion.py:50 #: project/templates/_macros.html:462 project/templates/_macros.html:618 -#: project/templates/event/create.html:248 -#: project/templates/event/update.html:133 +#: project/templates/event/create.html:328 +#: project/templates/event/update.html:156 #: project/templates/event_place/create.html:21 #: project/templates/event_place/delete.html:13 #: project/templates/event_place/update.html:21 @@ -681,8 +681,8 @@ msgstr "" #: project/forms/event.py:261 project/forms/event.py:270 #: project/forms/event.py:326 project/forms/event.py:376 #: project/forms/event_suggestion.py:60 project/templates/_macros.html:500 -#: project/templates/_macros.html:655 project/templates/event/create.html:223 -#: project/templates/event/update.html:124 +#: project/templates/_macros.html:655 project/templates/event/create.html:299 +#: project/templates/event/update.html:147 #: project/templates/organizer/create.html:17 #: project/templates/organizer/delete.html:13 #: project/templates/organizer/update.html:17 @@ -698,7 +698,7 @@ msgid "Enter new organizer" msgstr "" #: project/forms/event.py:276 project/templates/event/create.html:4 -#: project/templates/event/create.html:195 project/templates/layout.html:254 +#: project/templates/event/create.html:271 project/templates/layout.html:254 #: project/templates/manage/events.html:12 #: project/templates/manage/organizers.html:21 msgid "Create event" @@ -724,7 +724,7 @@ msgid "" "Organizers." msgstr "" -#: project/forms/event.py:335 project/templates/event/update.html:114 +#: project/forms/event.py:335 project/templates/event/update.html:137 #: project/templates/oauth2_token/list.html:21 msgid "Status" msgstr "" @@ -758,7 +758,7 @@ msgid "Select the status of the event." msgstr "" #: project/forms/event.py:347 project/templates/event/update.html:4 -#: project/templates/event/update.html:86 +#: project/templates/event/update.html:109 msgid "Update event" msgstr "" @@ -846,13 +846,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:253 +#: project/forms/event_suggestion.py:52 project/templates/event/create.html:333 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:227 +#: project/forms/event_suggestion.py:62 project/templates/event/create.html:303 msgid "" "Select the organizer. If the organizer is not yet on the list, just enter" " it." @@ -1059,9 +1059,9 @@ msgstr "" #: project/templates/_macros.html:402 project/templates/_macros.html:578 #: project/templates/event/actions.html:12 -#: project/templates/event/create.html:202 +#: project/templates/event/create.html:278 #: project/templates/event/delete.html:13 -#: project/templates/event/update.html:93 +#: project/templates/event/update.html:116 #: project/templates/reference/delete.html:13 #: project/templates/widget/event_suggestion/create.html:197 msgid "Event" @@ -1348,8 +1348,8 @@ msgstr "" #: project/templates/admin_unit/create.html:49 #: project/templates/admin_unit/update.html:50 -#: project/templates/event/create.html:311 -#: project/templates/event/update.html:171 +#: project/templates/event/create.html:391 +#: project/templates/event/update.html:194 #: project/templates/event_place/create.html:47 #: project/templates/event_place/update.html:47 #: project/templates/organizer/create.html:46 @@ -1460,26 +1460,36 @@ msgid "Enter place or address" msgstr "" #: project/templates/event/create.html:97 +#: project/templates/event/create.html:210 #, python-format msgid "Just use %(term)s" msgstr "" -#: project/templates/event/create.html:212 -#: project/templates/event/update.html:103 +#: project/templates/event/create.html:200 +#: project/templates/event/update.html:96 +msgid "Enter organizer" +msgstr "" + +#: project/templates/event/create.html:288 +#: project/templates/event/update.html:126 msgid "Event date" msgstr "" -#: project/templates/event/create.html:273 +#: project/templates/event/create.html:320 +msgid "Switch to organizer search" +msgstr "" + +#: project/templates/event/create.html:353 msgid "Switch to place search" msgstr "" -#: project/templates/event/create.html:284 -#: project/templates/event/update.html:144 +#: project/templates/event/create.html:364 +#: project/templates/event/update.html:167 msgid "Access" msgstr "" -#: project/templates/event/create.html:298 -#: project/templates/event/update.html:158 +#: project/templates/event/create.html:378 +#: project/templates/event/update.html:181 msgid "Target group" msgstr "" @@ -1783,7 +1793,7 @@ msgstr "" msgid "Event successfully deleted" msgstr "" -#: project/views/event.py:380 +#: project/views/event.py:384 msgid "Referenced event changed" msgstr "" diff --git a/project/static/site.js b/project/static/site.js index 60e0476..ef3d956 100644 --- a/project/static/site.js +++ b/project/static/site.js @@ -254,6 +254,13 @@ function reset_place_form(prefix = '') { $('#' + prefix + 'location-longitude').val(''); } +function reset_organizer_form(prefix = '') { + $('#' + prefix + 'name').val(''); + $('#' + prefix + 'location-street').val(''); + $('#' + prefix + 'location-postalCode').val(''); + $('#' + prefix + 'location-city').val(''); +} + function fill_place_form_with_gmaps_place(place, prefix = '', location_only = false) { var street_number = ""; var route = ""; diff --git a/project/templates/_macros.html b/project/templates/_macros.html index a76d8d0..f12265a 100644 --- a/project/templates/_macros.html +++ b/project/templates/_macros.html @@ -10,7 +10,7 @@ {% set is_required = kwargs['is_required'] if 'is_required' in kwargs else field.flags.required %} {% set label_text = field.label.text + ' *' if is_required else field.label.text %}
- {% if 'ri' in kwargs and kwargs['ri'] == 'checkbox' %} + {% if 'label_hidden' in kwargs or ('ri' in kwargs and kwargs['ri'] == 'checkbox') %} {% else %} {{ field.label(text=label_text, class="mb-0") }} {% endif %} diff --git a/project/templates/event/create.html b/project/templates/event/create.html index 2d84954..178d156 100644 --- a/project/templates/event/create.html +++ b/project/templates/event/create.html @@ -37,8 +37,8 @@ $( function() { } }, organizer_id: { - min: { - param: 1, + required: { + param: true, depends: function(element) { return $('input[type=radio][name=organizer_choice]:checked').val() == "1"; } @@ -176,6 +176,75 @@ $( function() { } } + $('#organizer_id').select2({ + width: '100%', + theme: 'bootstrap4', + tags: true, + ajax: { + url: "{{ url_for('api_v1_organization_organizer_list', id=admin_unit.id) }}", + dataType: 'json', + delay: 250, + cache: true, + data: function (params) { + return { + name: params.term, + per_page: 5 + }; + }, + processResults: function (data) { + return { + results: data.items.map(p => ({"id": p.id, "text": p.name})) + }; + } + }, + placeholder: "{{ _('Enter organizer') }}", + createTag: function (params) { + var term = $.trim(params.term); + + if (term === '') { + return null; + } + + return { + id: term, + text: "{{ _('Just use %(term)s', term='%(term)s') }}".replace("%(term)s", term), + term: term, + is_new_tag: true + } + }, + insertTag: function (data, tag) { + data.push(tag); + }, + templateResult: function (state) { + if ("is_new_tag" in state) { + return $("" + state.text + ""); + } + return state.text; + } + }); + + $('#organizer_id').on('select2:close', function (e) { + var dataArray = $(e.target).select2('data'); + var data = {}; + + if (dataArray.length > 0) { + data = dataArray[0]; + } + + if ("is_new_tag" in data) { + $(this).val(null).trigger('change'); + $('input[type=radio][name=organizer_choice][value=2]').click(); + reset_organizer_form('new_organizer-'); + + $('#new_organizer-name').val(data.term); + + $('#new_organizer_container').find(':input').valid(); + $(this).removeClass('is-valid'); + } else { + $(this).valid(); + } + }); + $('input[type=radio][name=organizer_choice]').on('change', function() { update_organizer_container($(this).val()); }); @@ -184,6 +253,13 @@ $( function() { $(this).valid(); }); + $('#new_organizer_container_search_link').click(function(e){ + e.preventDefault(); + e.stopPropagation(); + reset_organizer_form('new_organizer-'); + $('input[type=radio][name=organizer_choice][value=1]').click(); + }); + update_organizer_container($('input[type=radio][name=organizer_choice]:checked').val()); {{ render_end_container_handling() }} @@ -225,11 +301,11 @@ $( function() {
{{ _("Select the organizer. If the organizer is not yet on the list, just enter it.") }}
- {{ render_radio_buttons(form.organizer_choice) }} +
{{ render_radio_buttons(form.organizer_choice) }}
- {{ render_field_with_errors(form.organizer_id, class="autocomplete w-100", is_required=True) }} + {{ render_field_with_errors(form.organizer_id, class="w-100", label_hidden=True) }}
@@ -239,6 +315,10 @@ $( function() { {{ render_field_with_errors(form.new_organizer.form.location.street) }} {{ render_field_with_errors(form.new_organizer.form.location.postalCode) }} {{ render_field_with_errors(form.new_organizer.form.location.city) }} + +
@@ -255,7 +335,7 @@ $( function() {
- {{ render_field_with_errors(form.event_place_id, class="w-100", is_required=True) }} + {{ render_field_with_errors(form.event_place_id, class="w-100", label_hidden=True) }}
diff --git a/project/templates/event/update.html b/project/templates/event/update.html index 31c7c7e..790035f 100644 --- a/project/templates/event/update.html +++ b/project/templates/event/update.html @@ -73,6 +73,29 @@ placeholder: "{{ _('Enter place or address') }}" }); + $('#organizer_id').select2({ + width: '100%', + theme: 'bootstrap4', + ajax: { + url: "{{ url_for('api_v1_organization_organizer_list', id=event.admin_unit.id) }}", + dataType: 'json', + delay: 250, + cache: true, + data: function (params) { + return { + name: params.term, + per_page: 5 + }; + }, + processResults: function (data) { + return { + results: data.items.map(p => ({"id": p.id, "text": p.name})) + }; + } + }, + placeholder: "{{ _('Enter organizer') }}" + }); + $('#organizer_id,#event_place_id').on('select2:select', function (e) { $(this).valid(); }); @@ -124,7 +147,7 @@ {{ _('Organizer') }}
- {{ render_field_with_errors(form.organizer_id, class="autocomplete w-100") }} + {{ render_field_with_errors(form.organizer_id, class="w-100", label_hidden=True) }}
@@ -133,7 +156,7 @@ {{ _('Place') }}
- {{ render_field_with_errors(form.event_place_id, class="w-100") }} + {{ render_field_with_errors(form.event_place_id, class="w-100", label_hidden=True) }}
diff --git a/project/translations/de/LC_MESSAGES/messages.mo b/project/translations/de/LC_MESSAGES/messages.mo index 603ae8f9327d29175a61ca7fd8946d02b09fcb68..9476bdca71b9b0e6ea546cf603b17454d07f44e0 100644 GIT binary patch delta 6803 zcmYk<2~?L=8prV~D9GXhh=LodBnToZN?IbgWQJfVuBd^cpr(`Pv9x+!7;D;{Oq|j( zvc=N0ACn zxAIO!wtn34&r_|O>yF{=RQumQzs5S(m+EDV#`Lbv@u)9HaSFDihMkVV+oGHN({xFs0r(_BOb;O{2aBA zCe(B1u`T|9z3?~GJjp$rt6+XtKtU_og9-RIoQ&tN81o3f0BbNA|A|Uv2x&{j_85;j zsQ0H@eI+u4+l*SsUQ|X7p)&bCdYZVAf+9bQTKPrngjX;fJH`7M$U}m6h1dlbptfc$ zDg!mBOudMDZx6Cd?hGp6%czM1h*B8}O(6f8D1rvPn1Tvu0BWyBp$48{{d25-J1WpM zsDam`R=5$hkXlsAcUXN7YO5Mh&mTi=O=E)R7rvrF1D;2vs0FpMD;S7TiJSxMf?8Px zX5izfEqDj3@n5L-mL&NTt}{2H4(0PW1>eF^*x5_=2P#1gbU*gR*DwW}FbzXFIjU!) zQd)v-a5-w_ccU`)2h_@HP#LX7t$Y`9zFhwu5sa>mOjOFpq9&Zqf4KT? z4QhbRsORcYfgVR?B!DBGiJ7R(%);4(K;K$_E7GNUEb948tKWbMbOv&M-JPiW|0fK>dJMq^4AuRAmx5B&h+6q+ zR4SWMsa4qO4@dRKT0ISQW(K34A8k&w{xa12i_Mj&t+*HUe2v!y)EqYrh2xXrGLp2HIvFFQX#djcswi zwZDs%)IY#%%t?2y2p1ve)9pi!fosA67@EOn7>8jStU_(coy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JkJ=@=cMAX1TP}gr1reP_Lz=hWS7IvW?yiGyZ<`gOk z&zoV)qIxoFz(Q2647Pd^Mo_=SoQ&GYbktGahkAdNxgNEU&8X17i$p4LjTCy&5HZ*P z6KikGqF#eH;9s!-&)@)zpGVlR6u06NsDb<5<^LUEDvqZ9G-`)uQIU0b`vqlS4Anf0 z)cqeoK`R=8+QDS2FEDGc6YWo$Z=iPgA?k>}G~Ilk3!PAr%fUW43Y81XP&reJO3Ifo zlKEW&1)b#)HQ*K01R)FjKPo4p+Mh**^hMN>>_8pCF1#M=F%Eygp%{9PPri|uP5oXh z#Ai_pIEF1pQTTyE3mjP2+;MYM-7D$;>`=FQz}oQeKB>J6`d?qyZP?k^x|Gtr9qX>n Hc`xFBZw~Yt diff --git a/project/translations/de/LC_MESSAGES/messages.po b/project/translations/de/LC_MESSAGES/messages.po index da760e3..14e9c68 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: 2021-08-06 13:48+0200\n" +"POT-Creation-Date: 2021-08-07 11:28+0200\n" "PO-Revision-Date: 2020-06-07 18:51+0200\n" "Last-Translator: FULL NAME \n" "Language: de\n" @@ -674,8 +674,8 @@ msgstr "Wähle Kategorien, die zur Veranstaltung passen." #: project/forms/event.py:233 project/forms/reference.py:14 #: project/forms/reference.py:27 project/forms/reference_request.py:75 -#: project/templates/event/create.html:323 -#: project/templates/event/update.html:183 +#: project/templates/event/create.html:403 +#: project/templates/event/update.html:206 msgid "Rating" msgstr "Bewertung" @@ -691,8 +691,8 @@ msgstr "" #: project/forms/event.py:245 project/forms/event.py:254 #: project/forms/event.py:318 project/forms/event_suggestion.py:50 #: project/templates/_macros.html:462 project/templates/_macros.html:618 -#: project/templates/event/create.html:248 -#: project/templates/event/update.html:133 +#: project/templates/event/create.html:328 +#: project/templates/event/update.html:156 #: project/templates/event_place/create.html:21 #: project/templates/event_place/delete.html:13 #: project/templates/event_place/update.html:21 @@ -710,8 +710,8 @@ msgstr "Neuen Ort eingeben" #: project/forms/event.py:261 project/forms/event.py:270 #: project/forms/event.py:326 project/forms/event.py:376 #: project/forms/event_suggestion.py:60 project/templates/_macros.html:500 -#: project/templates/_macros.html:655 project/templates/event/create.html:223 -#: project/templates/event/update.html:124 +#: project/templates/_macros.html:655 project/templates/event/create.html:299 +#: project/templates/event/update.html:147 #: project/templates/organizer/create.html:17 #: project/templates/organizer/delete.html:13 #: project/templates/organizer/update.html:17 @@ -727,7 +727,7 @@ msgid "Enter new organizer" msgstr "Neuen Veranstalter eingeben" #: project/forms/event.py:276 project/templates/event/create.html:4 -#: project/templates/event/create.html:195 project/templates/layout.html:254 +#: project/templates/event/create.html:271 project/templates/layout.html:254 #: project/templates/manage/events.html:12 #: project/templates/manage/organizers.html:21 msgid "Create event" @@ -757,7 +757,7 @@ msgstr "" "Wähle den Veranstalter. Du kannst Veranstalter unter Verwaltung > " "Veranstalter hinzufügen und ändern." -#: project/forms/event.py:335 project/templates/event/update.html:114 +#: project/forms/event.py:335 project/templates/event/update.html:137 #: project/templates/oauth2_token/list.html:21 msgid "Status" msgstr "Status" @@ -791,7 +791,7 @@ msgid "Select the status of the event." msgstr "Wähle den Status der Veranstaltung." #: project/forms/event.py:347 project/templates/event/update.html:4 -#: project/templates/event/update.html:86 +#: project/templates/event/update.html:109 msgid "Update event" msgstr "Veranstaltung aktualisieren" @@ -879,7 +879,7 @@ msgstr "Bitte gib deine Email-Adresse oder deine Telefonnummer für die Prüfung msgid "I would like to be notified by email after the review" msgstr "Ich möchte per Email benachrichtigt werden nach der Prüfung" -#: project/forms/event_suggestion.py:52 project/templates/event/create.html:253 +#: project/forms/event_suggestion.py:52 project/templates/event/create.html:333 msgid "" "Choose where the event takes place. If the venue is not yet in the list, " "just enter it." @@ -887,7 +887,7 @@ msgstr "" "Wähle aus, wo die Veranstaltung stattfindet. Ist der Veranstaltungsort " "noch nicht in der Liste, trage ihn einfach ein." -#: project/forms/event_suggestion.py:62 project/templates/event/create.html:227 +#: project/forms/event_suggestion.py:62 project/templates/event/create.html:303 msgid "" "Select the organizer. If the organizer is not yet on the list, just enter" " it." @@ -1096,9 +1096,9 @@ msgstr "Zuletzt aktualisiert am %(updated_at)s." #: project/templates/_macros.html:402 project/templates/_macros.html:578 #: project/templates/event/actions.html:12 -#: project/templates/event/create.html:202 +#: project/templates/event/create.html:278 #: project/templates/event/delete.html:13 -#: project/templates/event/update.html:93 +#: project/templates/event/update.html:116 #: project/templates/reference/delete.html:13 #: project/templates/widget/event_suggestion/create.html:197 msgid "Event" @@ -1387,8 +1387,8 @@ msgstr "Bearbeiten" #: project/templates/admin_unit/create.html:49 #: project/templates/admin_unit/update.html:50 -#: project/templates/event/create.html:311 -#: project/templates/event/update.html:171 +#: project/templates/event/create.html:391 +#: project/templates/event/update.html:194 #: project/templates/event_place/create.html:47 #: project/templates/event_place/update.html:47 #: project/templates/organizer/create.html:46 @@ -1501,26 +1501,36 @@ msgid "Enter place or address" msgstr "Orte oder Adresse eingeben" #: project/templates/event/create.html:97 +#: project/templates/event/create.html:210 #, python-format msgid "Just use %(term)s" msgstr "Verwende einfach %(term)s" -#: project/templates/event/create.html:212 -#: project/templates/event/update.html:103 +#: project/templates/event/create.html:200 +#: project/templates/event/update.html:96 +msgid "Enter organizer" +msgstr "Veranstalter eingeben" + +#: project/templates/event/create.html:288 +#: project/templates/event/update.html:126 msgid "Event date" msgstr "Termin" -#: project/templates/event/create.html:273 +#: project/templates/event/create.html:320 +msgid "Switch to organizer search" +msgstr "Zur Veranstaltersuche wechseln" + +#: project/templates/event/create.html:353 msgid "Switch to place search" msgstr "Zur Ortssuche wechseln" -#: project/templates/event/create.html:284 -#: project/templates/event/update.html:144 +#: project/templates/event/create.html:364 +#: project/templates/event/update.html:167 msgid "Access" msgstr "Zugang" -#: project/templates/event/create.html:298 -#: project/templates/event/update.html:158 +#: project/templates/event/create.html:378 +#: project/templates/event/update.html:181 msgid "Target group" msgstr "Zielgruppe" @@ -1827,7 +1837,7 @@ msgstr "Der eingegebene Name entspricht nicht dem Namen der Veranstaltung" msgid "Event successfully deleted" msgstr "Veranstaltung erfolgreich gelöscht" -#: project/views/event.py:380 +#: project/views/event.py:384 msgid "Referenced event changed" msgstr "Empfohlene Veranstaltung wurde geändert" diff --git a/project/translations/en/LC_MESSAGES/messages.mo b/project/translations/en/LC_MESSAGES/messages.mo index 07ccd8f6c326b0cb2d388387b17249d45227e283..bd9a4fc5f671ff7e811b3d4d1ec39898407fb00f 100644 GIT binary patch delta 19 bcmbO!Ia6}OV-7ZR1w%tCqs=clHZTJKLXif7 delta 19 bcmbO!Ia6}OV-7Ym1w&&ilg%$VHZTJKLZSwR diff --git a/project/translations/en/LC_MESSAGES/messages.po b/project/translations/en/LC_MESSAGES/messages.po index ed92e3f..da0f454 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: 2021-08-06 13:48+0200\n" +"POT-Creation-Date: 2021-08-07 11:28+0200\n" "PO-Revision-Date: 2021-04-30 15:04+0200\n" "Last-Translator: FULL NAME \n" "Language: en\n" @@ -648,8 +648,8 @@ msgstr "" #: project/forms/event.py:233 project/forms/reference.py:14 #: project/forms/reference.py:27 project/forms/reference_request.py:75 -#: project/templates/event/create.html:323 -#: project/templates/event/update.html:183 +#: project/templates/event/create.html:403 +#: project/templates/event/update.html:206 msgid "Rating" msgstr "" @@ -663,8 +663,8 @@ msgstr "" #: project/forms/event.py:245 project/forms/event.py:254 #: project/forms/event.py:318 project/forms/event_suggestion.py:50 #: project/templates/_macros.html:462 project/templates/_macros.html:618 -#: project/templates/event/create.html:248 -#: project/templates/event/update.html:133 +#: project/templates/event/create.html:328 +#: project/templates/event/update.html:156 #: project/templates/event_place/create.html:21 #: project/templates/event_place/delete.html:13 #: project/templates/event_place/update.html:21 @@ -682,8 +682,8 @@ msgstr "" #: project/forms/event.py:261 project/forms/event.py:270 #: project/forms/event.py:326 project/forms/event.py:376 #: project/forms/event_suggestion.py:60 project/templates/_macros.html:500 -#: project/templates/_macros.html:655 project/templates/event/create.html:223 -#: project/templates/event/update.html:124 +#: project/templates/_macros.html:655 project/templates/event/create.html:299 +#: project/templates/event/update.html:147 #: project/templates/organizer/create.html:17 #: project/templates/organizer/delete.html:13 #: project/templates/organizer/update.html:17 @@ -699,7 +699,7 @@ msgid "Enter new organizer" msgstr "" #: project/forms/event.py:276 project/templates/event/create.html:4 -#: project/templates/event/create.html:195 project/templates/layout.html:254 +#: project/templates/event/create.html:271 project/templates/layout.html:254 #: project/templates/manage/events.html:12 #: project/templates/manage/organizers.html:21 msgid "Create event" @@ -725,7 +725,7 @@ msgid "" "Organizers." msgstr "" -#: project/forms/event.py:335 project/templates/event/update.html:114 +#: project/forms/event.py:335 project/templates/event/update.html:137 #: project/templates/oauth2_token/list.html:21 msgid "Status" msgstr "" @@ -759,7 +759,7 @@ msgid "Select the status of the event." msgstr "" #: project/forms/event.py:347 project/templates/event/update.html:4 -#: project/templates/event/update.html:86 +#: project/templates/event/update.html:109 msgid "Update event" msgstr "" @@ -847,13 +847,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:253 +#: project/forms/event_suggestion.py:52 project/templates/event/create.html:333 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:227 +#: project/forms/event_suggestion.py:62 project/templates/event/create.html:303 msgid "" "Select the organizer. If the organizer is not yet on the list, just enter" " it." @@ -1060,9 +1060,9 @@ msgstr "" #: project/templates/_macros.html:402 project/templates/_macros.html:578 #: project/templates/event/actions.html:12 -#: project/templates/event/create.html:202 +#: project/templates/event/create.html:278 #: project/templates/event/delete.html:13 -#: project/templates/event/update.html:93 +#: project/templates/event/update.html:116 #: project/templates/reference/delete.html:13 #: project/templates/widget/event_suggestion/create.html:197 msgid "Event" @@ -1349,8 +1349,8 @@ msgstr "" #: project/templates/admin_unit/create.html:49 #: project/templates/admin_unit/update.html:50 -#: project/templates/event/create.html:311 -#: project/templates/event/update.html:171 +#: project/templates/event/create.html:391 +#: project/templates/event/update.html:194 #: project/templates/event_place/create.html:47 #: project/templates/event_place/update.html:47 #: project/templates/organizer/create.html:46 @@ -1461,26 +1461,36 @@ msgid "Enter place or address" msgstr "" #: project/templates/event/create.html:97 +#: project/templates/event/create.html:210 #, python-format msgid "Just use %(term)s" msgstr "" -#: project/templates/event/create.html:212 -#: project/templates/event/update.html:103 +#: project/templates/event/create.html:200 +#: project/templates/event/update.html:96 +msgid "Enter organizer" +msgstr "" + +#: project/templates/event/create.html:288 +#: project/templates/event/update.html:126 msgid "Event date" msgstr "" -#: project/templates/event/create.html:273 +#: project/templates/event/create.html:320 +msgid "Switch to organizer search" +msgstr "" + +#: project/templates/event/create.html:353 msgid "Switch to place search" msgstr "" -#: project/templates/event/create.html:284 -#: project/templates/event/update.html:144 +#: project/templates/event/create.html:364 +#: project/templates/event/update.html:167 msgid "Access" msgstr "" -#: project/templates/event/create.html:298 -#: project/templates/event/update.html:158 +#: project/templates/event/create.html:378 +#: project/templates/event/update.html:181 msgid "Target group" msgstr "" @@ -1784,7 +1794,7 @@ msgstr "" msgid "Event successfully deleted" msgstr "" -#: project/views/event.py:380 +#: project/views/event.py:384 msgid "Referenced event changed" msgstr "" diff --git a/project/views/event.py b/project/views/event.py index 1ce4b4d..1d0cd88 100644 --- a/project/views/event.py +++ b/project/views/event.py @@ -5,7 +5,6 @@ from flask import flash, jsonify, redirect, render_template, request, url_for from flask_babelex import gettext from flask_security import auth_required, current_user from sqlalchemy.exc import SQLAlchemyError -from sqlalchemy.sql import func from project import app, db from project.access import ( @@ -102,8 +101,7 @@ def event_create_for_admin_unit_id(id): form = CreateEventForm( admin_unit_id=admin_unit.id, category_ids=[upsert_event_category("Other").id] ) - prepare_event_form(form, admin_unit) - form.organizer_id.choices.insert(0, (0, "")) + prepare_event_form(form) # Vorlagen event_suggestion = None @@ -116,6 +114,7 @@ def event_create_for_admin_unit_id(id): event_template = Event.query.get_or_404(event_template_id) if not form.is_submitted(): form.process(obj=event_template) + prepare_organizer(form) prepare_event_place(form) if not event_template: @@ -189,7 +188,7 @@ def event_update(event_id): access_or_401(event.admin_unit, "event:update") form = UpdateEventForm(obj=event, start=event.start, end=event.end) - prepare_event_form(form, event.admin_unit) + prepare_event_form(form) if not form.is_submitted(): form.category_ids.data = [c.id for c in event.categories] @@ -278,15 +277,18 @@ def prepare_event_place(form): form.event_place_id.choices = [(place.id, get_place_str(place))] -def prepare_event_form(form, admin_unit): - form.organizer_id.choices = [ - (o.id, o.name) - for o in EventOrganizer.query.filter( - EventOrganizer.admin_unit_id == admin_unit.id - ).order_by(func.lower(EventOrganizer.name)) - ] +def prepare_organizer(form): + if form.organizer_id.data and form.organizer_id.data > 0: + organizer = EventOrganizer.query.get(form.organizer_id.data) + + if organizer: + form.organizer_id.choices = [(organizer.id, organizer.name)] + + +def prepare_event_form(form): form.category_ids.choices = get_event_category_choices() + prepare_organizer(form) prepare_event_place(form) if not form.start.data: @@ -332,6 +334,7 @@ def prepare_event_form_for_suggestion(form, event_suggestion): form.organizer_choice.data = 2 form.new_organizer.form.name.data = event_suggestion.organizer_text + prepare_organizer(form) prepare_event_place(form)