Example #1
0
 class Meta:
     model = Alumni
     fields = [
         'firstName', 'middleName', 'lastName', 'email', 'sex', 'birthday',
         'nationality', 'category'
     ]
     widgets = {'birthday': DatePickerInput()}
Example #2
0
 class Meta:
     model = Alumni
     fields = ['givenName', 'middleName', 'familyName', 'email', 'sex',
               'birthday', 'nationality']
     widgets = {
         'birthday': DatePickerInput()
     }
     help_texts = {
         "birthday": "",
     }
Example #3
0
 class Meta:
     model = Alumni
     fields = [
         'firstName', 'middleName', 'lastName', 'email', 'existingEmail',
         'sex', 'birthday', 'birthdayVisible', 'nationality', 'category'
     ]
     widgets = {'birthday': DatePickerInput()}
     labels = {
         "firstName": "First Name",
         "middleName": "Middle Name",
         "lastName": "Last Name",
         "birthdayVisible": ""
     }
Example #4
0
 class Meta:
     model = Alumni
     fields = [
         'firstName', 'middleName', 'lastName', 'email', 'existingEmail',
         'resetExistingEmailPassword', 'sex', 'birthday', 'nationality',
         'category'
     ]
     widgets = {'birthday': DatePickerInput()}
     labels = {
         "firstName": "First Name",
         "middleName": "Middle Name",
         "lastName": "Last Name",
         "existingEmail": "",
         "resetExistingEmailPassword": ""
     }
     help_texts = {
         "birthday": "",
     }
Example #5
0
class HackerForm(forms.ModelForm):
    class Meta:
        model = Hacker
        fields = [
            'firstName',
            'middleName',
            'lastName',
            'dob',
            'gender',
            'race',
            'email',
            'phoneNumber',
            'nationality',
            'countryOfResidence',
            'jacobsHackTerms',
            'mlhCodeOfConduct',
            'mlhContestTerms',
        ]
        labels = {
            "firstName": "First Name",
            "middleName": "Middle Name",
            "lastName": "Last Name",
            "dob": "Date Of Birth",
            "race": "Race / Ethnicity",
            "phoneNumber": "Phone Number",
            "countryOfResidence": "Country Of Residence",
            "jacobsHackTerms": "JacobsHack! Terms & Conditions",
            "mlhCodeOfConduct": "MLH Code Of Conduct",
            "mlhContestTerms": "MLH Contest Terms & Privacy Policy",
        }

    dob = forms.DateField(
        input_formats=settings.DATE_INPUT_FORMATS,
        label="Date Of Birth",
        help_text=
        "The date you were born. You need to be at least {} years of age to participate in jacobsHack!. Use either the datepicker widget or enter it in <em>%Y-%m-%d</em> format. "
        .format(settings.MIN_HACKER_AGE),
        widget=DatePickerInput())

    def clean(self):
        # individual field's clean methods have already been called
        cleaned_data = self.cleaned_data

        # check that we have accepted the terms and conditions
        if not cleaned_data.get('jacobsHackTerms'):
            self.add_error(
                'jacobsHackTerms',
                forms.ValidationError(
                    "You need to accept the JacobsHack Terms and Conditions to apply to JacobsHack. "
                ))
            raise forms.ValidationError("Please correct the error below. ")

        # check that we have accepted the MLH Code Of Conduct
        if not cleaned_data.get('mlhCodeOfConduct'):
            self.add_error(
                'mlhCodeOfConduct',
                forms.ValidationError(
                    "You need to accept the MLH Code of Conduct to apply to JacobsHack. "
                ))
            raise forms.ValidationError("Please correct the error below. ")

        # check that we have accepted the MLT Terms & Conditions
        if not cleaned_data.get('mlhContestTerms'):
            self.add_error(
                'mlhContestTerms',
                forms.ValidationError(
                    "You need to accept the MLH Contest Terms & Conditions to apply to JacobsHack. "
                ))
            raise forms.ValidationError("Please correct the error below. ")

        dob = cleaned_data.get('dob')
        today = datetime.date.today()
        age = today.year - dob.year - ((today.month, today.day) <
                                       (dob.month, dob.day))

        if age < settings.MIN_HACKER_AGE:
            self.add_error(
                'dob',
                forms.ValidationError(
                    "We are not allowed to accept applications of minors for JacobsHack. Please apply once you are older than {} years of age. "
                    .format(settings.MIN_HACKER_AGE)))
            raise forms.ValidationError("Please correct the error below. ")

        return super(HackerForm, self).clean()