Simplify event creation localization and derive default language from ordered list - #4770
Simplify event creation localization and derive default language from ordered list#4770SxxAq wants to merge 6 commits into
Conversation
Thank you for contributingPlease complete the checklist. Screenshots in the PR description and completed AI reviews are checked automatically.
🤖 AI reviews❌ 2 failed or rate-limited AI reviewers
ℹ️ Does not count toward the checklist
📎 Attached media (1)Thank you for your contribution feel free to reach out if you have any questions. |
Reviewer's GuideEvent creation localization is refactored so the default language is derived from the ordered list of selected locales, using a new drag‑and‑drop tray and hidden input, with backend fallback logic and tests ensuring the first locale becomes the default. Sequence diagram for default locale derivation during event creationsequenceDiagram
actor Organizer
participant BrowserForm
participant EventCreateJS
participant EventWizardBasicsForm
participant EventCreateView
participant Event
Organizer->>BrowserForm: select foundation_form.locales
BrowserForm->>EventCreateJS: change event on foundation-locales
EventCreateJS->>EventCreateJS: syncLocaleOrder()
EventCreateJS->>EventCreateJS: updateLocaleOrderList()
EventCreateJS->>BrowserForm: set id_basics-locale (first locale)
EventCreateJS->>EventCreateJS: renderOrderTray()
Organizer->>BrowserForm: submit event create form
BrowserForm->>EventWizardBasicsForm: clean()
EventWizardBasicsForm->>EventWizardBasicsForm: if data.locale not in self.locales
EventWizardBasicsForm->>EventWizardBasicsForm: set data.locale = self.locales[0]
EventWizardBasicsForm-->>EventCreateView: basics_data with locale
EventCreateView->>EventCreateView: create_event()
EventCreateView->>EventCreateView: chosen_locale = basics_data.locale or foundation_data.locales[0]
EventCreateView->>EventCreateView: if chosen_locale not in foundation_data.locales
EventCreateView->>EventCreateView: chosen_locale = foundation_data.locales[0]
EventCreateView->>Event: update_language_configuration(locales, content_locales, chosen_locale)
EventCreateView-->>Organizer: event created with default_locale = first locale
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…q/eventyay into feature/simplify-event-localization
Follow-ups before mergeLooks good overall and matches the intent of #4697. Two small gaps still worth fixing: 1.
|
| <fieldset> | ||
| <legend>{% trans "Localization" %}</legend> | ||
| {% bootstrap_field foundation_form.locales layout="control" %} | ||
| {% bootstrap_field basics_form.locale layout="control" %} | ||
| <input type="hidden" name="basics-locale" id="id_basics-locale" value="{{ basics_form.locale.value|default:'' }}"> | ||
| </fieldset> |
There was a problem hiding this comment.
No-JS / Progressive Enhancement failure. Replacing the visible <select name="basics-locale"> dropdown with a <input type="hidden" name="basics-locale"> means if JavaScript is disabled or fails to load, basics-locale submits an empty value "". EventWizardBasicsForm rejects empty locale fields with a "This field is required" validation error, rendering the event creation form unusable without JS.
Resolution: Ensure value has a sensible default fallback (e.g. 'en' or foundation_form.locales.value.0) if basics_form.locale.value is empty.
| badge.addEventListener("dragstart", function (e) { | ||
| draggedCode = code; | ||
| badge.classList.add("dragging"); | ||
| e.dataTransfer.effectAllowed = "move"; | ||
| e.dataTransfer.setData("text/plain", code); | ||
| }); |
There was a problem hiding this comment.
Accessibility (a11y) failure. Drag-and-drop reordering relies solely on HTML5 Drag and Drop events (dragstart, dragover, drop). Mouse-only drag-and-drop cannot be operated using keyboard navigation (Tab / Arrow keys) or screen readers.
Resolution: Add keyboard event handlers (ArrowLeft/ArrowRight or reorder buttons) and ARIA attributes (role="option", tabindex="0") so keyboard users can reorder languages.
| e.dataTransfer.setData("text/plain", code); | ||
| }); | ||
|
|
||
| badge.addEventListener("dragend", function () { |
There was a problem hiding this comment.
Mobile touch screens unsupported. Standard HTML5 dragstart and drop events do not fire on mobile touch interfaces (iOS Safari / Android Chrome). Mobile users cannot drag badges to reorder default languages.
Resolution: Add touch event listeners or click-to-promote functionality so mobile users can tap a badge to set it as the default language.
| function updateLocaleOrderList() { | ||
| var checkedLocales = getCheckedLocalesFromDOM(); | ||
| var checkedSet = new Set(checkedLocales); | ||
|
|
||
| currentLocaleOrder = currentLocaleOrder.filter(function (code) { | ||
| return checkedSet.has(code); | ||
| }); |
There was a problem hiding this comment.
State loss on form re-validation. currentLocaleOrder is initialized to [] on script execution. When a form validation error occurs (e.g. missing event name) and the server re-renders the page, updateLocaleOrderList() populates currentLocaleOrder from checkbox DOM order, discarding the custom language order chosen prior to form submission.
Resolution: Read the initial value from id_basics-locale when populating currentLocaleOrder for the first time.



Summary
This PR simplifies the event creation localization workflow by removing the redundant Default language dropdown field from the event creation form. The default language is now automatically derived from the first language in the Event languages list.
Additionally, an interactive drag-and-drop tray is introduced so organizers can easily reorder selected languages to control which language acts as the default.
Closes #4697

Key Changes
Template (create.html)
Default languagedropdown field (basics_form.locale).basics-locale) and a drag-and-drop language ordering tray (#language-order-tray).Front-end JavaScript (event-create.js)
renderOrderTray()to display selected languages as draggable pills with a Default badge on the first pill.basics-localeinput synchronized with whichever language is first in the tray.Forms & Views (forms/event.py & views/event.py)
EventWizardBasicsForm.clean()andEventCreateView.create_event()with fallback logic to setdefault_localeto the first language inlocalesiflocaleis omitted or invalid.Acceptance Criteria Verification
Default languagedropdown.Event languagesis saved as the default language.Summary by Sourcery
Derive an event’s default language from the ordered list of selected locales and streamline the localization UX in the event creation flow.
New Features:
Bug Fixes:
Enhancements:
Tests: