Beispiel #1
0
    def clean(self) -> None:  # type: ignore
        cleaned_data = super().clean()

        # validate password (requires username to check similarity)
        username = cleaned_data.get('username')
        password = cleaned_data.get('password')

        if username and password:
            wrap_validator(validators.validate_password)(username, password)
Beispiel #2
0
    def clean(self):
        cleaned_data = super(ApproveForm, self).clean()

        # validate password (requires username to check similarity)
        username = cleaned_data.get('username')
        password = cleaned_data.get('password')

        if username and password:
            wrap_validator(validators.validate_password)(username, password)
Beispiel #3
0
    def clean(self):
        cleaned_data = super(ApproveForm, self).clean()

        # validate password (requires username to check similarity)
        username = cleaned_data.get('username')
        password = cleaned_data.get('password')

        if username and password:
            wrap_validator(validators.validate_password)(username, password)
Beispiel #4
0
class ApproveForm(Form):
    def __init__(self, *args: Any, **kwargs: Any) -> None:
        association_choices = kwargs.pop('association_choices', None)
        super().__init__(*args, **kwargs)
        if association_choices:
            self.fields['account_association'].choices = association_choices

    account_association = forms.ChoiceField(
        label='CalNet/CalLink account association',
        widget=forms.Select(),
    )

    ocf_login_name = forms.CharField(
        label='OCF account name',
        widget=forms.TextInput(attrs={'placeholder': 'jsmith'}),
        validators=[wrap_validator(validators.validate_username)],
        min_length=3,
        max_length=16,
    )

    # password is validated in clean since we need the username as part of the
    # password validation (to compare similarity)
    password = forms.CharField(
        widget=forms.PasswordInput(render_value=True),
        label='Password',
        min_length=8,
        max_length=256,
    )

    verify_password = forms.CharField(
        widget=forms.PasswordInput(render_value=True),
        label='Confirm password',
        min_length=8,
        max_length=64,
    )

    contact_email = forms.EmailField(
        label='Contact e-mail',
        validators=[wrap_validator(ocflib.misc.validators.valid_email)],
        widget=forms.EmailInput(attrs={'placeholder': '*****@*****.**'}),
    )

    verify_contact_email = forms.EmailField(
        label='Confirm contact e-mail',
        widget=forms.EmailInput(attrs={'placeholder': '*****@*****.**'}),
    )

    disclaimer_agreement = forms.BooleanField(
        label='I agree with the above statement.',
        error_messages={
            'required': 'You must agree to our policies.',
        },
    )

    def clean_verify_password(self) -> str:
        password = self.cleaned_data.get('password')
        verify_password = self.cleaned_data.get('verify_password')

        if password and verify_password:
            if password != verify_password:
                raise forms.ValidationError("Your passwords don't match.")
        return verify_password

    def clean_verify_contact_email(self) -> str:
        email = self.cleaned_data.get('contact_email')
        verify_contact_email = self.cleaned_data.get('verify_contact_email')

        if email and verify_contact_email:
            if email != verify_contact_email:
                raise forms.ValidationError("Your emails don't match.")
        return verify_contact_email

    # clean incompatible with supertype BaseForm which is defined in django.
    def clean(self) -> None:  # type: ignore
        cleaned_data = super().clean()

        # validate password (requires username to check similarity)
        username = cleaned_data.get('username')
        password = cleaned_data.get('password')

        if username and password:
            wrap_validator(validators.validate_password)(username, password)
Beispiel #5
0
class ApproveForm(Form):

    ocf_login_name = forms.CharField(
        label='OCF account name',
        widget=forms.TextInput(attrs={'placeholder': 'jsmith'}),
        validators=[wrap_validator(validators.validate_username)],
        min_length=3,
        max_length=16,
    )

    # password is validated in clean since we need the username as part of the
    # password validation (to compare similarity)
    password = forms.CharField(
        widget=forms.PasswordInput(render_value=True),
        label='Password',
        min_length=8,
        max_length=256,
    )

    verify_password = forms.CharField(
        widget=forms.PasswordInput(render_value=True),
        label='Confirm password',
        min_length=8,
        max_length=64,
    )

    contact_email = forms.EmailField(
        label='Contact e-mail',
        validators=[wrap_validator(ocflib.misc.validators.valid_email)],
        widget=forms.EmailInput(attrs={'placeholder': '*****@*****.**'}),
    )

    verify_contact_email = forms.EmailField(
        label='Confirm contact e-mail',
        widget=forms.EmailInput(attrs={'placeholder': '*****@*****.**'}),
    )

    disclaimer_agreement = forms.BooleanField(
        label='I agree with the above statement.',
        error_messages={
            'required': 'You must agree to our policies.',
        },
    )

    def clean_verify_password(self):
        password = self.cleaned_data.get('password')
        verify_password = self.cleaned_data.get('verify_password')

        if password and verify_password:
            if password != verify_password:
                raise forms.ValidationError("Your passwords don't match.")
        return verify_password

    def clean_verify_contact_email(self):
        email = self.cleaned_data.get('contact_email')
        verify_contact_email = self.cleaned_data.get('verify_contact_email')

        if email and verify_contact_email:
            if email != verify_contact_email:
                raise forms.ValidationError("Your emails don't match.")
        return verify_contact_email

    def clean(self):
        cleaned_data = super(ApproveForm, self).clean()

        # validate password (requires username to check similarity)
        username = cleaned_data.get('username')
        password = cleaned_data.get('password')

        if username and password:
            wrap_validator(validators.validate_password)(username, password)
Beispiel #6
0
class RequestForm(forms.Form):

    error_css_class = 'error'
    required_css_class = 'required'

    real_name = forms.CharField(
        label='Full Name',
        widget=forms.TextInput(attrs={'placeholder': 'Oski Bear'}),
        min_length=3,
    )

    contact_email = forms.EmailField(
        label='Contact email',
        validators=[wrap_validator(ocflib.misc.validators.valid_email)],
        widget=forms.EmailInput(attrs={'placeholder': '*****@*****.**'}),
    )

    verify_contact_email = forms.EmailField(
        label='Confirm contact email',
        validators=[wrap_validator(ocflib.misc.validators.valid_email)],
        widget=forms.EmailInput(attrs={'placeholder': '*****@*****.**'}),
    )

    group = forms.CharField(
        label='Group',
        widget=forms.TextInput(attrs={'placeholder': 'Open Computing Facility'}),
        min_length=3,
    )

    reason = forms.CharField(
        label='Reason for reservation',
        widget=forms.Textarea(attrs={'placeholder': ''}),
    )

    date = forms.DateField(
        label='Date of reservation (yyyy-mm-dd)',
        widget=forms.DateInput(attrs={'placeholder': datetime.now().strftime('%Y-%m-%d')}),
    )

    starttime = forms.TimeField(
        label='Starting time of reservation (24 hour, i.e. 20:00)',
    )

    endtime = forms.TimeField(
        label='Ending time of reservation (24 hour, i.e. 22:00)',
    )

    disclaimer_agreement = forms.BooleanField(
        label='I agree with the above statement.',
        error_messages={
            'required': 'You must agree to our policies.',
        },
    )

    def clean_verify_(self):
        email = self.cleaned_data.get('contact_email')
        verify_contact_email = self.cleaned_data.get('verify_contact_email')

        if email != verify_contact_email:
            raise forms.ValidationError("Your emails don't match.")
        return verify_contact_email