Exemplo n.º 1
0
class VisitSelectorForm(forms.Form):
    start_date = forms.DateField(
        label='Start date',
        widget=SelectDateWidget(years=range(2008,
                                            datetime.date.today().year + 1)),
        initial=timezone.now().date())
    end_date = forms.DateField(
        label='End date',
        widget=SelectDateWidget(years=range(2008,
                                            datetime.date.today().year + 1)),
        initial=timezone.now().date())
Exemplo n.º 2
0
class SchoolVisitFormOneBase(forms.Form):
    school = forms.ModelChoiceField(
        queryset=School.objects.none(),
        help_text=
        _('If the school is not listed here, it first needs to be added in Workshops > Add School'
          ))
    date = forms.DateField(
        label=_('School visit date'),
        widget=SelectDateWidget(years=range(2008,
                                            datetime.date.today().year + 3)),
        initial=timezone.now().date())
    start_time = forms.TimeField(label=_('Start time'), initial='10:00:00')
    end_time = forms.TimeField(label=_('End time'), initial='13:00:00')
    location = forms.CharField(
        label=_("Location"),
        help_text=_(
            "Where the workshop takes place, at the school or elsewhere"))

    # Form validation
    def clean(self):
        cleaned_data = super(SchoolVisitFormOneBase, self).clean()
        start = cleaned_data.get("start_time")
        end = cleaned_data.get("end_time")
        if start and end and end <= start:
            msg = _("Start time must be before end time.")
            self._errors["start_time"] = self.error_class([msg])
            self._errors["end_time"] = self.error_class([msg])
            del cleaned_data["start_time"]
            del cleaned_data["end_time"]
        return cleaned_data
Exemplo n.º 3
0
class WriteSMSForm(forms.Form):
	SCHEDULED_DATE_TYPES = (
		(1, 'My timezone'),
		(2, 'Recipients\' timezones'),
	)

	body = forms.CharField(widget=forms.Textarea(attrs={'cols': '35', 'rows': '7', 'onkeyup': 'updateTextBoxCounter();'}), initial=_("Put your message here.  To opt-out reply 'stop'"))
	from_type = forms.ChoiceField(choices=((0,"+61429558100 (myRobogals)"),), help_text=_('You can send SMSes from your own number if you <a href="%s">verify your number</a>') % '/profile/mobverify/')
	recipients = SMSModelMultipleChoiceField(queryset=User.objects.none(), widget=FilteredSelectMultiple("Recipients", False, attrs={'rows': 10}), required=False)
	chapters = forms.ModelMultipleChoiceField(queryset=Group.objects.all().order_by('name'), widget=FilteredSelectMultiple("Chapters", False, attrs={'rows': 10}), required=False)
	chapters_exec = forms.ModelMultipleChoiceField(queryset=Group.objects.all().order_by('name'), widget=FilteredSelectMultiple("Chapters", False, attrs={'rows': 10}), required=False)
	list = forms.ModelChoiceField(queryset=UserList.objects.none(), required=False)
	schedule_time = forms.TimeField(widget=SelectTimeWidget(), initial=datetime.now(), required=False)
	schedule_date = forms.DateField(widget=SelectDateWidget(years=range(datetime.now().year, datetime.now().year + 2)), initial=datetime.now(), required=False)
	schedule_zone = forms.ChoiceField(choices=SCHEDULED_DATE_TYPES, initial=2, required=False)

	def __init__(self, *args, **kwargs):
		user=kwargs['user']
		del kwargs['user']
		super(WriteSMSForm, self).__init__(*args, **kwargs)
		if user.is_superuser:
			self.fields['recipients'].queryset = User.objects.filter(is_active=True, mobile_marketing_optin=True).exclude(mobile='').order_by('last_name')
		else:
			self.fields['recipients'].queryset = User.objects.filter(chapter=user.chapter, is_active=True, mobile_marketing_optin=True).exclude(mobile='').order_by('last_name')
		self.fields['list'].queryset = UserList.objects.filter(chapter=user.chapter)
		if user.mobile_verified:
			self.fields['from_type'].choices = (
				(1, "+" + user.mobile + " (you)"),
				(0,"+61429558100 (myRobogals)"),
			)
			self.fields['from_type'].initial = 1
			self.fields['from_type'].help_text = ''
		self.fields['schedule_time'].initial = utc.localize(datetime.now()).astimezone(user.tz_obj())
		self.fields['schedule_date'].initial = utc.localize(datetime.now()).astimezone(user.tz_obj())
Exemplo n.º 4
0
class ReportSelectorForm(forms.Form):
    start_date = forms.DateField(
        label='Report start date',
        widget=SelectDateWidget(years=range(20011,
                                            datetime.date.today().year + 1)),
        initial=datetime.date.today())
    end_date = forms.DateField(
        label='Report end date',
        widget=SelectDateWidget(years=range(2011,
                                            datetime.date.today().year + 1)),
        initial=datetime.date.today())
    visit_type = forms.ChoiceField(
        choices=VISIT_TYPES_REPORT,
        required=True,
        help_text=
        _('For an explanation of each type please see <a href="%s" target="_blank">here</a> (opens in new window)'
          ) % '/teaching/statshelp/')
    printview = forms.BooleanField(label='Show printable version',
                                   required=False)
Exemplo n.º 5
0
class FormPartThree(forms.Form):
    def __init__(self, *args, **kwargs):
        chapter = kwargs['chapter']
        del kwargs['chapter']
        super(FormPartThree, self).__init__(*args, **kwargs)

    COURSE_TYPE_CHOICES = ((0, '---'), (1, _('Undergraduate')),
                           (2, _('Postgraduate')))

    STUDENT_TYPE_CHOICES = ((0, '---'), (1, _('Local')), (2,
                                                          _('International')))

    dob = forms.DateField(label=_('Date of birth'),
                          widget=SelectDateWidget(),
                          required=False)
    course = forms.CharField(label=_('Course'), max_length=128, required=False)
    uni_start = forms.DateField(label=_('Started university'),
                                widget=SelectMonthYearWidget(),
                                required=False)
    uni_end = forms.DateField(label=_('Will finish university'),
                              widget=SelectMonthYearWidget(),
                              required=False)
    university = forms.ModelChoiceField(label=_('University'),
                                        queryset=University.objects.all(),
                                        required=False)
    course_type = forms.ChoiceField(label=_('Course level'),
                                    choices=COURSE_TYPE_CHOICES,
                                    required=False)
    student_type = forms.ChoiceField(label=_('Student type'),
                                     choices=STUDENT_TYPE_CHOICES,
                                     required=False)
    job_title = forms.CharField(label=_('Occupation'),
                                max_length=128,
                                required=False)
    company = forms.CharField(label=_('Employer'),
                              max_length=128,
                              required=False)
    bio = forms.CharField(label=_('About me (for profile page)'),
                          required=False,
                          widget=forms.Textarea(attrs={
                              'cols': '35',
                              'rows': '7'
                          }))
Exemplo n.º 6
0
class WriteEmailForm(forms.Form):
	SCHEDULED_DATE_TYPES = (
		(1, 'My timezone'),
		(2, 'Recipients\' timezones'),
	)

	subject = forms.CharField(max_length=256)
	body = forms.CharField(widget=TinyMCE(attrs={'cols': 70}))
	from_type = forms.ChoiceField(choices=((0,"Robogals"),(1,_("Chapter name")),(2,_("Your name"))), initial=1)
	recipients = EmailModelMultipleChoiceField(queryset=User.objects.none(), widget=FilteredSelectMultiple(_("Recipients"), False, attrs={'rows': 10}), required=False)
	chapters = forms.ModelMultipleChoiceField(queryset=Group.objects.all().order_by('name'), widget=FilteredSelectMultiple(_("Chapters"), False, attrs={'rows': 10}), required=False)
	chapters_exec = forms.ModelMultipleChoiceField(queryset=Group.objects.all().order_by('name'), widget=FilteredSelectMultiple(_("Chapters"), False, attrs={'rows': 10}), required=False)
	list = forms.ModelChoiceField(queryset=UserList.objects.none(), required=False)
	newsletters = forms.ModelChoiceField(queryset=Newsletter.objects.all(), required=False)
	schedule_time = forms.TimeField(widget=SelectTimeWidget(), initial=datetime.now(), required=False)
	schedule_date = forms.DateField(widget=SelectDateWidget(years=range(datetime.now().year, datetime.now().year + 2)), initial=datetime.now(), required=False)
	schedule_zone = forms.ChoiceField(choices=SCHEDULED_DATE_TYPES, initial=2, required=False)
	header_list = forms.ModelChoiceField(queryset=EmailHeader.objects.all(), required=False)

	def __init__(self, *args, **kwargs):
		user=kwargs['user']
		del kwargs['user']
		super(WriteEmailForm, self).__init__(*args, **kwargs)
		if user.is_superuser:
			self.fields['recipients'].queryset = User.objects.filter(is_active=True, email_chapter_optin=True).exclude(email='').order_by('last_name')
		else:
			self.fields['recipients'].queryset = User.objects.filter(chapter=user.chapter, is_active=True, email_chapter_optin=True).exclude(email='').order_by('last_name')
		self.fields['list'].queryset = UserList.objects.filter(chapter=user.chapter)
		if not user.is_superuser:
			self.fields['body'].initial = _("<br><br>--<br>This email has been sent to you by %s ({{unsubscribe}})") % user.chapter.name
		self.fields['from_type'].choices = (
			(0, "Robogals <" + user.email + ">"),
			(1, user.chapter.name + " <" + user.email + ">"),
			(2, user.get_full_name() + " <" + user.email + ">")
		)
		self.fields['list'].queryset = UserList.objects.filter(chapter=user.chapter)
		self.fields['schedule_time'].initial = utc.localize(datetime.now()).astimezone(user.tz_obj())
		self.fields['schedule_date'].initial = utc.localize(datetime.now()).astimezone(user.tz_obj())
Exemplo n.º 7
0
class DefaultsFormOne(forms.Form):
    COURSE_TYPE_CHOICES = ((0, '---'), (1, 'Undergraduate'), (2,
                                                              'Postgraduate'))

    STUDENT_TYPE_CHOICES = ((0, '---'), (1, 'Local'), (2, 'International'))

    date_joined = forms.DateField(label=_('Date joined'),
                                  widget=SelectDateWidget(),
                                  required=False)
    gender = forms.ChoiceField(choices=GENDERS, initial=0)
    uni_start = forms.DateField(label=_('Started university'),
                                widget=SelectMonthYearWidget(),
                                required=False)
    uni_end = forms.DateField(label=_('Will finish university'),
                              widget=SelectMonthYearWidget(),
                              required=False)
    university = forms.ModelChoiceField(queryset=University.objects.all(),
                                        required=False)
    course_type = forms.ChoiceField(label=_('Course level'),
                                    choices=COURSE_TYPE_CHOICES,
                                    required=False)
    student_type = forms.ChoiceField(label=_('Student type'),
                                     choices=STUDENT_TYPE_CHOICES,
                                     required=False)
Exemplo n.º 8
0
class ConfRSVPForm(forms.Form):
    def __init__(self, *args, **kwargs):
        conf = kwargs['conf']
        del kwargs['conf']
        user = kwargs['user']
        del kwargs['user']
        super(ConfRSVPForm, self).__init__(*args, **kwargs)
        this_year = str(conf.committee_year)
        last_year = str(conf.committee_year - 1)
        next_year = str(conf.committee_year + 1)
        CHOICES = ((0,
                    last_year + "/" + this_year + " committee, now outgoing"),
                   (1, last_year + "/" + this_year +
                    " committee, continuing into " + this_year + "/" +
                    next_year + " committee"),
                   (2, "Incoming into " + this_year + "/" + next_year +
                    " committee"), (3,
                                    "None of the above; ordinary volunteer"))
        self.fields['attendee_type'].choices = CHOICES
        self.fields['first_name'].initial = user.first_name
        self.fields['last_name'].initial = user.last_name
        self.fields['email'].initial = user.email
        if user.mobile == '':
            pass
        elif user.mobile[0] != '0':
            self.fields['mobile'].initial = '+' + user.mobile
        else:
            self.fields['mobile'].initial = user.mobile
        self.fields['dob'].initial = user.dob
        if user.gender in [1, 2]:
            self.fields['gender'].initial = user.gender
        else:
            self.fields['gender'].initial = 2

    def clean(self):
        cleaned_data = self.cleaned_data
        attendee_type = int(cleaned_data.get('attendee_type'))
        outgoing_position = cleaned_data.get('outgoing_position')
        incoming_position = cleaned_data.get('incoming_position')
        #print attendee_type
        #print outgoing_position
        #print incoming_position
        if attendee_type == 0:
            if not outgoing_position:
                raise forms.ValidationError(
                    _('You have indicated that you are outgoing from your chapter committee, but did not specify your outgoing position. Please state the position from which you are outgoing, e.g. "Schools Manager". If your chapter does not assign specific roles, you can simply put "General Committee"'
                      ))
        elif attendee_type == 1:
            if not incoming_position:
                raise forms.ValidationError(
                    _('You have indicated that you are continuing in your chapter committee, but did not specify your position. Please state the position in which you are continuing, e.g. "Schools Manager". If your chapter does not assign specific roles, you can simply put "General Committee"'
                      ))
        elif attendee_type == 2:
            if not incoming_position:
                raise forms.ValidationError(
                    _('You have indicated that you are incoming into your chapter committee, but did not specify your incoming position. Please state the position into which you are incoming, e.g. "Schools Manager". If your chapter does not assign specific roles, you can simply put "General Committee"'
                      ))
        return cleaned_data

    GENDERS = (
        (1, 'Male'),
        (2, 'Female'),
    )

    first_name = forms.CharField(
        label=_("First name"),
        help_text=
        _("Whatever you put here is what the name tag will show.<br />You can put a preferred name, e.g. 'Bec' instead of 'Rebecca' if you like."
          ),
        required=True,
        widget=forms.TextInput(attrs={'size': '30'}))
    last_name = forms.CharField(label=_("Last name"),
                                required=True,
                                widget=forms.TextInput(attrs={'size': '30'}))
    attendee_type = forms.ChoiceField(label=_("This person is"),
                                      choices=((0, ''), ))
    gender = forms.ChoiceField(label=_("Gender"), choices=GENDERS)
    outgoing_position = forms.CharField(
        label=_("Outgoing position"),
        required=False,
        widget=forms.TextInput(attrs={'size': '30'}))
    incoming_position = forms.CharField(
        label=_("Incoming position"),
        required=False,
        widget=forms.TextInput(attrs={'size': '30'}))
    email = forms.EmailField(label=_("Email"),
                             required=True,
                             widget=forms.TextInput(attrs={'size': '30'}))
    mobile = forms.CharField(label=_("Mobile/cell phone"),
                             required=True,
                             widget=forms.TextInput(attrs={'size': '30'}))
    dob = forms.DateField(
        label=_("Date of birth"),
        help_text=
        _("If you are under 18, we will send you a form that must be signed by your parent or guardian."
          ),
        widget=SelectDateWidget(),
        required=True)
    update_account = forms.BooleanField(label=_(
        "Also update this person's account in myRobogals with the email, mobile and DOB above"
    ),
                                        required=False,
                                        initial=False)
    emergency_name = forms.CharField(
        label=_("Contact name"),
        required=True,
        widget=forms.TextInput(attrs={'size': '30'}))
    emergency_number = forms.CharField(
        label=_("Contact number"),
        required=True,
        widget=forms.TextInput(attrs={'size': '30'}))
    emergency_relationship = forms.CharField(
        label=_("Relationship to you"),
        required=True,
        widget=forms.TextInput(attrs={'size': '30'}))
    tshirt = forms.ModelChoiceField(
        label=_("T-shirt size"),
        queryset=ShirtSize.objects.filter(chapter__id=1),
        required=True)
    arrival_time = forms.CharField(
        label=_("Arrival time, if known"),
        required=False,
        widget=forms.TextInput(attrs={'size': '30'}))
    dietary_reqs = forms.CharField(
        label=_("Dietary requirements"),
        required=False,
        widget=forms.TextInput(attrs={'size': '30'}))
    comments = forms.CharField(label=_("Comments or special requests"),
                               required=False,
                               widget=forms.TextInput(attrs={'size': '30'}))
Exemplo n.º 9
0
class FormPartOne(forms.Form):
    def __init__(self, *args, **kwargs):
        chapter = kwargs['chapter']
        del kwargs['chapter']
        user_id = kwargs['user_id']
        del kwargs['user_id']
        super(FormPartOne, self).__init__(*args, **kwargs)
        self.fields['mobile'] = MobileField(label=_('Mobile phone'),
                                            max_length=20,
                                            required=False,
                                            widget=MobileTextInput(),
                                            chapter=chapter)

        if chapter.student_number_enable:
            self.fields['student_number'].label = chapter.student_number_label
            self.fields[
                'student_number'].required = chapter.student_number_required
            self.fields['student_number'].chapter = chapter
            self.fields['student_number'].user_id = user_id
        else:
            del self.fields['student_number']

        if chapter.student_union_enable:
            self.fields['union_member'].label = chapter.student_union_label
            self.fields[
                'union_member'].required = chapter.student_union_required
        else:
            del self.fields['union_member']

        if chapter.tshirt_enable:
            self.fields['tshirt'].label = chapter.tshirt_label
            self.fields['tshirt'].required = chapter.tshirt_required
            self.fields['tshirt'].queryset = ShirtSize.objects.filter(
                chapter=chapter)
        else:
            del self.fields['tshirt']

        if chapter.police_check_number_enable:
            self.fields[
                'police_check_number'].label = chapter.police_check_number_label
            self.fields['police_check_expiration'].label = 'Expiration Date'
            self.fields[
                'police_check_number'].required = chapter.police_check_number_required
            self.fields[
                'police_check_expiration'].required = chapter.police_check_number_required
        else:
            del self.fields['police_check_number']
            del self.fields['police_check_expiration']

    username = forms.CharField(label=_('Username'), max_length=30)
    first_name = forms.CharField(label=_('First name'), max_length=30)
    last_name = forms.CharField(label=_('Last name'), max_length=30)
    email = forms.EmailField(label=_('Email'), max_length=64)
    student_number = StudentNumField(max_length=32)
    union_member = forms.BooleanField()
    tshirt = ShirtChoiceField(queryset=ShirtSize.objects.none())
    alt_email = forms.EmailField(label=_('Alternate email'),
                                 max_length=64,
                                 required=False)
    mobile = forms.BooleanField()
    gender = forms.ChoiceField(label=_('Gender'), choices=GENDERS)
    police_check_number = forms.CharField(help_text=_(
        "Also known as the number that allows you to volunteer with Robogals. Ask an executive member if unsure. When this number is entered, your chapter's executive members will be notified"
    ))
    police_check_expiration = forms.DateField(
        widget=SelectDateWidget(),
        help_text=
        _("You must also enter an expiration date shown on your card. myRobogals will inform you and your chapter executives when the card is about to expire"
          ))

    def clean(self):
        cleaned_data = super(FormPartOne, self).clean()
        police_check_number = cleaned_data.get("police_check_number")
        police_check_expiration = cleaned_data.get("police_check_expiration")

        if police_check_number and police_check_expiration:
            # Only check expiration date if field is required and the user has entered a p/c number
            if self.fields[
                    'police_check_expiration'].required or police_check_number != '':
                local_time = datetime.date(now())

                # Check if card has expired in their local time only if they've made changes
                if police_check_expiration < local_time:
                    self.add_error(
                        'police_check_expiration',
                        'The card you have entered has already expired')
            else:
                cleaned_data["police_check_expiration"] = None

        return cleaned_data