class InscriptionForm(forms.Form): username = forms.CharField(label="Nom d'utilisateur", max_length="150", required=True, min_length="6") prenom = forms.CharField(label="Prénom", max_length="150", required=True, min_length="6") nom = forms.CharField(label='Nom', max_length="150", required=True, min_length="6") password = forms.CharField(label='Mot de passe', max_length="150", required=True, min_length="6", widget=forms.PasswordInput) password2 = forms.CharField(label='Mot de passe', max_length="150", required=True, min_length="6", widget=forms.PasswordInput) addresse = AddressField(required=True) email = forms.EmailField(label="Adresse email", required=True) telephone = forms.CharField(label='Numéro de teléphone', min_length="10", required=True, max_length="10", widget=forms.NumberInput)
class ModificationForm(forms.Form): addresse = AddressField(required=True) email = forms.EmailField(label="Adresse email", required=True) telephone = forms.CharField(label='Numéro de teléphone', min_length="10", required=True, max_length="10", widget=forms.NumberInput)
class BuyerCreationForm(forms.ModelForm): """A form for creating new_profile users. Includes all the required fields, plus a repeated password.""" address = AddressField( label='Адрес', widget=AddressWidget(attrs={'placeholder': 'введите свой адрес'}), help_text='улица Макарова, 24, Ровно, Ровенская область, Украина') password1 = forms.CharField( label=_('Password'), widget=forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': _('введите пароль') })) password2 = forms.CharField( label=_('Password confirmation'), widget=forms.PasswordInput(attrs={ 'class': 'form-control', 'placeholder': _('повторите пароль') })) class Meta: model = BuyerUser fields = ('email', 'first_name', 'last_name', 'date_of_birth', 'sex', 'phone_number') def clean_password1(self): password1 = self.cleaned_data.get("password1") valid_password = validate_password(password1) if valid_password is not None: raise valid_password.ValidationError() return password1 def clean_password2(self): # Check that the two password entries match password1 = self.cleaned_data.get("password1") password2 = self.cleaned_data.get("password2") if password1 and password2 and password1 != password2: raise forms.ValidationError("Пароли не совпадают") return password2 def save(self, commit=True): # Save the provided password in hashed format user = super(BuyerCreationForm, self).save(commit=False) user.set_password(self.cleaned_data["password1"]) if commit: user.save() return user
class BuyerChangeForm(forms.ModelForm): """A form for updating users. Includes all the fields on the user, but replaces the password field with admin's password hash display field. """ password = ReadOnlyPasswordHashField() address = AddressField() class Meta: model = BuyerUser fields = ('email', 'password', 'first_name', 'last_name', 'date_of_birth', 'sex', 'phone_number', 'sex', 'is_active', 'is_admin') def clean_password(self): # Regardless of what the user provides, return the initial value. # This is done here, rather than on the field, because the # field does not have access to the initial value return self.initial["password"]
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['first_name'].widget = forms.TextInput() self.fields['first_name'].label = 'First Name' self.fields['first_name'].required = False self.fields['last_name'].widget = forms.TextInput() self.fields['last_name'].label = 'Last Name' self.fields['last_name'].required = False address = AddressField(required=False) self.fields['phone_number'].widget = forms.NumberInput() self.fields['phone_number'].label = 'Phone Number' self.fields['phone_number'].required = False self.fields['date_of_birth'].widget = forms.DateInput( attrs={'class': 'datepicker'}) self.fields['date_of_birth'].label = 'Date of Birth' self.fields['date_of_birth'].required = False
class OrderForm(forms.ModelForm): class Meta: model = Order fields = [ 'ingress_mail', 'ingress_agent_name', 'is_shipping', 'address', 'additional_address', 'custom_order', 'bank_transfer_name', ] ingress_mail = forms.CharField(max_length=200, required=True) ingress_agent_name = forms.CharField(max_length=200, required=True) is_shipping = forms.widgets.boolean_check(v=None) address = AddressField(required=False) additional_address = forms.CharField(max_length=255, required=False) custom_order = forms.CharField(max_length=255, label='Order Options', required=False) bank_transfer_name = forms.CharField(max_length=20, required=False) how_to_receive_krw = forms.CharField(max_length=1, required=False)
class EventCreationForm(ModelForm): venue = AddressField() start_date = forms.DateTimeField(widget=DateTimePickerInlineInput()) end_date = forms.DateTimeField(widget=DateTimePickerInlineInput()) od = forms.ChoiceField(choices=((True, "Yes"), (False, "No"))) cover_image = forms.ImageField(widget=ImageInput()) description = forms.CharField(widget=QuillInput()) club = forms.CharField(widget=forms.HiddenInput()) class Meta: model = Event fields = [ 'title', 'cover_image', 'start_date', 'end_date', 'venue', 'od', 'description', 'club' ] def __init__(self, club, *args, **kwargs): super(EventCreationForm, self).__init__(*args, **kwargs) self.club_data = club self.helper = FormHelper() self.helper.label_class = "font-weight-bold" self.helper.layout = Layout( 'title', 'cover_image', Div(Field('start_date', wrapper_class="col-12 col-md-4"), Field('end_date', wrapper_class="col-12 col-md-4"), InlineRadios('od'), css_class="row"), 'venue', 'description', Hidden('club', self.club_data), Submit('save-event', "Save")) def clean_club(self): if not self.club_data: raise ValidationError("Invalid Club") return self.club_data
class TestForm(Form): address = AddressField()
class ApplicationModelForm(forms.ModelForm): required_css_class = "required-form-input" gender_other = forms.CharField( label='If you chose "Prefer to self-describe", please elaborate.', required=False, ) race_other = forms.CharField( label='If you chose "Prefer to self-describe", please elaborate.', required=False, ) school = forms.ModelChoiceField( School.objects.all(), label="What school do you go to?", ) school_other = forms.CharField( label='If you chose "Other", please enter your school\'s name here.', required=False, ) # Languages PYTHON = "Python" JAVA_SCRIPT = "JavaScript" TYPE_SCRIPT = "TypeScript" JAVA = "Java" C_SHARP = "C#" C_LANG = "C" CPP = "C++" GOLANG = "Go" R_LANG = "R" SWIFT = "Swift" DART = "Dart" KOTLIN = "Kotlin" RUBY = "Ruby" RUST = "Rust" SCALA = "Scala" # Concepts MACHINE_LEARNING = "ML" FULL_STACK = "full-stack" FRONT_END = "front-end" BACK_END = "back-end" WEB = "web-dev" MOBILE = "mobile-dev" DESIGN = "design" DATA_SCIENCE = "data-science" DEV_OPS = "dev-ops" CLOUD = "cloud" TECHNOLOGY_EXPERIENCE = ( (PYTHON, "Python"), (JAVA_SCRIPT, "JavaScript"), (TYPE_SCRIPT, "TypeScript"), (JAVA, "Java"), (C_SHARP, "C#"), (C_LANG, "C"), (CPP, "C++"), (GOLANG, "Golang"), (R_LANG, "R"), (SWIFT, "Swift"), (DART, "Dart"), (KOTLIN, "Kotlin"), (RUBY, "Ruby"), (RUST, "Rust"), (SCALA, "Scala"), (FULL_STACK, "Full Stack"), (FRONT_END, "Front End"), (BACK_END, "Back End"), (WEB, "Web"), (MOBILE, "Mobile"), (DESIGN, "Design"), (DEV_OPS, "Dev Ops"), (CLOUD, "Cloud (AWS, etc.)"), (DATA_SCIENCE, "Data Science"), (MACHINE_LEARNING, "Machine Learning"), ) # SKILLS technology_experience = forms.MultipleChoiceField( label="What technical skills do you have?", help_text="Select all that apply", choices=TECHNOLOGY_EXPERIENCE, required=False, ) address = AddressField( help_text="You will not receive swag and prizes without an address", required=False, ) def __init__(self, *args, **kwargs): if kwargs.get("instance"): kwargs["initial"] = { "technology_experience": ast.literal_eval( kwargs.get("instance").technology_experience or "[]"), } super().__init__(*args, **kwargs) self.fields["agree_to_coc"].label = mark_safe( 'I agree to the <a href="https://static.mlh.io/docs/mlh-code-of-conduct.pdf">MLH Code of Conduct</a>' ) mlh_stuff = ( f"I authorize {settings.EVENT_NAME} to share my application/registration information for" " event administration, ranking, MLH administration, pre- and post-event informational e-mails," 'and occasional messages about hackathons in-line with the <a href="https://mlh.io/privacy">MLH' ' Privacy Policy</a>. I further agree to the terms of both the <a href="https://github.com/MLH' '/mlh-policies/tree/master/prize-terms-and-conditions">MLH Contest Terms and Conditions</a>' ' and the <a href="https://mlh.io/privacy">MLH Privacy Policy</a>') self.fields["agree_to_mlh_stuff"].label = mark_safe(mlh_stuff) # HACK: Disable the form if there's not an active wave if not application_models.Wave.objects.active_wave(): for field_name in self.fields.keys(): self.fields[field_name].widget.attrs["disabled"] = "disabled" def is_valid(self) -> bool: """ Checks to ensure that a wave is currently active. """ if not application_models.Wave.objects.active_wave(): self.add_error( None, "Applications may only be submitted during an active registration wave.", ) return super().is_valid() def clean(self): gender = self.cleaned_data.get("gender") if gender == application_models.GENDER_OTHER: gender_other = self.cleaned_data.get("gender_other") if not gender_other: msg = forms.ValidationError( 'Please fill out this field or choose "Prefer not to answer".' ) self.add_error("gender_other", msg) races = self.cleaned_data.get("race") if races: race_other = self.cleaned_data.get("race_other") if application_models.RACE_OTHER in races and not race_other: msg = forms.ValidationError( "Please fill out this field with the appropriate information." ) self.add_error("race_other", msg) return self.cleaned_data class Meta: model = application_models.Application widgets = { "is_adult": forms.CheckboxInput, "agree_to_coc": forms.CheckboxInput, "agree_to_mlh_stuff": forms.CheckboxInput, "travel_reimbursement": forms.CheckboxInput, "extra_links": forms.TextInput( attrs={ "placeholder": "ex. GitHub, Devpost, personal website, LinkedIn, etc." }), } fields = [ "first_name", "last_name", "school", "school_other", "major", "classification", "grad_year", "gender", "gender_other", "race", "race_other", "num_hackathons_attended", "technology_experience", "has_team", "wants_team", "shirt_size", "address", "resume", "extra_links", "question1", "question2", "question3", "additional_accommodations", "notes", "agree_to_coc", "agree_to_mlh_stuff", "is_adult", ]
class PersonForm(forms.Form): address = AddressField()
class Meta: model = Person address = AddressField() fields = '__all__'
class ProfileForm(forms.Form): address = AddressField(label='Direccion')
class ExampleForm(forms.Form): address = AddressField()
class OrderForm(forms.Form): is_shipping = forms.widgets.boolean_check(v=None) address = AddressField(required=False) AdditionalAddress = forms.CharField(max_length=255, required=False) OrderOptioin = forms.CharField(max_length=255, label='Order Options', required=False)
class CreateFarmForm(forms.Form): name = Farm._meta.get_field("name").formfield() name.help_text = "" name.widget.attrs["placeholder"] = "Farm's name" address = AddressField(initial={"formatted": ""})
class TestForm(Form): coachAddress_address = AddressField()
class HubForm(forms.Form): name = forms.CharField(max_length=100) address = AddressField()
class AddressForm(forms.Form): address = AddressField()