-
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?
Changes from all commits
896fd23
4d6af95
52cc267
ecd3824
f0194f5
6256ca1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -53,10 +53,17 @@ | |||||||||||
| class EventWizardFoundationForm(forms.Form): | ||||||||||||
| locales = forms.MultipleChoiceField( | ||||||||||||
| choices=settings.LANGUAGES, | ||||||||||||
| label=_('Use languages'), | ||||||||||||
| label=_('Active languages'), | ||||||||||||
| widget=MultipleLanguagesWidget, | ||||||||||||
| help_text=_('Choose all languages that your event should be available in.'), | ||||||||||||
| ) | ||||||||||||
| content_locales = forms.MultipleChoiceField( | ||||||||||||
| choices=settings.LANGUAGES, | ||||||||||||
| label=_('Content languages'), | ||||||||||||
| widget=MultipleLanguagesWidget, | ||||||||||||
| required=False, | ||||||||||||
| help_text=_('Users will be able to submit proposals in these languages.'), | ||||||||||||
| ) | ||||||||||||
| has_subevents = forms.BooleanField( | ||||||||||||
| label=_('This is an event series'), | ||||||||||||
| required=False, | ||||||||||||
|
|
@@ -99,6 +106,25 @@ def __init__(self, *args, **kwargs): | |||||||||||
| self.fields['organizer'].initial = qs.first() | ||||||||||||
| self.fields['organizer'].required = False | ||||||||||||
|
|
||||||||||||
| def clean(self): | ||||||||||||
| cleaned_data = super().clean() | ||||||||||||
| locales = cleaned_data.get('locales', []) | ||||||||||||
| content_locales = cleaned_data.get('content_locales') | ||||||||||||
|
|
||||||||||||
| assert isinstance(locales, list) | ||||||||||||
|
|
||||||||||||
| if content_locales is None or not content_locales: | ||||||||||||
| return cleaned_data | ||||||||||||
|
|
||||||||||||
| assert isinstance(content_locales, list) | ||||||||||||
|
||||||||||||
| 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
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.
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