Skip to content
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

Fix/sorted section list 467 #790

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/members/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@


class MemberForm(forms.ModelForm):
section = forms.ModelChoiceField(
required=False,
queryset=Section.objects.order_by('abbreviation'),
label=_('Section'),
)
person_number = PersonNumberField(
label=_('Person number'),
help_text=_('Person number using the YYYYMMDD-XXXX format.'),
Expand Down Expand Up @@ -81,6 +86,12 @@ def save(self, commit=True):


class RegistrationForm(MemberForm, auth.UserCreationForm):
section = forms.ModelChoiceField(
required=False,
queryset=Section.objects.order_by('abbreviation'),
label=_('Section'),
)

class Meta:
model = Member
fields = ['username', 'email', 'phone_number', 'section']
Expand Down Expand Up @@ -216,6 +227,12 @@ def password_enabled(self):
widget=forms.PasswordInput,
help_text=_("Enter the same password as above, for verification."))

section = forms.ModelChoiceField(
required=False,
queryset=Section.objects.order_by('abbreviation'),
label=_('Section'),
)

is_superuser = forms.BooleanField(
label=_("Administrator"), required=False,
help_text=_('Administrators have full access to manage any object '
Expand Down Expand Up @@ -304,6 +321,11 @@ def save(self, commit=True):

class UserEditForm(UserForm):
password_required = False
section = forms.ModelChoiceField(
required=False,
queryset=Section.objects.order_by('abbreviation'),
label=_('Section'),
)

def __init__(self, *args, **kwargs):
kwargs.pop('editing_self', False)
Expand Down Expand Up @@ -348,7 +370,7 @@ class CustomUserEditForm(UserEditForm):
)
section = forms.ModelChoiceField(
required=False,
queryset=Section.objects,
queryset=Section.objects.order_by('abbreviation'),
label=_('Section'),
)
status = forms.ChoiceField(
Expand Down Expand Up @@ -412,7 +434,7 @@ class CustomUserCreationForm(UserCreationForm):
)
section = forms.ModelChoiceField(
required=False,
queryset=Section.objects,
queryset=Section.objects.order_by('abbreviation'),
label=_("Section"),
)

Expand Down
Loading