How to use the ocflib.misc.validators.valid_email function in ocflib

To help you get started, we’ve selected a few ocflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ocf / ocfweb / ocfweb / account / register.py View on Github external
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': 'jsmith@berkeley.edu'}),
    )

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

    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:
github ocf / ocflib / ocflib / misc / mail.py View on Github external
def send_mail(to, subject, body, *, cc=None, sender=MAIL_FROM):
    """Send a plain-text mail message.

    `body` should be a string with newlines, wrapped at about 80 characters."""

    if not validators.valid_email(parseaddr(sender)[1]):
        raise ValueError('Invalid sender address.')

    if not validators.valid_email(parseaddr(to)[1]):
        raise ValueError('Invalid recipient address.')

    msg = email.mime.text.MIMEText(body)

    msg['Subject'] = subject
    msg['From'] = sender
    msg['To'] = to
    msg['Cc'] = cc

    # we send the message via sendmail because direct traffic to port 25
    # is firewalled off
    p = subprocess.Popen((SENDMAIL_PATH, '-t', '-oi'),
                         stdin=subprocess.PIPE)
github ocf / ocfweb / ocfweb / atool / approve / forms.py View on Github external
password = forms.CharField(
        widget=forms.PasswordInput(render_value=True),
        label='New password',
        min_length=8,
        max_length=64,
    )

    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)])

    verify_contact_email = forms.EmailField(label='Confirm contact e-mail')

    disclaimer_agreement = forms.BooleanField(
        label='You have read, understood, and agreed to our policies.',
        error_messages={
            'required': 'You did not 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.")
github ocf / ocfweb / ocfweb / lab_reservations / reserve.py View on Github external
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': 'oski@berkeley.edu'}),
    )

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

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

    reason = forms.CharField(
github ocf / ocflib / ocflib / misc / mail.py View on Github external
def send_mail(to, subject, body, *, cc=None, sender=MAIL_FROM):
    """Send a plain-text mail message.

    `body` should be a string with newlines, wrapped at about 80 characters."""

    if not validators.valid_email(parseaddr(sender)[1]):
        raise ValueError('Invalid sender address.')

    if not validators.valid_email(parseaddr(to)[1]):
        raise ValueError('Invalid recipient address.')

    msg = email.mime.text.MIMEText(body)

    msg['Subject'] = subject
    msg['From'] = sender
    msg['To'] = to
    msg['Cc'] = cc

    # we send the message via sendmail because direct traffic to port 25
    # is firewalled off
    p = subprocess.Popen((SENDMAIL_PATH, '-t', '-oi'),
                         stdin=subprocess.PIPE)
    p.communicate(msg.as_string().encode('utf8'))
github ocf / ocflib / ocflib / account / creation.py View on Github external
def validate_email(email):
    if not valid_email(email):
        raise ValidationError('Invalid email.')
github ocf / ocfweb / ocfweb / account / vhost.py View on Github external
def clean_your_email(self) -> str:
        your_email = self.cleaned_data['your_email']
        if not valid_email(your_email):
            raise forms.ValidationError(
                "The email you entered doesn't appear to be "
                'valid. Please double-check it.',
            )
        return your_email
github ocf / ocfweb / ocfweb / lab_reservations / reserve.py View on Github external
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': 'oski@berkeley.edu'}),
    )

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

    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)',