[docs]classProfileEditForm(forms.ModelForm):"""A form containing editable fields in the User model."""GENDERS=(("male","Male"),("female","Female"),("non-binary","Non-Binary"))admin_comments=forms.CharField(label="Admin Comments",widget=forms.Textarea,required=False)student_id=forms.IntegerField(label="FCPS Student ID",required=False)first_name=forms.CharField(label="First Name")middle_name=forms.CharField(label="Middle Name",required=False)last_name=forms.CharField(label="Last Name")nickname=forms.CharField(label="Nickname",required=False)graduation_year=forms.IntegerField(label="Graduation Year",required=False)gender=forms.ChoiceField(choices=GENDERS,label="Sex (Male, Female, or Non-Binary)")counselor_id=forms.IntegerField(label="Counselor ID",required=False)classMeta:model=get_user_model()fields=["admin_comments","student_id","first_name","middle_name","last_name","title","nickname","graduation_year","gender"]
[docs]classUserChoiceField(forms.ModelChoiceField):"""A ModelChoiceField that returns a user's full name instead of their TJ username (which is the default string representation)."""deflabel_from_instance(self,obj):returnobj.full_name
[docs]classSortedUserChoiceField(forms.ModelChoiceField):"""A ModelChoiceField that returns a user's Last, First name instead of their TJ username (which is the default string representation)."""deflabel_from_instance(self,obj):returnobj.last_first_id
[docs]classUserMultipleChoiceField(forms.ModelMultipleChoiceField):"""A ModelMultipleChoiceField that returns a user's full name instead of their TJ username (which is the default string representation)."""deflabel_from_instance(self,obj):returnobj.full_name
[docs]classSortedUserMultipleChoiceField(forms.ModelMultipleChoiceField):"""A ModelMultipleChoiceField that returns a user's Last, First name instead of their TJ username (which is the default string representation)."""deflabel_from_instance(self,obj):returnobj.last_first_id
[docs]classSortedTeacherMultipleChoiceField(forms.ModelMultipleChoiceField):"""A ModelMultipleChoiceField that returns a user's Last, First initial instead of their TJ username (which is the default string representation)."""
[docs]classAddressForm(forms.ModelForm):"""Form for user address"""street=forms.CharField(label="Street")city=forms.CharField(label="City")state=forms.CharField(label="State")postal_code=forms.CharField(label="ZIP")classMeta:model=Addressfields=["street","city","state","postal_code"]