Esempio n. 1
0
 class AdminReportForm(forms.Form):
     stdate = forms.DateField(
         label=_('Satrt date'),
         widget=SelectDateWidget(years=range(dt.year - 5, dt.year + 1)))
     spdate = forms.DateField(
         label=_('Stop date'),
         widget=SelectDateWidget(years=range(dt.year - 5, dt.year + 1)))
Esempio n. 2
0
class PrescriptionEditForm(forms.Form):
    p_doctor = forms.CharField(label='Prescribing Doctor',
                               widget=forms.TextInput(attrs={'placeholder': 'will be set to curDoctor'}),
                               required=False)
    p_patient = forms.CharField(label='Patient',
                                widget=forms.TextInput(attrs={'placeholder': 'Patient Email'}),
                                required=False)
    p_created = forms.DateField(label='Date Created', initial=datetime.today, required=False,
                                widget=SelectDateWidget(attrs={'class': 'smallDrop'}))
    p_prescription = forms.CharField(label='Medication', required=True)
    p_dose = forms.IntegerField(label='Dosage', initial=0, required=True)
    labels = (
        ('mg', 'mg'),
        ('cc', 'cc'),
    )
    p_units = forms.ChoiceField(label='Units', choices=labels, widget=forms.Select(attrs={'class': 'smallDrop'}),
                                initial='mg', required=True)
    p_refills = forms.IntegerField(label='Refills', initial=0, required=True)
    p_expiration = forms.DateField(label='Expiration Date', initial=datetime.today, required=True,
                                   widget=SelectDateWidget(attrs={'class': 'smallDrop'}))

    def clean_p_dose(self):
        p_dose = self.cleaned_data.get('p_dose')
        if p_dose <= 0:
            raise forms.ValidationError('Not a valid dose amount')
        return p_dose
Esempio n. 3
0
class PrescriptionForm(forms.Form):
    error_css_class = 'error'
    p_doctor = forms.CharField(label='Prescribing Doctor',
                               widget=forms.TextInput(attrs={'placeholder': 'will be set to curDoctor'}),
                               required=False)
    #p_patient = forms.CharField(label='Patient',
    #                            widget=forms.TextInput(attrs={'placeholder': 'Patient Email'}),
    #                            required=False)

    p_patient = forms.ModelChoiceField(queryset=Patient.objects, empty_label=None, label='Patient', widget=forms.Select(attrs={'class': 'chzn-select'}))
    p_prescription = forms.CharField(label='Medication', required=True)
    p_dose = forms.IntegerField(label='Dosage', initial=0, required=True)
    labels = (
        ('mg', 'mg'),
        ('cc', 'cc'),
    )
    p_units = forms.ChoiceField(label='Units', choices=labels, widget=forms.Select(attrs={'class': 'smallDrop'}),
                                initial='mg', required=True)
    p_refills = forms.IntegerField(label='Refills', initial=0, required=True)
    p_expiration = forms.DateField(label='Expiration Date', initial=datetime.today, required=True,
                                   widget=SelectDateWidget(attrs={'class': 'smallDrop'}))
    p_created = forms.DateField(label='Date Created', initial=datetime.today, required=True,
                                widget=SelectDateWidget(attrs={'class': 'smallDrop'}))

    def clean_p_patient(self):
        p_patient = self.cleaned_data.get('p_patient')
        if not Patient.objects.all().filter(email=p_patient).exists():
            raise forms.ValidationError('Not a valid Patient email address')
        return p_patient

    def clean_p_dose(self):
        p_dose = self.cleaned_data.get('p_dose')
        if p_dose <= 0:
            raise forms.ValidationError('Not a valid dose amount')
        return p_dose
Esempio n. 4
0
 def __init__(self, form, request, *args, **kwargs):
     """
     Iterate through the fields of the ``forms.models.Form`` instance and 
     create the form fields required to control including the field in 
     the export (with a checkbox) or filtering the field which differs 
     across field types. User a list of checkboxes when a fixed set of 
     choices can be chosen from, a pair of date fields for date ranges, 
     and for all other types provide a textbox for text search.
     """
     self.form = form
     self.request = request
     self.form_fields = form.fields.all()
     self.entry_time_name = unicode(
         FormEntry._meta.get_field("entry_time").verbose_name).encode(
             "utf-8")
     super(ExportForm, self).__init__(*args, **kwargs)
     for field in self.form_fields:
         field_key = "field_%s" % field.id
         # Checkbox for including in export.
         self.fields["%s_export" % field_key] = forms.BooleanField(
             label=field.label, initial=True, required=False)
         if field.is_a(*fields.CHOICES):
             # A fixed set of choices to filter by.
             if field.is_a(fields.CHECKBOX):
                 choices = ((True, _("Checked")), (False, _("Not checked")))
             else:
                 choices = field.get_choices()
             contains_field = forms.MultipleChoiceField(
                 label=" ",
                 choices=choices,
                 widget=forms.CheckboxSelectMultiple(),
                 required=False)
             self.fields["%s_filter" % field_key] = choice_filter_field
             self.fields["%s_contains" % field_key] = contains_field
         elif field.is_a(*fields.DATES):
             # A date range to filter by.
             self.fields["%s_filter" % field_key] = date_filter_field
             self.fields["%s_from" % field_key] = forms.DateField(
                 label=" ", widget=SelectDateWidget(), required=False)
             self.fields["%s_to" % field_key] = forms.DateField(
                 label=_("and"), widget=SelectDateWidget(), required=False)
         else:
             # Text box for search term to filter by.
             contains_field = forms.CharField(label=" ", required=False)
             self.fields["%s_filter" % field_key] = text_filter_field
             self.fields["%s_contains" % field_key] = contains_field
     # Add ``FormEntry.entry_time`` as a field.
     field_key = "field_0"
     self.fields["%s_export" % field_key] = forms.BooleanField(
         initial=True,
         label=FormEntry._meta.get_field("entry_time").verbose_name,
         required=False)
     self.fields["%s_filter" % field_key] = date_filter_field
     self.fields["%s_from" % field_key] = forms.DateField(
         label=" ", widget=SelectDateWidget(), required=False)
     self.fields["%s_to" % field_key] = forms.DateField(
         label=_("and"), widget=SelectDateWidget(), required=False)
Esempio n. 5
0
class PlanningRequestForm(ModelForm):
    class Meta:
        model = PlanningRequest
        exclude = [
            "state", "budget_feedback", "decoration_descr", "parties_descr",
            "drinks_descr", "food_descr", "media_descr"
        ]

    client = forms.ModelChoiceField(queryset=Client.objects.all(),
                                    required=False)
    from_date = fields.DateField(widget=SelectDateWidget())
    to_date = fields.DateField(widget=SelectDateWidget())
Esempio n. 6
0
class MakeTeacherPlanFrom(forms.Form):
  start_date = IntegerField(
    label="Год начала действия учебного плана",
    widget=forms.TextInput(attrs={'type': 'number', "min": "2000", "max": "2100", "step": "1"})
  )
  first_name = CharField(label="Имя", max_length=30)
  last_name = CharField(label="Фамилия", max_length=30)
  patronymic = CharField(label="Отчество", max_length=30)
  election_date = DateField(
    label="Дата текущего избрания или зачисления на преподавательскую должность",
    widget=SelectDateWidget(years=[y for y in range(2000, 2100)])
  )
  position = CharField(
    max_length=40,
    label="Должность",
  )
  contract_date = DateField(
    label="Срок окончания трудового договора",
    widget=SelectDateWidget(years=[y for y in range(1940, 2100)]),
  )

  academic_degree = ChoiceField(
    choices=ACADEMIC_DEGREE_CHOICES,
    label="Ученая степень",
  )

  year_of_academic_degree = IntegerField(
    label="Год присвоения ученой степени",
    widget=forms.TextInput(attrs={'type': 'number', "min": "1950","max":"2100", "step": "1"})
  )

  academic_status = ChoiceField(
    choices=ACADEMIC_STATUS_CHOICES,
    label="Учебное звание",
  )

  year_of_academic_status = IntegerField(
    label="Год получения учебного звания",
    widget=forms.TextInput(attrs={'type': 'number', "min": "1950", "max": "2100", "step": "1"})
  )

  rate = ChoiceField(
    choices=RATE_CHOICES,
    label="Ставка"
  )

  department_name = CharField(label="Название кафедры", max_length=10)
  organisation_name = CharField(label="Название факультета", max_length=10)
  department_head = CharField(label="Заведующий кафедры", max_length=100)
  organisation_head = CharField(label="Декан", max_length=100)
Esempio n. 7
0
class EditPlayerForm(forms.ModelForm):
    date_of_birth = forms.DateField(
        label='Date of Birth*',
        widget=SelectDateWidget(empty_label=('Year', 'Month', 'Day'),
                                years=range(timezone.now().year,
                                            timezone.now().year - 70, -1)))
    gender = forms.CharField(label='Gender*',
                             widget=forms.Select(choices=(('', ''), ) +
                                                 Player.GENDER_CHOICES))
    nickname = forms.CharField(required=False)
    phone = forms.CharField(required=False)
    zip_code = forms.CharField(label='Postal/Zip Code', required=False)
    height_inches = forms.IntegerField(label='Height Inches', required=False)
    jersey_size = forms.CharField(
        label='Jersey Size',
        required=False,
        widget=forms.Select(choices=(('', ''), ) + Player.JERSEY_SIZE_CHOICES))

    guardian_name = forms.CharField(label='Parent/Guardian Name',
                                    required=False)
    guardian_phone = forms.CharField(label='Parent/Guardian Phone',
                                     required=False)

    class Meta:
        model = Player
        exclude = (
            'id',
            'groups',
            'user',
            'highest_level',
            'post_count',
        )
Esempio n. 8
0
class CreateImmForm(forms.Form):
    firstname = forms.CharField(max_length=20, label="First Name")
    lastname = forms.CharField(max_length=20, label="Last Name")
    gender = forms.ChoiceField(choices=(('Male', 'Male'), ('Female',
                                                           'Female')),
                               label="Gender")
    date = forms.DateField(widget=SelectDateWidget(years=range(1900, 1960)),
                           label="Immigration Date")
    country = forms.CharField(max_length=20, label="Home Country")

    continentChoices = tuple([(c.cname, c.cname) for c in getContinent()])
    continent = forms.ChoiceField(choices=continentChoices, label="Continent")

    ethnicity = forms.CharField(max_length=20, label="Ethnicity")
    spokenlang = forms.CharField(max_length=20, label="Language")

    plocChoices = tuple([(ploc.plname, ploc.plname)
                         for ploc in getProcessLocations()])
    processLocation = forms.ChoiceField(choices=plocChoices,
                                        label="Process Location")

    city = forms.CharField(max_length=20, label="Destination City")

    stateChoices = tuple([(s.sname, s.sname) for s in getStates()])
    state = forms.ChoiceField(choices=stateChoices, label="Destination State")
Esempio n. 9
0
class SubastasForm(ModelForm):
	fechaFin = forms.DateField(required=False, label = 'Fecha de finalización', widget=SelectDateWidget())
 
	class Meta:
		model 	= Subastas
		fields 	= ('titulo', 'detalle', 'precioBase', 'idCategoria','fechaFin', 'localidad', 'provincia', 'pais', 'imagenA', 'imagenB', 'imagenC')
		labels 	= { 'titulo': 'Título', 'detalle': 'Detalle', 'precioBase': 'Precio base', 'idCategoria': 'Categoria', 'fechaFin': 'Fecha finalizacion','localidad' : 'Localidad', 'provincia': 'Provincia', 'pais': 'Pais', 'imagenA': 'Imagen 1', 'imagenB': 'Imagen 2', 'imagenC': 'Imagen 3' }
Esempio n. 10
0
class EditProfileForm2(forms.ModelForm):
    class Meta:
        model = Profile
        fields = (
            'location',
            'birthdate',
            'bio',
            'phone_number',
        )

    location = forms.CharField(
        max_length=30,
        required=True,
        label='Location',
        widget=forms.TextInput(attrs={'class': 'form-control'}))
    birthdate = forms.DateField(
        required=True,
        label='Date of Birth',
        widget=SelectDateWidget(years=range(1900, 2000)))
    bio = forms.CharField(
        widget=forms.Textarea(attrs={'class': 'form-control'}),
        max_length=500,
        required=False,
        label='Bio')
    phone_number = forms.IntegerField(
        required=True,
        label='Phone Number (After +91)',
        widget=forms.TextInput(attrs={'class': 'form-control'}))
Esempio n. 11
0
class FanPageForm(forms.Form):
    YEARS = range(datetime.datetime.now().date().year,
                  datetime.datetime.now().date().year - 100, -1)

    name = forms.CharField(
        label='User Name',
        help_text='This can be your real name or something made up!')
    date_of_birth = forms.DateField(widget=SelectDateWidget(years=YEARS))
    state = forms.ChoiceField(choices=[(k, v)
                                       for k, v in SORTED_STATES.items()],
                              label="Where is your favorite team located?")
    file = forms.FileField(
        required=False,
        label="Add logo to your profile",
        help_text="Great logos are square and about 200px x 200px")

    def __init__(self, *args, **kwargs):
        fan_id = kwargs.pop('fan_id', None)
        self.fan_id = fan_id
        self.image = kwargs.pop('image', None)

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

        if self.image:
            self.update_file_field_label_and_help_text()

    def update_file_field_label_and_help_text(self):
        self.fields['file'].label = "Replace your current logo"
        self.fields['file'].help_text = """
<span class=\"help-text-content\">Great logos are square and about 200px x 200px</span>
<img class=\"edit-team-logo-img pull-left\" src=\"/file/serve/%s\"/>
""" % self.image.id
Esempio n. 12
0
class TripPlanner(forms.ModelForm):
    date_from = forms.DateField(widget=SelectDateWidget())
    date_to = forms.DateField(widget=SelectDateWidget())


    class Meta:
        model = Trip
        fields = (
            'description',
            'date_from',
            'date_to',
        )
    def clean(self):
        date_from = self.cleaned_data.get("date_from")
        date_to = self.cleaned_data.get("date_to")
        if date_to < date_from:
            raise forms.ValidationError("End date should be greater than start date.")
Esempio n. 13
0
class UploadDocumentForm(forms.ModelForm):
    class Meta:
        model = Document

    published = forms.DateField(
        widget=SelectDateWidget(years=range(1970, YEAR + 1)),
        label='Dato',
        initial=Document._meta.get_field('published').default)
Esempio n. 14
0
class ProfileEditForm(forms.ModelForm):
    present = datetime.datetime.now().year
    date_of_birth = forms.DateField(widget=SelectDateWidget(
        attrs={'style': 'width: 32.5%; display: inline-block;'},
        years=range(1950, present)))

    class Meta:
        model = Profile
        fields = ('date_of_birth', 'city', 'country', 'education', 'photo')
Esempio n. 15
0
class ProfileForm(forms.Form):
    name = forms.CharField(label='Navn')
    street = forms.CharField(label='Gade')
    city = forms.CharField(label='Postnr. og by')
    phone = forms.CharField(label='Telefon')
    email = forms.EmailField(label='Email')
    study = forms.CharField(label='Studium')
    birthday = forms.DateField(
        label='Fødselsdag', widget=SelectDateWidget(years=range(1970, YEAR)))
Esempio n. 16
0
 class Meta:
     model = Resume
     fields = (
         'post',
         'category',
         'schedule',
         'type_employment',
         'wage_min',
         'type_wages',
         'fio',
         'photo',
         'dob',
         'sex',
         'marital_status',
         'experience',
         'professional_skills',
         'education',
         'educational_institution',
         'major_subject',
         'extras_education',
         'personal_qualities',
         'driver_license',
         'willing_travel',
         'smoke',
         'summary',
         'phone1',
         'other_phone1',
         'email',
         'icq',
         'skype',
         'city',
     )
     widgets = {
         'photo':
         ImageWidget(attrs={}),
         'professional_skills':
         forms.Textarea(attrs={
             'class': 'span12',
             'rows': 3
         }),
         'extras_education':
         forms.Textarea(attrs={
             'class': 'span12',
             'rows': 3
         }),
         'personal_qualities':
         forms.Textarea(attrs={
             'class': 'span12',
             'rows': 3
         }),
         'dob':
         SelectDateWidget(attrs={'class': 'span4'},
                          years=range(1930,
                                      datetime.datetime.now().year - 14)),
     }
Esempio n. 17
0
class SignupForm(forms.ModelForm):
    confirm_password = forms.CharField(widget=forms.PasswordInput)
    birthday = forms.DateField(widget=SelectDateWidget(
        years=range(2015, 1900, -1)))

    class Meta:
        model = Guest
        fields = [
            'username', 'password', 'first_name', 'last_name', 'birthday',
            'email', 'gender', 'avatar'
        ]
Esempio n. 18
0
class UserInfo(forms.ModelForm):
    """
    ``个人资料``
    sign  签名
    job 工作
    first_name 名
    last_name 姓
    sex   性别
    birthday  生日
    country   国家
    state     州省
    city      区县
    qq      qq号码
    weibo   微博帐号
    phone_number  电话号码
    """
    # TODO : 未完成
    SEX_CHOICES = (('M', u'男'), ('F', u'女'))
    sign = forms.CharField(label=u'签名',
                           widget=forms.Textarea(attrs={
                               'class': 'span11',
                               'rows': '4',
                           }))
    job = forms.ChoiceField(label=u'职业',
                            widget=forms.Select(attrs={'class': 'span10'}))
    first_name = forms.CharField(
        label=u'名', widget=forms.TextInput(attrs={'class': 'span10'}))
    last_name = forms.CharField(
        label=u'姓', widget=forms.TextInput(attrs={'class': 'span10'}))
    sex = forms.ChoiceField(
        label=u'性别',
        choices=SEX_CHOICES,
        widget=forms.RadioSelect(attrs={'class': 'text-info'}))
    birthday = forms.DateTimeField(label=u'生日',
                                   widget=SelectDateWidget(
                                       years=get_last_70_year_range(),
                                       attrs={'class': 'span10'}))
    country = forms.CharField(
        label=u'国家', widget=forms.Select(attrs={'class': 'input-small'}))
    state = forms.CharField(
        label=u'州省', widget=forms.Select(attrs={'class': 'input-small'}))
    city = forms.CharField(label=u'市县',
                           widget=forms.Select(attrs={'class': 'input-small'}))
    qq = forms.IntegerField(label=u'QQ',
                            widget=forms.TextInput(attrs={'class': 'span10'}))
    weibo = forms.CharField(label=u'微博',
                            widget=forms.TextInput(attrs={'class': 'span10'}))
    phone_number = forms.CharField(
        label=u'手机号码', widget=forms.TextInput(attrs={'class': 'span10'}))

    class Meta:
        model = MyUser
        fields = ('sign', 'job', 'first_name', 'last_name', 'sex', 'birthday',
                  'country', 'state', 'city', 'qq', 'weibo', 'phone_number')
Esempio n. 19
0
class MoreInfo(forms.ModelForm):
    dob = forms.DateField(widget=SelectDateWidget(years=DOY))

    class Meta:
        model = student
        fields = [
            'location',
            'degree',
            'college',
            'year',
            'dob',
        ]
Esempio n. 20
0
class EventForm(forms.ModelForm):

    CHOICES = [('1', 'I'),
               ('2', 'II'),
               ('3', 'III'),
               ('4', 'IV'), ]

    # category = forms.MultipleChoiceField(choices=CHOICES, widget=forms.CheckboxSelectMultiple,)

    start_date = forms.DateField(widget=SelectDateWidget(years=range(2016, 2050)))
    end_date = forms.DateField(widget=SelectDateWidget(years=range(2016, 2050)))

    class Meta:
        model = Event

        fields = ('name', 'description', 'start_date', 'end_date')
        widgets = {'name': forms.TextInput(attrs={'placeholder': 'Event Name', 'class': 'form-control',
                                                  'id': 'event_name'}),
                   'description': forms.Textarea(attrs={'placeholder': 'Description', 'class': 'form-control',
                                                        'id': 'event_desc'}),
                   }
Esempio n. 21
0
class SignUpForm(forms.ModelForm):
    confirm_password = forms.PasswordInput()
    captcha = CaptchaField()
    birthday = forms.DateField(widget=SelectDateWidget(
        years=range(datetime.date.today().year, 1930, -1)))

    class Meta:
        model = myUser
        fields = [
            'username', 'password', 'first_name', 'last_name', 'birthday',
            'email', 'male', 'profile_pic', 'cover_pic'
        ]
Esempio n. 22
0
class AppointmentForm(forms.Form):
    #a_doctor = forms.CharField( label='Doctor', max_length=200, required=False,
    #    widget=forms.TextInput( attrs={'placeholder': 'Doctor Email'}), )
    #a_patient = forms.CharField( label='Patient', max_length=200, required=False,
    #    widget=forms.TextInput( attrs={'placeholder': 'Patient Email'}), )

    a_doctor = forms.ModelChoiceField(
        queryset=Doctor.objects,
        empty_label=None,
        required=False,
        label='Doctor',
        widget=forms.Select(attrs={'class': 'chzn-select'}))
    a_patient = forms.ModelChoiceField(
        queryset=Patient.objects,
        empty_label=None,
        required=False,
        label='Patient',
        widget=forms.Select(attrs={'class': 'chzn-select'}))

    a_title = forms.CharField(
        label='Title',
        max_length=200,
        required=True,
    )

    a_description = forms.CharField(
        label='Description',
        max_length=1000,
        widget=forms.Textarea,
    )

    a_date = forms.DateField(
        label='Date',
        required=True,
        initial=datetime.today,
        widget=SelectDateWidget(attrs={'class': 'smallDrop'}))

    a_starttime = forms.TimeField(
        label='Start Time',
        required=True,
        widget=forms.TextInput(attrs={'placeholder': '2:00 PM'}),
        input_formats=('%I:%M %p', '%H:%M', '%I:%M:%S %p', '%H:%M:%S'),
    )

    a_endtime = forms.TimeField(
        label='End Time',
        required=True,
        widget=forms.TextInput(attrs={'placeholder': '2:30 PM'}),
        input_formats=('%I:%M %p', '%H:%M', '%I:%M:%S %p', '%H:%M:%S'),
    )
Esempio n. 23
0
    def __init__(self, *args, **kwargs):
        super(CandidateUserProfileForm, self).__init__(*args, **kwargs)

        self.fields['birthday'].required = True
        year_max = timezone.now().year - 10
        year_min = year_max - 70
        self.fields['birthday'].widget = SelectDateWidget(
            years=range(year_min, year_max))

        self.fields['cell_phone'].required = True

        self.fields['local_address1'].required = True
        self.fields['local_city'].required = True
        self.fields['local_state'].required = True
        self.fields['local_zip'].required = True
Esempio n. 24
0
class BasicProfileForm(forms.ModelForm):

    CHOICES = [('M', 'Male'), ('F', 'Female')]
    gender = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect)

    dob = forms.DateField(widget=SelectDateWidget(years=range(1980, 2017)))

    class Meta:
        model = UserProfile
        fields = (
            'name',
            'dob',
            'gender',
            'birthplace',
            'contact',
            'alternate_contact',
        )
        widgets = {
            'name':
            forms.TextInput(
                attrs={
                    'placeholder': 'Enter Name',
                    'id': 'form-name',
                    'class': 'form-control'
                }),
            'birthplace':
            forms.TextInput(
                attrs={
                    'placeholder': 'Enter Birth Place',
                    'id': 'form-birthplace',
                    'class': 'form-control'
                }),
            'contact':
            forms.TextInput(
                attrs={
                    'placeholder': 'Enter Contact No.',
                    'id': 'form-contact',
                    'class': 'form-control'
                }),
            'alternate_contact':
            forms.TextInput(
                attrs={
                    'placeholder': 'Enter Alternate Contact No.',
                    'id': 'form-acontact',
                    'class': 'form-control'
                }),
        }
Esempio n. 25
0
class UploadDocumentForm(forms.ModelForm):
    class Meta:
        model = Document
        fields = ('title', 'year', 'published', 'type', 'doc_file')

    # TODO get year from request
    published = forms.DateField(widget=SelectDateWidget(years=[]),
                                label='Dato')

    def __init__(self, **kwargs):
        year = kwargs.pop('year')
        initial = copy.deepcopy(kwargs.pop('initial', {}))
        initial.setdefault('year', year)
        initial.setdefault('published', datetime.date.today())
        kwargs['initial'] = initial
        super(UploadDocumentForm, self).__init__(**kwargs)
        self.fields['published'].widget.years = range(1970, year + 1)
Esempio n. 26
0
class formPerfil(ModelForm):
    fechaNacimiento = forms.DateField(
        required=False,
        label='Fecha de nacimiento',
        widget=SelectDateWidget(years=YearNacimiento))

    class Meta:
        model = Perfil
        fields = ('direccion', 'direccionNumero', 'ciudad', 'provincia',
                  'pais', 'fechaNacimiento')
        labels = {
            'direccion': 'Dirección',
            'direccionNumero': 'Número',
            'ciudad': 'Ciudad',
            'provincia': 'Provincia',
            'pais': 'Pais'
        }
Esempio n. 27
0
    def __init__(self, *args, **kwargs):
        super(UserProfileForm, self).__init__(*args, **kwargs)
        # Set the initial values for the user model fields based on those
        # corresponding values. Note that editing a user profile only makes
        # sense if an instance is provided, as every user will have a user
        # profile.
        self.fields['username'].initial = self.instance.user.username
        self.fields['first_name'].initial = self.instance.user.first_name
        self.fields['last_name'].initial = self.instance.user.last_name
        self.fields['email'].initial = self.instance.user.email
        student_org_user_profile = self.instance.get_student_org_user_profile()
        if student_org_user_profile:
            self.fields['bio'].initial = student_org_user_profile.bio

        # Set initial values for college student info
        college_student_info = self.instance.get_college_student_info()
        if college_student_info:
            self.fields['major'].initial = college_student_info.major.all()
            self.fields['start_term'].initial = \
                college_student_info.start_term
            self.fields['grad_term'].initial = college_student_info.grad_term

        # Disable editing for user account fields (besides email):
        self.fields['username'].widget.attrs['disabled'] = 'disabled'
        self.fields['first_name'].widget.attrs['disabled'] = 'disabled'
        self.fields['last_name'].widget.attrs['disabled'] = 'disabled'

        # TODO(sjdemartini): Add clarifying help_text regarding forwarding email
        # to the "email" field here, as it will affect the forwarding email
        # address once LDAP modification is enabled in the save() method.

        # Change the range of dates shown for the birthday field to only
        # relevant times
        year_max = timezone.now().year - 10
        year_min = year_max - 70
        self.fields['birthday'].widget = SelectDateWidget(
            years=range(year_min, year_max))

        # Make the local address required for someone editing their user
        # profile:
        self.fields['local_address1'].required = True
        self.fields['local_city'].required = True
        self.fields['local_state'].required = True
        self.fields['local_zip'].required = True
Esempio n. 28
0
 class Meta:
     model = Project
     fields = ('name', 'description', 'expiration_date',
               'number_of_users_required', 'opensource', 'url')
     widgets = {
         'name':
         Textarea(attrs={
             'rows': 2,
             'cols': 50
         }),
         'description':
         TinyMCE(mce_attrs={'theme': "advanced"}),
         'expiration_date':
         SelectDateWidget(),
         'number_of_users_required':
         NumberInput(attrs={'style': 'text-align:right'}),
         'url':
         TextInput(attrs={'size': 54}),
     }
Esempio n. 29
0
class PersonForm(forms.Form):
    '''
		表单类
	'''
    CHOICE = (
        ('man', '男'),
        ('woman', '女'),
        ('gay', '基'),
    )
    YEARS = reversed(range(1990, 2000))

    Boolean = forms.BooleanField(required=False)
    Char = forms.CharField(widget=forms.PasswordInput())
    Choice = forms.ChoiceField(choices=CHOICE)
    Date = forms.DateField(widget=SelectDateWidget(years=YEARS, ))
    DateTime = forms.DateTimeField()
    Email = forms.EmailField()
    Float = forms.FloatField()
    Integer = forms.IntegerField()
    IP = forms.GenericIPAddressField()
Esempio n. 30
0
class ActionForm(forms.ModelForm, FormMixin):
    def save(self, commit=True):
        newo = super(ActionForm, self).save(commit=commit)
        if newo.created_dt == None:
            newo.created_dt = datetime.datetime.now()
        newo.modified_dt = datetime.datetime.now()
        return newo

    class Meta:
        model = Action
        exclude = ('parent_pk', 'parent_type', 'user', 'child', 'children',
                   'permission_req', 'created_dt', 'modified_dt',
                   'deadline_dt')

    form_id = forms.CharField(widget=forms.HiddenInput(),
                              initial="pp_event_form")
    summary = forms.CharField(max_length=100,
                              widget=forms.TextInput(attrs={
                                  'size': '50',
                                  'class': 'inputText'
                              }),
                              label="Summary of Action")
    description = forms.CharField(widget=MarkItUpWidget(),
                                  label="Call to Action Instructions")
    location = forms.CharField(label="City/State/Country Location",
                               max_length=100,
                               widget=forms.TextInput(attrs={
                                   'size': '50',
                                   'class': 'inputText'
                               }),
                               required=False)
    date = forms.DateField(widget=SelectDateWidget(),
                           required=False,
                           label="Date")
    time_start = forms.TimeField(widget=SelectTimeWidget(),
                                 required=False,
                                 label="Time Start")
    time_end = forms.TimeField(widget=SelectTimeWidget(),
                               required=False,
                               label="Time End")