Пример #1
0
class EmployeeUpdateForm(forms.ModelForm):
    user = forms.ModelChoiceField(
        queryset=User.objects.all(),
        widget=forms.Select(attrs={'class': 'form-control col-md-12'}))
    id_number = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control col-md-12'}))
    phone_number = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control col-md-12'}))
    tax_number = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control col-md-12'}))
    email = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control col-md-12'}))
    personal_email = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control col-md-12'}))
    github_user = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control col-md-12'}))
    physical_address = forms.CharField(widget=forms.Textarea(
        attrs={
            'cols': 30,
            'rows': 5,
            'class': 'form-control col-md-12'
        }))
    gender = forms.CharField(widget=forms.Select(
        choices=GENDER_OPTIONS, attrs={'class': 'form-control col-md-12'}))
    race = forms.CharField(widget=forms.Select(
        choices=RACE_OPTIONS, attrs={'class': 'form-control col-md-12'}))
    birth_date = forms.DateField(widget=extras.SelectDateWidget(
        years=YEAR_OF_BIRTH, attrs={'class': 'form-control col-md-12'}))
    start_date = forms.DateField(widget=extras.SelectDateWidget(
        years=START_YEAR, attrs={'class': 'form-control col-md-12'}))

    class Meta:
        model = Employee
        fields = '__all__'
Пример #2
0
class ProfileForm(forms.ModelForm):
    birth_day = forms.DateField(
        label=_('Birth day'),
        widget=extras.SelectDateWidget(years=range(2014, 1900, -1)))
    registration = forms.DateField(
        label=_('Registration'),
        widget=extras.SelectDateWidget(years=range(2014, 1900, -1)))

    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop("request")
        super().__init__(*args, **kwargs)
        tags_filed = self.fields['tags']
        self.fields['tags'].widget.attrs["value"] = ",".join(
            [item.name for item in tags_filed.queryset])

    class Meta:
        widgets = {
            'tags': TagSelec2,
            'industries': IndastrySelect2,
        }
        model = get_user_model()
        fields = [
            'birth_day',
            'aboutme',
            'business_summarize',
            'registration',
            'business_name',
            'tags',
            'industries',
        ]

    def save(self, *args, **kwargs):
        return super(ProfileForm, self).save(*args, **kwargs)
Пример #3
0
def razzia_wizard(request):
    if request.method == 'POST':
        return redirect(
            reverse("razzia_view") +
            "?start={0}-{1}-{2}&end={3}-{4}-{5}&products={6}&username=&razzia_title={7}"
            .format(
                int(request.POST['start_year']),
                int(request.POST['start_month']), int(
                    request.POST['start_day']), int(request.POST['end_year']),
                int(request.POST['end_month']), int(request.POST['end_day']),
                request.POST.get('products'), request.POST.get('razzia_title'))
        )

    suggested_start_date = datetime.datetime.now() - datetime.timedelta(
        days=-180)
    suggested_end_date = datetime.datetime.now()

    start_date_picker = fields.DateField(widget=extras.SelectDateWidget(
        years=[x for x in range(2000,
                                datetime.datetime.now().year + 1)]))
    end_date_picker = fields.DateField(widget=extras.SelectDateWidget(
        years=[x for x in range(2000,
                                datetime.datetime.now().year + 1)]))

    return render(
        request,
        'admin/stregsystem/razzia/wizard.html',
        {
            'start_date_picker':
            start_date_picker.widget.render("start", suggested_start_date),
            'end_date_picker':
            end_date_picker.widget.render("end", suggested_end_date)
        },
    )
Пример #4
0
class GapAddForm(forms.Form):
    types = [['1', 'Cykliczna'], ['2', 'Jednoniowa'], ['3', 'Okresowa']]
    type = forms.CharField(widget=forms.Select(choices=types))

    days = [['1', 'Poniedziałek'], ['2', 'Wtorek'], ['3', 'Środa'],
            ['4', 'Czwartek'], ['5', 'Piątek']]
    week_day = forms.CharField(widget=forms.Select(choices=days))

    start_date = forms.DateField(initial=datetime.date.today,
                                 input_formats='%Y-%m-%d',
                                 widget=extras.SelectDateWidget())
    end_date = forms.DateField(initial=datetime.datetime(
        int(datetime.datetime.now().strftime("%Y")) + 9, 12, 31),
                               input_formats='%Y-%m-%d',
                               widget=extras.SelectDateWidget())
Пример #5
0
class SignupForm(forms.Form):
    name = forms.CharField(
        max_length=30,
        label=_('Name'),
        widget=forms.TextInput(attrs={
            'placeholder': _('John Smith'),
            'autofocus': 'autofocus'
        }))
    GENDER_CHOICES = (
        ('M', _('Male')),
        ('F', _('Female')),
        ('O', _('Other')),
    )
    gender = forms.ChoiceField(label=_('Gender'), choices=GENDER_CHOICES)
    birthday = forms.DateField(
        label=_('Birthday'),
        widget=extras.SelectDateWidget(years=range(1910, 2017)))
    place_of_origin = LazyTypedChoiceField(label=_('Country/Region of Origin'),
                                           choices=countries)

    def signup(self, request, user):
        user.name = self.cleaned_data['name']
        user.gender = self.cleaned_data['gender']
        user.birthday = self.cleaned_data['birthday']
        user.place_of_origin = self.cleaned_data['place_of_origin']
        user.save()
Пример #6
0
class UploadForm(forms.Form):
    now = datetime.now()
    years = range(now.year, now.year - 30, -1)
    #print years

    utility_type = forms.ChoiceField(
        choices=UTILITY_TYPES,
        widget=forms.Select(attrs={'data-bind': "value: utility"}))
    alt_type = forms.CharField(max_length=100, required=False)

    file = forms.FileField()
    address = forms.CharField(max_length=100, required=False)
    vendor = forms.CharField(max_length=200, required=False)
    move_in = forms.DateField(widget=extras.SelectDateWidget(years=years),
                              required=False)
    energy_options = forms.MultipleChoiceField(
        widget=forms.CheckboxSelectMultiple(choices=ENERGY_TYPES),
        choices=ENERGY_TYPES,
        required=False)
    alt_energy = forms.CharField(max_length=100, required=False)
    bedrooms = forms.ChoiceField(widget=widgets.RadioSelect(choices=BEDROOMS),
                                 choices=BEDROOMS,
                                 required=False)
    sqft = forms.CharField(max_length=5, required=False)
    email = forms.EmailField(required=False)
Пример #7
0
class OrderDetailsForm(forms.Form):
    """
    Form used to collect all required information when submitting an order.
    """
    name = forms.CharField()
    email = forms.EmailField(required=False)
    birthday = forms.DateField(widget=extras.SelectDateWidget(years=YEARS))
    street = forms.CharField()
    postal_code = forms.CharField()
    city = forms.CharField()

    def clean_birthday(self):
        birthday = self.cleaned_data['birthday']

        # Not a perfect solution given leap years but enough for demo!
        if birthday > datetime.datetime.now().date() - datetime.timedelta(
                days=18 * 365):
            raise forms.ValidationError(
                _('You need to be at least 18 years of age'))
        return birthday

    def clean_postal_code(self):
        postal_code = self.cleaned_data['postal_code']
        if not POSTAL_CODE_REGEX.match(postal_code):
            raise forms.ValidationError(
                _('Postal code can only contain digits'))
        return postal_code
Пример #8
0
class NameForm(forms.Form):

    name = forms.CharField(widget=forms.TextInput(),
                           label='Nome',
                           max_length=200)
    sname = forms.CharField(widget=forms.TextInput(),
                            label='Sobrenome',
                            max_length=200)
    age = forms.DateField(widget=extras.SelectDateWidget(
        years=range(2022, 1930, -1)))
    address = forms.CharField(widget=forms.TextInput(),
                              label='Endereco',
                              max_length=200)
    city = forms.CharField(widget=forms.TextInput(),
                           label='Cidade',
                           max_length=200)
    state1 = forms.CharField(widget=forms.TextInput(),
                             label='Estado',
                             max_length=200)
    country = forms.CharField(widget=forms.TextInput(),
                              label='Pais',
                              max_length=200)
    email = forms.CharField(widget=forms.EmailInput(),
                            label='Email',
                            max_length=200)
    password1 = forms.CharField(widget=forms.PasswordInput(),
                                label='Senha',
                                max_length=200)
    password2 = forms.CharField(widget=forms.PasswordInput(),
                                label='Senha Novamente',
                                max_length=200)

    class Meta:
        model = User
Пример #9
0
class EditForm(forms.Form):
    first_name = forms.CharField()
    last_name = forms.CharField()
    email = forms.EmailField()
    hobbies = forms.CharField()
    favorites_categories = forms.MultipleChoiceField(
        choices=(), widget=forms.CheckboxSelectMultiple, required=False)
    birthdate = forms.DateField(widget=extras.SelectDateWidget(
        years=range(1920,
                    datetime.date.today().year)))
    avatar = forms.FileField(required=False)

    def clean_avatar(self):
        im_file = self.cleaned_data['avatar']
        try:
            im = Image.open(im_file)
        except IOError:
            raise forms.ValidationError("Upload a valid image please")
        except AttributeError:
            return None
        return im_file

    def clean_hobbies(self):
        return self.cleaned_data['hobbies'].lower()

    def clean_favorites_categories(self):
        name_categories = self.cleaned_data['favorites_categories']
        return ','.join(name_categories)

    def __init__(self, *args, **kwargs):
        super(EditForm, self).__init__(*args, **kwargs)
        self.fields['favorites_categories'].choices = [
            (choice.category_name, choice)
            for choice in Category.objects.all()
        ]
Пример #10
0
class form_add_show(forms.Form):
    now = datetime.datetime.now()
    name = forms.CharField(required=True, max_length=30)
    organizer = forms.CharField(required=False, max_length=30)
    date = forms.DateField(required=True,
                           widget=extras.SelectDateWidget(
                               years=range(now.year + 2, now.year - 2, -1)))
    class Meta:
        model = UploadAdvetisement
        fields = (
            'time_of_advertisement',
            'no_of_slots',
            'select_bundles',
            'no_of_weeks',
            'start_week',
            'no_of_repeats',
            'bussinessPoint_latitude',
            'bussinessPoint_longitude',
        )
        widgets = {
            'start_week':
            extras.SelectDateWidget(),

            #'upload_Advertisement': forms.FileInput(attrs={'class':'btn btn-default'}),
            'time_of_advertisement':
            forms.NumberInput(attrs={'class': 'form-control'}),
            'no_of_weeks':
            forms.NumberInput(attrs={'class': 'form-control'}),
            'no_of_slots':
            forms.NumberInput(attrs={'class': 'form-control'}),
            'no_of_repeats':
            forms.NumberInput(attrs={'class': 'form-control'}),
            'select_bundles':
            forms.NumberInput(attrs={'class': 'form-control'}),
            'bussinessPoint_latitude':
            forms.HiddenInput,
            'bussinessPoint_longitude':
            forms.HiddenInput,
        }
Пример #12
0
class SignUpForm(UserCreationForm):
    MY_CHOICES = (
        ('None', 'Nessuno'),
        ('PT1', 'Pistoia 1'),
        ('PT2', 'Pistoia 2'),
        ('PT3', 'Pistoia 3'),
        ('PT4', 'Pistoia 4'),
        ('SG1', 'San Giorgio 1'),
        ('QU1', 'Quarrata 1'),
        ('MC1', 'Massa e Cozzile 1'),
        ('CU1', 'Chiesina Uzzanese 1'),
        ('UZ 1', 'Uzzano 1'),
    )
    now = datetime.datetime.now()
    current_year = now.year
    email = forms.EmailField(
        max_length=254, help_text='Required. Inform a valid email address.')
    gruppo = forms.ChoiceField(choices=MY_CHOICES)
    birth_date = forms.DateField(widget=extras.SelectDateWidget(
        years=range(current_year - 90, current_year - 7)))

    class Meta:
        model = User
        fields = (
            'username',
            'gruppo',
            'first_name',
            'last_name',
            'birth_date',
            'email',
            'password1',
            'password2',
        )
Пример #13
0
class BasicForm(forms.ModelForm):
    birthdate = forms.DateField(widget=extras.SelectDateWidget(
        required=False, years=range(2014, 1930, -1)))

    class Meta:
        model = Basic
        exclude = ('user', 'timestamp')
Пример #14
0
class ProfileForm(forms.ModelForm):
    sex = forms.ChoiceField(
        widget=forms.Select,
        choices=SEX_CHOICES,
        required=False)
    location = forms.ChoiceField(
        widget=forms.Select,
        choices=LOCATION_CHOICES,
        required=False,
    )
    birthdate = forms.DateField(
        widget=extras.SelectDateWidget(years=range(2017, 1949, -1)),
        required=False
    )
    interests = forms.CharField(
        widget=forms.TextInput(attrs={'style': 'width:60%;min-width:320px'}),
        max_length=255,
        help_text='Use spaces to separate the tags, such as "these are tag1 tag2"',
        required=False,
    )

    # location = forms.CharField(
    #     widget=forms.TextInput(attrs={'class': 'form-control'}),
    #     max_length=50,
    #     required=False)

    class Meta:
        model = User
        fields = ['sex', 'location', 'birthdate', 'interests']
Пример #15
0
class SingUpForm(forms.ModelForm):
    email = forms.EmailField(
        label='E-Mail',
        max_length=128,
        widget=forms.TextInput(attrs={'placeholder': '*****@*****.**'}))
    password = forms.CharField(
        label='Password',
        max_length=128,
        widget=forms.PasswordInput(attrs={'placeholder': 'password'}))
    username = forms.CharField(
        label='Username',
        max_length=128,
        widget=forms.TextInput(attrs={'placeholder': 'Username'}))
    first_name = forms.CharField(
        label='First Name',
        max_length=128,
        widget=forms.TextInput(attrs={'placeholder': 'First Name'}))
    last_name = forms.CharField(
        label='Last Name',
        max_length=128,
        widget=forms.TextInput(attrs={'placeholder': 'Last Name'}))
    birthday = forms.DateField(widget=extras.SelectDateWidget(
        years=range(datetime.now().year - 100,
                    datetime.now().year)))
    city = forms.CharField(
        label='City',
        max_length=128,
        widget=forms.TextInput(attrs={'placeholder': 'City'}))

    class Meta:
        model = User
        fields = ('email', 'username', 'password', 'first_name', 'last_name',
                  'birthday', 'country', 'city')
Пример #16
0
class UpdatePlayer(forms.Form):
    birthday = forms.DateField(widget=extras.SelectDateWidget(years=DOY))
    place = forms.ChoiceField(widget=forms.Select(),
                              label="Where do you live",
                              initial="",
                              choices=PLACE_CHOICES)
    game = forms.ModelChoiceField(queryset=Game.objects.all())
Пример #17
0
class RegistrationForm(forms.Form):
    email_ver = forms.EmailField(required=False)
    first_name = forms.CharField(max_length=50, required=True)
    last_name = forms.CharField(max_length=50, required=True)
    email = forms.EmailField(required=True)
    password = forms.CharField(widget=forms.PasswordInput(), required=True)
    b_day = forms.DateField(
        widget=extras.SelectDateWidget(years=range(1939,
                                                   datetime.now().year)),
        required=True)
    gender = forms.CharField(
        widget=forms.RadioSelect(choices=SocialUser.GENDER_CHOICES),
        required=True)

    def clean_email(self, *args, **kwargs):
        email = self.cleaned_data.get('email')
        email2 = self.cleaned_data.get('email_ver')
        print email
        print email2
        if email != email2:
            raise forms.ValidationError("Emails must match")
        email_qs = User.objects.filter(email=email).first()
        if email_qs:
            raise forms.ValidationError(
                "This email has already been registered")
        return email
Пример #18
0
 class Meta:
     model = Transaction
     fields = ['date', 'from_account', 'amount', 'memo']
     widgets = {
         'date':
         extras.SelectDateWidget(years=['2013', '2014', '2015', '2016']),
     }
Пример #19
0
class UserRegistrationForm(forms.Form):
    name = forms.CharField(max_length=30, help_text='Full Name')
    username = forms.CharField(max_length=30)
    email = forms.EmailField()
    password = forms.CharField(max_length=30, widget=forms.PasswordInput())
    dob = forms.DateField(
        widget=extras.SelectDateWidget(years=range(1990,
                                                   datetime.now().year + 1)),
        help_text='Date of Birth')
    CSE = 'CSE'
    ECE = 'ECE'
    EEE = 'EEE'
    ME = 'ME'
    CE = 'CE'
    branchs = (
        (CSE, 'Computer Science and Engineering'),
        (ECE, 'Electronic and Communincation'),
        (EEE, 'Electrical and Electronic Engineering'),
        (ME, 'Mechanical Engineering'),
        (CE, 'Civil Engineering'),
    )
    department = forms.ChoiceField(choices=branchs, initial=CSE)
    student = 'st'
    faculty = 'fac'
    positions = (
        (student, 'Student'),
        (faculty, 'Faculty'),
    )
    position = forms.ChoiceField(choices=positions, initial=student)

    def clean_username(self):
        u_name = self.cleaned_data['username']
        if u_name.strip(VALID_USERNAME_CHARS):
            msg = "Only letters, digits, period and underscore characters are allowed in username"
            raise forms.ValidationError(msg)
        try:
            User.objects.get(username__exact=u_name)
            raise forms.ValidationError("Username already exists")
        except User.DoesNotExist:
            return u_name

    def clean_password(self):
        pwd = self.cleaned_data['password']
        if pwd.strip(VALID_PASSWORD_CHARS):
            raise forms.ValidationError(
                "Only letters, digits and punctuation are allowed in password")
        return pwd

    def save(self):
        u_name = self.cleaned_data['username']
        u_name = u_name.lower()
        pwd = self.cleaned_data['password']
        email = self.cleaned_data['email']
        new_user = User.objects.create_user(u_name, email, pwd)
        new_user.name = self.cleaned_data['name']
        new_user.dob = self.cleaned_data['dob']
        new_user.department = self.cleaned_data['department']
        new_user.position = self.cleaned_data['position']
        new_user.save()
Пример #20
0
class BuyForm(forms.ModelForm):
    class Meta:
        model = Stock
        fields = ['stock', 'date', 'shares']

    # stock = forms.CharField(max_length=5)
    date = forms.DateTimeField(
        widget=extras.SelectDateWidget(empty_label="Nothing", years=DOY))
Пример #21
0
    class Meta:

        model = Work
        fields = ('intern', 'date', 'time_in', 'time_out', 'summary')

        widgets = {
            'date': extras.SelectDateWidget(empty_label="Nothing"),
        }
Пример #22
0
    class Meta:

        model = Work
        fields = ('intern', 'date', 'time_in', 'time_out', 'summary')

        widgets = {
            'date': extras.SelectDateWidget(empty_label="Nothing"),
            'intern': autocomplete.ModelSelect2(url='intern-autocomplete')
        }
Пример #23
0
 class Meta:
     model = models.UserProfile
     fields = '__all__'
     exclude = ['user']
     widgets = {
         'birthdate':
         extras.SelectDateWidget(
             years=utils.FormUtils.get_birthday_years()),
     }
Пример #24
0
class ProfileForm(forms.ModelForm):
    dob = forms.DateField(widget=extras.SelectDateWidget(
        years=range(1940,
                    datetime.date.today().year + 10)))

    class Meta:
        model = Profile
        fields = ('first_name', 'last_name', 'description', 'profile_picture',
                  'dob', 'gender', 'country', 'city')
Пример #25
0
 class Meta:
     model = UserProfile
     fields = ('first_name', 'last_name',
               'birth_date', 'gender')
     widgets = {
         'gender': widgets.Select(choices=GENDER_CHOICES),
         'birth_date': extras.SelectDateWidget(
             years=range(1930, datetime.date.today().year))
     }
Пример #26
0
 def __init__(self, *args, **kwargs):
     super(PatientMedicalInfoForm, self).__init__(*args, **kwargs)
     self.fields['eye_color'] = forms.ChoiceField(
         choices=self.EYE_COLOR_CHOICES)
     self.fields['race'] = forms.ChoiceField(choices=self.RACE_CHOICES)
     self.fields['sex'] = forms.ChoiceField(choices=self.SEX_CHOICES)
     self.fields['birthday'] = forms.DateField(
         widget=extras.SelectDateWidget(
             years=range(datetime.datetime.now().year - 150,
                         datetime.datetime.now().year)))
Пример #27
0
 class Meta:
     model = Place
     fields = ['name', 'visited', 'date_visited', 'notes']
     widgets = {
         'visited':
         forms.HiddenInput(),
         'date_visited':
         extras.SelectDateWidget(years=range(2000,
                                             timezone.now().year + 1))
     }
Пример #28
0
class EditCohortForm(ModelForm):
    start_date = forms.DateField(widget=extras.SelectDateWidget(
        empty_label="Nothing", attrs={'class': 'ui fluid dropdown'}))
    stack = forms.ChoiceField(
        widget=forms.Select(attrs={'class': 'ui fluid dropdown'}),
        choices=stack_choices)

    class Meta:
        model = Cohort
        fields = ['stack', 'start_date']
Пример #29
0
class AboutForm(forms.ModelForm):
    birth_date = forms.DateField(widget=extras.SelectDateWidget(
        years=range(this_year - date_range, this_year)))

    class Meta:
        model = About
        fields = [
            'name', 'birth_date', 'position', 'dept', 'image', 'email',
            'telephone', 'roomnumber', 'authentication_key'
        ]
Пример #30
0
class SignUpForm(UserCreationForm):
    first_name = forms.CharField(max_length=25, required=True)
    last_name = forms.CharField(max_length=25, required=True)
    dob = forms.DateField(
        widget=extras.SelectDateWidget(years=range(1901, 2003)), required=True)

    class Meta:
        model = User
        fields = ('username', 'first_name', 'last_name', 'dob', 'password1',
                  'password2')