-
Notifications
You must be signed in to change notification settings - Fork 166
feat: Add Active Languages and Content Languages to event creation form #1497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: enext
Are you sure you want to change the base?
feat: Add Active Languages and Content Languages to event creation form #1497
Conversation
Reviewer's GuideAdds a separate Content Languages field to the event creation foundation step, validates it as a subset of Active Languages, wires it through the event wizard flow, and updates templates and defaults accordingly. Sequence diagram for event creation wizard handling active and content languagessequenceDiagram
actor Organizer
participant Wizard as EventCreationWizard
participant FoundationForm as EventWizardFoundationForm
participant BasicsForm as EventWizardBasicsForm
participant Event as EventSettings
Organizer->>Wizard: Start event creation
Wizard->>Wizard: get_form_initial(step = foundation)
Wizard->>Wizard: initial.locales = [en]
Wizard->>Wizard: initial.content_locales = [en]
Organizer->>FoundationForm: Submit foundation step
FoundationForm->>FoundationForm: clean()
FoundationForm->>FoundationForm: Validate content_locales ⊆ locales
alt Invalid content_locales
FoundationForm-->>Organizer: ValidationError on content_locales
else Valid or empty content_locales
FoundationForm-->>Wizard: cleaned_data with locales, content_locales
end
Organizer->>BasicsForm: Proceed to basics step
Wizard->>BasicsForm: __init__(..., content_locales)
BasicsForm->>BasicsForm: kwargs.pop(content_locales, None)
BasicsForm-->>Wizard: basics_data
Organizer->>Wizard: Finish wizard
Wizard->>Wizard: foundation_data = storage.get_step_data(foundation)
Wizard->>Wizard: content_locales = foundation_data.content_locales or foundation_data.locales
Wizard->>Event: set(locales, foundation_data.locales)
Wizard->>Event: set(content_locales, content_locales)
Wizard-->>Organizer: Event created with active and content languages
Updated class diagram for event creation forms and settingsclassDiagram
class EventWizardFoundationForm {
+MultipleChoiceField locales
+MultipleChoiceField content_locales
+BooleanField has_subevents
+__init__(*args, **kwargs)
+clean()
}
class EventWizardBasicsForm {
+__init__(*args, **kwargs)
}
class EventCreationWizardView {
+get_form_initial(step)
+done(form_list, form_dict, **kwargs)
}
class EventSettings {
+set(key, value)
+get(key, as_type)
+locale
+locales
}
EventCreationWizardView --> EventWizardFoundationForm : uses
EventCreationWizardView --> EventWizardBasicsForm : uses
EventCreationWizardView --> EventSettings : configures
EventWizardBasicsForm --> EventSettings : reads timezone, locale
EventWizardFoundationForm --> EventSettings : defines locales, content_locales
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- The
cleanmethod onEventWizardFoundationFormraisesValidationError, but there’s no import shown in this file diff; verify thatValidationErroris imported fromdjango.core.exceptions(or useforms.ValidationError) to avoid a runtime error. - Since
content_localesmust always be a subset oflocales, consider mentioning this constraint explicitly in thecontent_localeshelp text so users understand why some options may be unavailable or cause validation errors.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `clean` method on `EventWizardFoundationForm` raises `ValidationError`, but there’s no import shown in this file diff; verify that `ValidationError` is imported from `django.core.exceptions` (or use `forms.ValidationError`) to avoid a runtime error.
- Since `content_locales` must always be a subset of `locales`, consider mentioning this constraint explicitly in the `content_locales` help text so users understand why some options may be unavailable or cause validation errors.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request adds separate configuration for active languages and content languages in the event creation wizard. Active languages control which languages the eventyay interface is available in, while content languages specifically control which languages users can submit proposals in. The change ensures content languages are validated to be a subset of active languages, preventing invalid configuration states.
Key changes:
- Added a dedicated
content_localesfield to the event foundation form with appropriate validation - Grouped language settings under a "Localization" section in the UI for better organization
- Updated help text to clearly distinguish between active languages and content languages
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
app/eventyay/control/forms/event.py |
Added content_locales field to EventWizardFoundationForm with validation ensuring it's a subset of active languages; updated help text for both locale fields; added logic to pop content_locales from kwargs in EventWizardBasicsForm |
app/eventyay/eventyay_common/views/event.py |
Added default initialization of content_locales to ['en']; updated done() method to use content_locales from form data with fallback to locales |
app/eventyay/eventyay_common/templates/eventyay_common/events/create_foundation.html |
Wrapped language fields in a fieldset with "Localization" legend; added content_locales field to the form |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
df99656 to
896fd23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
app/eventyay/control/forms/event.py
Outdated
| label=_('Active languages'), | ||
| widget=MultipleLanguagesWidget, | ||
| help_text=_('Choose all languages that your event should be available in.'), | ||
| help_text=_( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This help text is too long, is it necessary?
app/eventyay/control/forms/event.py
Outdated
| locales = cleaned_data.get('locales', []) | ||
| content_locales = cleaned_data.get('content_locales') | ||
|
|
||
| if not isinstance(locales, list): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MultipleChoiceField already guarantees this value to be a list, the isinstance is not necessary.
If your purpose is to help Pyright / your IDE infer type correctly, you can use:
assert isinstance(locales, list)to keep the code flat.
app/eventyay/control/forms/event.py
Outdated
| if not isinstance(locales, list): | ||
| locales = list(locales) | ||
|
|
||
| if content_locales is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is too deeply nested, try to make code flatter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| assert isinstance(locales, list) | ||
|
|
||
| if content_locales is None or not content_locales: | ||
| return cleaned_data | ||
|
|
||
| assert isinstance(content_locales, list) |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using assertions for runtime validation is inappropriate. Assertions can be disabled with Python's -O flag and are meant for debugging, not user input validation. Replace with proper error handling that raises a ValidationError with a clear message if the type check fails.
| assert isinstance(locales, list) | |
| if content_locales is None or not content_locales: | |
| return cleaned_data | |
| assert isinstance(content_locales, list) | |
| if not isinstance(locales, list): | |
| raise ValidationError({'locales': _('Active languages data is invalid.')}) | |
| if content_locales is None or not content_locales: | |
| return cleaned_data | |
| if not isinstance(content_locales, list): | |
| raise ValidationError({'content_locales': _('Content languages data is invalid.')}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hongquan shall I revert it back then
| if content_locales is None or not content_locales: | ||
| return cleaned_data | ||
|
|
||
| assert isinstance(content_locales, list) |
Copilot
AI
Dec 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using assertions for runtime validation is inappropriate. Assertions can be disabled with Python's -O flag and are meant for debugging, not user input validation. Replace with proper error handling that raises a ValidationError with a clear message if the type check fails.
| assert isinstance(content_locales, list) | |
| if not isinstance(content_locales, list): | |
| raise ValidationError({ | |
| 'content_locales': _('Content languages must be provided as a list.') | |
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
Screen.Recording.2025-12-13.at.7.38.19.PM.mov
fixes #1472
Summary by Sourcery
Add separate active language and content language configuration to the event creation wizard and ensure content languages are constrained to active languages.
New Features:
Bug Fixes:
Enhancements: