Beispiel #1
0
class EmergContactForm(FormUnrestrictedOtherUser):
    """ Contact form for emergency contacts """

    emerg_first_name = StrippedCharField(length=25, max_length=64)
    emerg_last_name = StrippedCharField(length=30, max_length=64)
    emerg_e_mail = forms.EmailField(required=False)
    emerg_phone_day = USPhoneNumberField()
    emerg_phone_cell = USPhoneNumberField(required=False)
    emerg_address_street = StrippedCharField(length=40, max_length=100)
    emerg_address_city = StrippedCharField(length=20, max_length=50)
    emerg_address_state = forms.ChoiceField(
        choices=zip(_states, _states),
        widget=forms.Select(attrs={'class': 'input-mini'}))
    emerg_address_zip = StrippedCharField(
        length=5,
        max_length=5,
        widget=forms.TextInput(attrs={'class': 'input-small'}))
    emerg_address_postal = forms.CharField(required=False,
                                           widget=forms.HiddenInput())

    def clean(self):
        super(EmergContactForm, self).clean()
        if self.cleaned_data.get('emerg_phone_day',
                                 '') == '' and self.cleaned_data.get(
                                     'emerg_phone_cell', '') == '':
            raise forms.ValidationError(
                "Please provide either a day phone or cell phone for your emergency contact."
            )
        return self.cleaned_data
Beispiel #2
0
class UserContactForm(FormUnrestrictedOtherUser, FormWithTagInitialValues):
    """ Base for contact form """

    first_name = StrippedCharField(length=25, max_length=64)
    last_name = StrippedCharField(length=30, max_length=64)
    e_mail = forms.EmailField()
    phone_day = USPhoneNumberField(required=False)
    phone_cell = USPhoneNumberField(required=False)
    receive_txt_message = forms.BooleanField(required=False)
    address_street = StrippedCharField(length=40, max_length=100)
    address_city = StrippedCharField(length=20, max_length=50)
    address_state = forms.ChoiceField(choices=zip(_states,_states))
    address_zip = StrippedCharField(length=5, max_length=5)
    address_postal = forms.CharField(required=False, widget=forms.HiddenInput())

    def __init__(self, *args, **kwargs):
        super(UserContactForm, self).__init__(*args, **kwargs)
        if Tag.getTag('request_student_phonenum', default='True') == 'False':
            del self.fields['phone_day']
        if not Tag.getTag('text_messages_to_students'):
            del self.fields['receive_txt_message']

    def clean(self):
        super(UserContactForm, self).clean()
        if self.user.isTeacher() or Tag.getTag('request_student_phonenum', default='True') != 'False':
            if self.cleaned_data.get('phone_day','') == '' and self.cleaned_data.get('phone_cell','') == '':
                raise forms.ValidationError("Please provide either a day phone or cell phone number in your personal contact information.")
        if self.cleaned_data.get('receive_txt_message', None) and self.cleaned_data.get('phone_cell','') == '':
            raise forms.ValidationError("Please specify your cellphone number if you ask to receive text messages.")
        return self.cleaned_data
Beispiel #3
0
class GuardContactForm(FormUnrestrictedOtherUser):
    """ Contact form for guardians """

    guard_first_name = StrippedCharField(length=25, max_length=64)
    guard_last_name = StrippedCharField(length=30, max_length=64)
    guard_no_e_mail = forms.BooleanField(required=False)
    guard_e_mail = forms.EmailField(required=False)
    guard_phone_day = USPhoneNumberField()
    guard_phone_cell = USPhoneNumberField(required=False)

    def __init__(self, *args, **kwargs):
        super(GuardContactForm, self).__init__(*args, **kwargs)
    
        if not Tag.getTag('allow_guardian_no_email'):
            if Tag.getTag('require_guardian_email'):
                self.fields['guard_e_mail'].required = True
            del self.fields['guard_no_e_mail']

    def clean_guard_e_mail(self):
        if 'guard_e_mail' not in self.cleaned_data or len(self.cleaned_data['guard_e_mail']) < 3:
            if Tag.getTag('require_guardian_email') and not self.cleaned_data['guard_no_e_mail']:
                if Tag.getTag('allow_guardian_no_email'):
                    raise forms.ValidationError("Please enter the e-mail address of your parent/guardian.  If they do not have access to e-mail, check the appropriate box.")
                else:
                    raise forms.ValidationError("Please enter the e-mail address of your parent/guardian.")
        else:
            return self.cleaned_data['guard_e_mail']

    def clean(self):
        super(GuardContactForm, self).clean()
        if self.cleaned_data.get('guard_phone_day','') == '' and self.cleaned_data.get('guard_phone_cell','') == '':
            raise forms.ValidationError("Please provide either a day phone or cell phone for your parent/guardian.")
        return self.cleaned_data
Beispiel #4
0
class UserProfileEditForm(forms.ModelForm):
    zipcode = USZipCodeField()
    phone = USPhoneNumberField()
    
    class Meta:
        model = User
        fields = ['first_name', 'last_name', 'email', 'address_line_1', 'address_line_2', 'city', 'state', 'zipcode', 'phone']
Beispiel #5
0
class GeneralPreferenceForm(ModelForm):
    email = forms.EmailField(required=False)
    phone = USPhoneNumberField(required=False)

    class Meta:
        model = Preference
        fields = ['name_store', 'email', 'phone']
Beispiel #6
0
class PlayerForm(forms.Form):
    username = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'input_text'}), max_length=50)
    first_name = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'input_text'}), max_length=50)
    last_name = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'input_text'}), max_length=50)
    email = forms.EmailField()
    sports = forms.ModelMultipleChoiceField(
        queryset=Sport.objects.all(),
        widget=forms.CheckboxSelectMultiple(attrs={'class': 'input_text'}),
        label='Sports')
    gender = forms.ChoiceField(choices=GENDER_CHOICES,
                               widget=forms.Select,
                               label='Gender',
                               help_text='optional',
                               required=False)
    phone_number = USPhoneNumberField(help_text='optional', required=False)

    def clean_email(self):
        email = self.cleaned_data['email']
        user = User.objects.filter(email=email)
        if len(user) > 0:
            raise forms.ValidationError('Email has been activated')
        return self.cleaned_data['email']

    def clean_username(self):
        username = self.cleaned_data['username']
        user = User.objects.filter(username=username)
        if len(user) > 0:
            raise forms.ValidationError('username has been already taken')
        return self.cleaned_data['username']
class ActorSignupForm(ModelForm):
  """A form that allows an actor to signup"""
  line1 = forms.CharField(max_length = 128, label=_('Address line 1'), 
    widget=forms.TextInput(attrs={'size': '40'})
  )
  line2 = forms.CharField(max_length = 128, label=_('Address line 2'), 
    required=False,
    widget=forms.TextInput(attrs={'size': '40'})
  )
  city = forms.CharField(max_length = 128, label=_('City'))
  state = USStateSelect()
  zipcode = USZipCodeField()
  phone = USPhoneNumberField(label=_('Phone (xxx-xxx-xxxx)'))

  
  
  class Meta:
    model = Actor

  def __init__(self, *args, **kwargs):
    super(ActorSignupForm, self).__init__(*args, **kwargs)
    
    self.fields['size'].label = _('Suit/Dress size')
    self.fields['union'].label = _('Union or Non-Union? (SAG, AFTRA, etc.)')
    self.fields['special'].label = _('Special Abilities')
    self.fields['reference'].label = _('How did you hear about us? (Include talent agency if applicable)')
Beispiel #8
0
class ProfileForm(forms.Form):
    first_name = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'input_text'}), max_length=50)
    last_name = forms.CharField(
        widget=forms.TextInput(attrs={'class': 'input_text'}), max_length=50)
    email = forms.EmailField()
    sports = forms.ModelMultipleChoiceField(
        queryset=Sport.objects.all(),
        widget=forms.CheckboxSelectMultiple,
        label='Sports')
    gender = forms.ChoiceField(choices=GENDER_CHOICES,
                               widget=forms.Select,
                               label='Gender',
                               help_text='optional',
                               required=False)
    phone_number = USPhoneNumberField(help_text='optional', required=False)

    def clean_password2(self):
        if self.cleaned_data['password2'] != self.cleaned_data['password1']:
            raise forms.ValidationError('passwords do not match!')
        return self.cleaned_data['password2']

    def clean_email(self):
        email = self.cleaned_data['email']
        user = User.objects.filter(email=email)
        if len(user) > 1:
            raise forms.ValidationError('Email has been activated')
        return self.cleaned_data['email']
Beispiel #9
0
class ReminderForm(forms.Form):
    """reminder form."""
    send_email = forms.BooleanField(required=False)
    email = forms.EmailField(required=False, label="Email Address")
    send_text = forms.BooleanField(required=False)
    email_advance = forms.ChoiceField(
        choices=REMINDER_TIME_CHOICES,
        label="Send reminder how far in advance?")
    text_number = USPhoneNumberField(required=False,
                                     label="Mobile phone number")
    text_carrier = forms.ChoiceField(choices=TextReminder.TEXT_CARRIERS,
                                     required=False,
                                     label="Carrier")
    text_advance = forms.ChoiceField(choices=REMINDER_TIME_CHOICES,
                                     label="Send reminder how far in advance?")

    def clean(self):
        """validate form."""
        cleaned_data = self.cleaned_data
        send_email = cleaned_data.get("send_email")
        email = None
        if "email" in cleaned_data:
            email = cleaned_data.get("email")
        if send_email and (not email or len(email) == 0):
            raise forms.ValidationError("A valid email address is required.")

        send_text = cleaned_data.get("send_text")
        number = None
        if "text_number" in cleaned_data:
            number = cleaned_data.get("text_number")
        if send_text and (not number or len(number) == 0):
            raise forms.ValidationError("A valid phone number is required.")

        return cleaned_data
Beispiel #10
0
class EmailPrefForm(forms.Form):
    email = ValidHostEmailField(label='E-Mail Address', required=True)
    confirm_email = ValidHostEmailField(
        label="Confirm email",
        help_text="<i>Please type your email address again.</i>")
    first_name = StrippedCharField(label='First Name',
                                   length=30,
                                   max_length=64,
                                   required=True)
    last_name = StrippedCharField(label='Last Name',
                                  length=30,
                                  max_length=64,
                                  required=True)
    sms_number = USPhoneNumberField(
        label='Cell Phone',
        required=False,
        help_text=
        'Optional: If you provide us your cell phone number, we can send you SMS text notifications'
    )

    #    sms_opt_in = forms.BooleanField(label='Send Me Text Updates', initial = True, required = False)

    def clean_confirm_email(self):
        if not (('confirm_email' in self.cleaned_data) and
                ('email' in self.cleaned_data)) or (
                    self.cleaned_data['confirm_email'] !=
                    self.cleaned_data['email']):
            raise forms.ValidationError(
                'Ensure that you have correctly typed your email both times.')
        return self.cleaned_data['confirm_email']
Beispiel #11
0
class TriviaGuruRegistrationForm(forms.Form):
    captain_name = vibhaforms.CharField(label="Team Captain", max_length=100)
    email = vibhaforms.EmailField()
    phone = USPhoneNumberField(help_text='Eg: 111-111-1111')
    member2_name = vibhaforms.CharField(
        label="Team member 2",
        max_length=100,
        required=False,
        help_text=
        r"Leave this blank if you are registering individually or do not have a full team"
    )
    member3_name = vibhaforms.CharField(
        label="Team member 3",
        max_length=100,
        required=False,
        help_text=
        r"Leave this blank if you are registering individually or do not have a full team"
    )
    team_name = vibhaforms.CharField(max_length=100)
    num_students = forms.IntegerField(required=True, initial=0)
    num_non_students = forms.IntegerField(required=True, initial=0)
    comments = vibhaforms.CharField(
        label="How did you hear about us?/Other comments",
        required=False,
        widget=forms.Textarea(attrs={'rows': 5}))
Beispiel #12
0
class ResourcePrintForm(forms.Form):
    # We set the 'queryset' field in __init__. This is passed from the view
    client_name = forms.CharField(label="Client's Name")
    client_phone = USPhoneNumberField(label="Client's Phone (Optional)",
                                      required=False)
    client_email = forms.EmailField(label="Client's Email (Optional)",
                                    required=False)
    user_email = forms.EmailField(label="Your Email")
Beispiel #13
0
class TeamPlayerForm(forms.Form):
    first_name = forms.CharField(max_length=100)
    last_name = forms.CharField(max_length=100)
    number = forms.IntegerField(required=False)
    position = forms.CharField(max_length=3, required=False)
    #TODO: Autocreate this by first letter, last name, then number -> It should always be unique
    username = forms.CharField(max_length=30)
    email = forms.EmailField(max_length=100)
    phone = USPhoneNumberField(required=False)
Beispiel #14
0
class ProfileFormUS(ProfileForm):
    phone_number = USPhoneNumberField(required=False)
    zipcode = USZipCodeField(required=False)

    def __init__(self, *args, **kwargs):
        super(ProfileFormUS, self).__init__(*args, **kwargs)
        self.fields['state'] = forms.ModelChoiceField(
            queryset=states_in_the_US(),
            help_text=
            'Please use "Other" listed at the end for a non-US address')
Beispiel #15
0
class BaseProfileForm(forms.Form):
    phone = USPhoneNumberField(required=False)
    city = forms.CharField()
    state = USStateField(
        widget=USStateSelect,
        help_text="Please select the state you will volunteer in.")
    zipcode = USZipCodeField(required=True, label="ZIP code")
    is_a = forms.ChoiceField(required=False,
                             choices=IS_A_CHOICES,
                             label='I am a:')
Beispiel #16
0
class SlideForm(forms.ModelForm):
	display_start = forms.DateField(label="Display Start Date", input_formats=('%m/%d/%Y',))
	display_end = forms.DateField(label="Display End Date", input_formats=('%m/%d/%Y',))
	phone = USPhoneNumberField()
	class Meta:
		model = Slide
		exclude = ('status','created', 'font', 'color_bg', 'color_font')
		widgets = {
				"font_size": forms.HiddenInput()
		}
Beispiel #17
0
class UserProfileForm(UserProfileBaseForm):
    birthday = forms.DateField(required=False)
    phone = USPhoneNumberField(required=False)
    about = forms.CharField(widget=forms.Textarea(), required=False)
    screen_name = forms.CharField(max_length=40, required=False)
    screen_name_service = forms.ChoiceField(choices=screen_name_service_choices, required=False)

    interests = forms.CharField(widget=forms.Textarea(), required=False)
    music = forms.CharField(widget=forms.Textarea(), required=False)
    tv = forms.CharField(widget=forms.Textarea(), required=False)
    books = forms.CharField(widget=forms.Textarea(), required=False)
    movies = forms.CharField(widget=forms.Textarea(), required=False)
Beispiel #18
0
class Staff(models.Model):
    first_name = models.CharField(max_length=32, verbose_name='first name')
    last_name = models.CharField(max_length=32, verbose_name='last name')
    email = models.EmailField(max_length=100, verbose_name='e-mail address')
    phone = USPhoneNumberField()

    def __unicode__(self):
        return unicode((self.first_name, self.last_name))

    class Meta:
        app_label = 'conference'
        ordering = ('last_name', 'first_name')
        verbose_name_plural = 'staff'
Beispiel #19
0
class SignupForm(account.forms.SignupForm):
    email = forms.EmailField(widget=forms.HiddenInput())
    first_name = forms.CharField()
    last_name = forms.CharField()
    street1 = forms.CharField(max_length=255)
    street2 = forms.CharField(required=False, max_length=255)
    city = forms.CharField(max_length=64)
    state = forms.ChoiceField(choices=add_empty_choice(LEGAL_STATES))
    zip = forms.CharField(max_length=64)
    security_question = forms.ModelChoiceField(SecurityQuestion.objects.all())
    security_answer = forms.CharField(max_length=50)
    phone = USPhoneNumberField()
    pin_delivery = forms.ChoiceField(widget=forms.RadioSelect,
                                     choices=UserProfile.PIN_DELIVERY_CHOICES)
    birthdate = forms.DateField(widget=SelectDateWidget(
        years=range(1910, 1994)))
    gender = forms.ChoiceField(choices=add_empty_choice(GENDER_CHOICES))
    email_policy = forms.BooleanField(
        help_text="I agree to LiveAce's <a href='#'>email policy</a>.")
    terms_and_conditions = forms.BooleanField(
        help_text="I agree to LiveAce's <a href='#'>Terms & Conditions</a>.")

    def clean_password(self):
        MIN_LENGTH = 6
        MAX_LENGTH = 25

        password = self.cleaned_data["password"]

        if len(password) < MIN_LENGTH or len(password) > MAX_LENGTH:
            raise forms.ValidationError(
                "Your password must contain %d-%d characters." %
                (MIN_LENGTH, MAX_LENGTH))

        first_isalpha = password[0].isalpha()
        if all(c.isalpha() == first_isalpha for c in password):
            raise forms.ValidationError(
                "Password must contain at least one letter and at least one digit."
            )

        return password

    def clean_phone(self):
        phone = self.cleaned_data["phone"]
        dupes = UserProfile.objects.filter(phone=phone)
        if dupes.count() > 0:
            username = dupes[0].user.username
            raise forms.ValidationError(
                mark_safe(
                    "The phone number %s was previously registered to username %s. If you have previously created an account, click 'Log In' above. If you forgot your passwrod, you can re-set it by clicking 'Forgot password' on the Login page. If you did not previously register an account under username %s, please <a href='#'>contact us</a> and we will be able to assist you with this process."
                    % (phone, username, username)))
        return phone
Beispiel #20
0
class ProfileForm(forms.Form):
    def __init__(self, *args, **kwargs):
        """
    Override for init to take a user argument.
    """
        self.user = kwargs.pop('user', None)

        super(ProfileForm, self).__init__(*args, **kwargs)

    display_name = forms.CharField(required=True, max_length=20, min_length=1)
    # enable_help = forms.BooleanField(required=False)
    # TODO: check http://docs.djangoproject.com/en/dev/topics/http/sessions/#using-sessions-in-views
    # stay_logged_in = forms.BooleanField(initial=True)

    # Event notifications
    contact_email = forms.EmailField(required=False)
    contact_text = USPhoneNumberField(
        required=False,
        widget=forms.TextInput(attrs={
            "style": "width: 100px",
        }))
    contact_carrier = forms.ChoiceField(choices=TextReminder.TEXT_CARRIERS)

    def __init__(self, *args, **kwargs):
        """
    Override for init to take a user argument.
    """
        self.user = kwargs.pop('user', None)
        super(ProfileForm, self).__init__(*args, **kwargs)

    def clean_display_name(self):
        """
    Check if this profile name is valid
    """
        name = self.cleaned_data['display_name'].strip()
        # Remove extra whitespace from the name.
        spaces = re.compile(r'\s+')
        name = spaces.sub(' ', name)

        # Check for name that is just whitespace.
        if name == '':
            raise forms.ValidationError('This field is required')

        # Check for duplicate name
        if Profile.objects.exclude(user=self.user).filter(
                name=name).count() > 0:
            raise forms.ValidationError(
                "%s is taken.  Please use another name.")

        return name
Beispiel #21
0
class EditUserForm(forms.Form):
    user_type = forms.ChoiceField(choices=[['player', 'Player'],
                                           ['coach', 'Coach, Manager, Other']],
                                  label='User Type')
    first_name = forms.CharField(max_length=100)
    last_name = forms.CharField(max_length=100)
    number = forms.IntegerField(required=False)
    position = forms.CharField(max_length=10, required=False)
    year = forms.CharField(max_length=20, required=False)
    #TODO: Autocreate this by first letter, last name, then number -> It should always be unique
    username = forms.CharField(max_length=30)
    email = forms.EmailField(max_length=100)
    phone = USPhoneNumberField(required=False)
    city = forms.CharField(required=False)
    state = forms.CharField(max_length=2, required=False)
    country = forms.CharField(max_length=50, required=False)
Beispiel #22
0
class UpdateSettings(forms.ModelForm):
    phone = USPhoneNumberField(required=False)

    class Meta:
        model = User
        fields = ('email', )

    def __init__(self, *args, **kwargs):
        super(UpdateSettings, self).__init__(*args, **kwargs)
        if self.instance:
            self.initial['phone'] = self.instance.profile.phone

    def save(self):
        instance = super(UpdateSettings, self).save()
        instance.profile.phone = self.cleaned_data['phone']
        instance.profile.save()
        return instance
Beispiel #23
0
class RegistrationForm(forms.ModelForm):
    cell_number = USPhoneNumberField(label='Cell phone number')
    proxy_email = forms.EmailField(label='Proxy email',
                                   max_length=50,
                                   required=False)
    #dropoff_pickup_time = forms.ModelChoiceField(DropoffPickupTime.objects.all(), widget=forms.RadioSelect, label="Dropoff/pickup time", empty_label=None)
    n_boxes_bought = forms.IntegerField(
        label='Quantity', widget=forms.TextInput(attrs={'size': '1'}))
    signature = forms.CharField(label='Signature',
                                max_length=50,
                                required=True)

    BOX_PRICE = "11.00"
    #BOX_PRICE = "00.01"
    MAX_BOXES = 9

    class Meta:
        model = UnpaidOrder
        fields = ('cell_number', 'dropoff_pickup_time', 'n_boxes_bought',
                  'proxy_name', 'proxy_email', 'signature')

    def clean_n_boxes_bought(self):
        quantity = self.cleaned_data['n_boxes_bought']
        if quantity > self.MAX_BOXES or quantity <= 0:
            raise forms.ValidationError("Limit %d boxes." % self.MAX_BOXES)
        dp_time = self.cleaned_data['dropoff_pickup_time']
        n_boxes_left = dp_time.n_boxes_total - dp_time.n_boxes_bought
        if quantity > n_boxes_left:
            raise forms.ValidationError(
                "There are only %d boxes available for the time you picked." %
                n_boxes_left)
        return quantity

    def clean_proxy_name(self):
        return string.capitalize(self.cleaned_data['proxy_name'].lower())

    def save(self, user, commit=True):
        #dp_time = self.cleaned_data['dropoff_pickup_time']
        form = super(RegistrationForm, self).save(commit=False)
        form.user = user
        form.invoice_id = str(uuid.uuid1())
        if commit:
            form.save()
        return form
Beispiel #24
0
class UserRegistrationForm(forms.ModelForm):
    password = forms.CharField(label=u'Password', widget=forms.PasswordInput(render_value=False))
    retyped_password = forms.CharField(label=u'Retype Password', widget=forms.PasswordInput(render_value=False))
    zipcode = USZipCodeField()
    phone = USPhoneNumberField()

    def __init__(self, *args, **kwargs):
        super(forms.ModelForm, self).__init__(*args, **kwargs)
        self.fields.keyOrder = [
            'username',
            'first_name',
            'last_name',
            'email',
            'password',
            'retyped_password',
            'address_line_1',
            'address_line_2',
            'city',
            'state',
            'zipcode',
            'phone']
    
    class Meta:
        model = User
        fields = ['username', 'first_name', 'last_name', 'email', 'password', 'address_line_1', 'address_line_2', 'city', 'state', 'zipcode', 'phone']

    def clean(self):
        cleaned_data = self.cleaned_data
        password = cleaned_data.get('password', '')
        retyped_password = cleaned_data.get('retyped_password', '')
        
        if password != retyped_password:
            raise ValidationError('Password and retyped password didn\'t match.')
        
        return cleaned_data

    def save(self, force_insert=False, force_update=False, commit=True, *args, **kwargs):
        user = super(UserRegistrationForm, self).save(*args, **kwargs)
        password = user.password
        user.set_password(password)
        user.save()
        
        return user
Beispiel #25
0
class CFCSignupForm(forms.Form):
    def __init__(self, *args, **kwargs):
        super(CFCSignupForm, self).__init__(*args, **kwargs)
        self.fields['state']._fill_choices(states_in_the_US())
        self.fields['actioncenter']._fill_choices(vibha_action_centers())

    first_name = forms.CharField(label="First Name", max_length=100)
    last_name = forms.CharField(label="Last Name", max_length=100)
    pg_first_name = forms.CharField(label="Parent/Guardian First Name",
                                    max_length=100,
                                    required=False)
    pg_last_name = forms.CharField(label="Parent/Guardian Last Name",
                                   max_length=100,
                                   required=False)
    email = forms.EmailField(label="E-mail")
    phone = USPhoneNumberField()
    address_1 = forms.CharField(label="Address Line1",
                                max_length=100,
                                required=False)
    address_2 = forms.CharField(label="Address Line2",
                                max_length=100,
                                required=False)
    city = forms.CharField(label="City", max_length=100, required=False)
    state = vibhaforms.ForeignKeyChoiceField(required=False)
    actioncenter = vibhaforms.ForeignKeyChoiceField(required=False)
    zipcode = USZipCodeField(required=False)
    comments = forms.CharField(label="Comments",
                               widget=forms.Textarea(),
                               required=False)
    receipt = forms.BooleanField(
        label="Need receipt?",
        required=False,
        help_text="""If the donation box is kept at a common
                     place like office cubicle or break room where anybody
                     can drop the change, that money is not tax
                     deductible""")
    agreement = forms.BooleanField(
        label="Agreement",
        help_text="""By selecting this option, I attest that I
                     am above 18 years of age or my parent/guardian has
                     approved signing up for this program""")
Beispiel #26
0
class ContactForm(Form):
    subject = CharField(max_length=100)
    message = CharField(max_length=2000,
                        widget=Textarea(attrs={
                            'cols': 35,
                            'rows': 5
                        }))
    name = CharField(max_length=200)
    phone = USPhoneNumberField(help_text='123-456-7890 only please!')
    email = EmailField()
    cc_myself = BooleanField(required=False)
    captcha = CaptchaField()

    def save(self):
        fd = self.cleaned_data
        cs = ContactSubmission(fd['subject'], fd['message'], fd['name'],
                               fd['phone'], fd['email'])
        mail_send([CONTACT_FORM_EMAIL], cs, 'mail/contact_form')
        if fd['cc_myself'] and fd['email']:
            mail_send([fd['email']], cs, 'mail/contact_form')
        return cs
Beispiel #27
0
class ProfileForm(forms.Form):
    """Define the form for the My_Info widget."""
    def __init__(self, *args, **kwargs):
        """Override init to take a user argument."""
        self.username = kwargs.pop('user', None)
        self.message = None
        super(ProfileForm, self).__init__(*args, **kwargs)

    display_name = forms.CharField(required=True, max_length=16, min_length=1)
    THEME_CHOICES = ((key, key[6:].capitalize()) for key in settings.INSTALLED_THEMES)

    theme = forms.ChoiceField(choices=THEME_CHOICES)

    # Event notifications
    contact_email = forms.EmailField(required=False)
    contact_text = USPhoneNumberField(required=False, widget=forms.TextInput(attrs={
        "style": "width: 100px",
        }))
    contact_carrier = forms.ChoiceField(choices=TextReminder.TEXT_CARRIERS)

    def clean_display_name(self):
        """Check if this profile name is valid."""
        name = self.cleaned_data['display_name'].strip()
        # Remove extra whitespace from the name.
        spaces = re.compile(r'\s+')
        name = spaces.sub(' ', name)

        # Check for name that is just whitespace.
        if name == '':
            raise forms.ValidationError('This field is required')

        # Check for duplicate name
        if Profile.objects.exclude(user__username=self.username).filter(name=name).count() > 0:
            raise forms.ValidationError("%s is taken.  Please use another name.")

        return name

    def clean_contact_email(self):
        """make the email lower case."""
        return self.cleaned_data['contact_email'].lower()
Beispiel #28
0
class RegisterForm(forms.Form):
    first_name = forms.CharField(max_length=30)
    last_name = forms.CharField(max_length=30)
    email = forms.EmailField()
    phone = USPhoneNumberField(required=False)
    password = forms.CharField(label='Password', widget=forms.PasswordInput)
    password2 = forms.CharField(label='Password Again',
                                widget=forms.PasswordInput)

    def clean_email(self):
        email = self.cleaned_data.get('email')
        if email and User.objects.filter(email__iexact=email).exists():
            raise forms.ValidationError(
                'There is already a user with that email.')
        return email

    def clean(self):
        password = self.cleaned_data.get('password')
        password2 = self.cleaned_data.get('password2')
        if password and password2 and password != password2:
            raise forms.ValidationError('Passwords do not match.')
        return self.cleaned_data

    def save(self):
        first_name = self.cleaned_data['first_name']
        last_name = self.cleaned_data['last_name']
        email = self.cleaned_data['email']
        phone = self.cleaned_data['phone']
        password = self.cleaned_data['password']
        user = User.objects.create(first_name=first_name,
                                   last_name=last_name,
                                   email=email)
        user.set_password(password)
        if phone:
            user.profile.phone = phone
            user.profile.save()
            PhoneVerification.create_with_unique_code(phone)
        EmailVerification.create_with_unique_code(email)
        user.save()
Beispiel #29
0
class AccountSettingsForm(forms.Form):

    username = forms.CharField(max_length=30, label=_("User Name"))
    preferred_contact_method = forms.TypedChoiceField(
        label=_("How do you prefer to be contacted for a follow up?"),
        choices=CONTACT_CHOICES,
    )
    mobile_phone_number = USPhoneNumberField(max_length=12,
                                             label=_("Mobile Phone Number"),
                                             required=False)
    email = forms.CharField(max_length=30, label=_("Email"), required=False)

    required_css_class = 'required'

    def clean_twitter(self):
        twitter = self.cleaned_data.get("twitter", "")
        if twitter != "":
            if twitter[0:1] == "@":
                twitter = twitter[1:]
        return twitter

    def clean_email(self):
        email = self.cleaned_data.get('email', "")
        if email:
            username = self.cleaned_data.get('username')
            if email and User.objects.filter(email=email).exclude(
                    email=email).count():
                raise forms.ValidationError(
                    _('This email address is already registered.'))
            return email
        else:
            return "*****@*****.**"

    def clean_username(self):
        username = self.cleaned_data.get('username')
        if username and User.objects.filter(username=username).exclude(
                username=username).count():
            raise forms.ValidationError(_('This username is already taken.'))
        return username
Beispiel #30
0
class AustinCricket08RegistrationForm(forms.Form):
    first_name = vibhaforms.CharField(max_length=100)
    last_name = vibhaforms.CharField(max_length=100)
    email = vibhaforms.EmailField()
    phone = USPhoneNumberField(help_text='Eg: 111-111-1111')
    INDIVIDUAL_TEAM_CHOICE = [
        (u'Team', u'Team registration'),
        (u'Individual', u'Individual registration'),
    ]
    individual = forms.ChoiceField(
        choices=INDIVIDUAL_TEAM_CHOICE,
        label=u'Team/Individual',
        initial=u'Team',
        widget=vibhaforms.RadioSelect(show_br=False))
    team_name = vibhaforms.CharField(max_length=100, required=False)
    num_students = forms.IntegerField(required=False, initial=0)
    num_non_students = forms.IntegerField(help_text="""In case of team
            registration, there should be a total of eight players.""",
                                          required=False,
                                          initial=0)
    comments = vibhaforms.CharField(
        label="How did you hear about us?/Other comments",
        required=False,
        widget=forms.Textarea(attrs={'rows': 5}))