Exemplo n.º 1
0
class LandForm(forms.Form):
    district = forms.ModelChoiceField(
        queryset=District.objects.all(),
        widget=forms.Select(attrs={"onChange": "getDistrict(this.value)"}))
    taluk = forms.ModelChoiceField(
        queryset=Taluk.objects.all(),
        widget=forms.Select(attrs={"onChange": "getTaluk(this.value)"}))
    gram_panchayat = forms.ModelChoiceField(
        queryset=GramPanchayat.objects.all())
    land_number = forms.CharField()
Exemplo n.º 2
0
    class Meta:
        model = Job
        fields = [
            'title', 'description', 'category', 'pay', 'number_of_positions',
            'address'
        ]

        #styling through bootstrap class in form-control
        widgets = {
            'title':
            forms.TextInput(attrs={'class': 'form-control'}),
            'description':
            forms.Textarea(
                attrs={
                    'class': 'form-control',
                    'placeholder': "Describe the job in 3-5 sentences."
                }),
            'category':
            forms.Select(attrs={'class': 'form-control'}),
            'pay':
            forms.TextInput(attrs={'class': 'form-control'}),
            'number_of_positions':
            forms.NumberInput(attrs={'class': 'form-control'}),
            'address':
            forms.TextInput(attrs={'class': 'form-control'}),
        }
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     user = kwargs.pop('user', None) #get the user passed to the form off of the keyword argument
     super(GroceryUserList, self).__init__(*args, **kwargs)
     lists = GroceryList.objects.filter(author=user)
     choices=[ (o.id, str(o)) for o in lists]
     choices.append((0,'new'))
     choices.sort()
     self.fields['lists'] = forms.ChoiceField( widget = forms.Select(), choices=choices, initial=0)
Exemplo n.º 4
0
class TenxGSCSubmissionForm(forms.Form):
    name = forms.CharField(max_length=50, widget=forms.TextInput())
    email = forms.EmailField(max_length=50, widget=forms.EmailInput())
    date = forms.DateField(widget=forms.SelectDateWidget(), initial=datetime.date.today())
    tenxpools = forms.ChoiceField(
        widget=forms.Select(),
        choices=[(pool.id, pool.pool_name) for pool in TenxPool.objects.all().order_by('id')],
        label="TenX Pool",
    )
class scoress(forms.Form):
    scores = forms.ChoiceField(
        error_messages=my_default_errors,
        label='',
        widget=forms.Select(
            attrs={
                'class': "form-control register-inputs",
                'style': "text-align-last:center;"
            }),
        choices=scores_types,
        required=False,
    )
class New_Project_form_job_types_form(forms.Form):
    job_type = forms.ChoiceField(
        error_messages=my_default_errors,
        label='',
        widget=forms.Select(
            attrs={
                'class': "form-control register-inputs",
                'style': "text-align-last:right; width: 150px"
            }),
        choices=job_types,
        required=True,
    )
Exemplo n.º 7
0
    class Meta:
        model = Eklogestbl
        fields = '__all__'

        VISIBLE_CHOICES = (
            ('1', 'ΝΑΙ'),
            ('0', 'ΟΧΙ'),
        )

        DEFAULT_CHOICES = (
            ('1', 'ΝΑΙ'),
            ('0', 'ΟΧΙ'),
        )

        labels = {
            'descr': _('Περιγραφή'),
            'dateofelection': _('Ημερ. διεξαγωγής'),
            'dimos': _('Δήμος'),
            'sisid': _('Νομοθετικό πλαίσιο'),
            'edrid': _('Σύστημα κατανομής εδρών'),
            'visible': _('Ορατή'),
            'defaultelection': _('Προεπιλεγμένη'),
        }
        help_texts = {
            'dateofelection':
            _('η ημερομηνία στη μορφή yyyy-mm-dd παρακαλώ, π.χ. 2019-05-17'),
            'visible':
            _('Επιλέξτε ΝΑΙ αν πρέπει να είναι ορατή στην εφαρμογή, αλλιώς επιλέξτε ΟΧΙ'
              ),
        }
        widgets = {
            'visible':
            forms.Select(choices=VISIBLE_CHOICES,
                         attrs={'class': 'form-control'}),
            'defaultelection':
            forms.Select(choices=DEFAULT_CHOICES,
                         attrs={'class': 'form-control'}),
        }
Exemplo n.º 8
0
class BlacklistForm(forms.Form):
    email = forms.CharField(label='Email',
                            required=True,
                            widget=forms.TextInput(
                                attrs={
                                    'type': 'email',
                                    'class': 'form-control',
                                    'placeholder': '*****@*****.**'
                                }))
    country = forms.ChoiceField(
        label='País',
        choices=COUNTRIES,
        required=True,
        widget=forms.Select(attrs={'class': 'form-control'}))
Exemplo n.º 9
0
    class Meta:
        model = Sindiasmoi
        fields = [
            'descr', 'shortdescr', 'eidos', 'koinid', 'proedros', 'photofield',
            'aa'
        ]

        EIDOS_CHOICES = (
            (1, 'Δήμο'),
            (0, 'Κοινότητα'),
        )
        labels = {
            'descr':
            _('Περιγραφή'),
            'shortdescr':
            _('Σύντομος τίτλος'),
            'eidos':
            _('Υποψήφιος συνδυασμός για όλο το Δήμο ή σε Τοπική Κοινότητα μόνο?'
              ),
            'koinid':
            _('Κοινότητα'),
            'proedros':
            _('Πρόεδρος'),
            'photofield':
            _('Φωτογραφία'),
        }
        help_texts = {
            'shortdescr': _('Π.χ, το επίθετο του επικεφαλής μόνο'),
            'koin': _('Κοινότητα στην οποία συμμέτεχει'),
            'aa': _('Με ποιο ΑΑ συμμετέχει o συνδυασμός στις εκλογές'),
        }
        widgets = {
            'eidos':
            forms.Select(choices=EIDOS_CHOICES,
                         attrs={'class': 'form-control'}),
        }
Exemplo n.º 10
0
class SimbouloiForm(ModelForm):

    EIDOS_CHOICES = (
        (1, 'Δήμο'),
        (0, 'Κοινότητα'),
    )

    hiddenid = IntegerField(label='ID Συμβούλου', required=False)

    eidos = forms.ChoiceField(choices=EIDOS_CHOICES,
                              label="Σε Δήμο ή Κοινότητα ?",
                              widget=forms.Select(),
                              required=True)
    perid = ModelChoiceField(queryset=Perifereies.objects.none(),
                             label='Εκλ. Περιφέρεια')
    koinid = ModelChoiceField(queryset=Koinotites.objects.none(),
                              label='Κοινότητα',
                              required=False)

    sindid = ModelChoiceField(queryset=Sindiasmoi.objects.none(),
                              label='Συνδυασμός',
                              required=False)
    aa = CharField(label='ΑΑ Συμβούλου', max_length=45)

    class Meta:
        model = Simbouloi
        fields = [
            'hiddenid', 'surname', 'firstname', 'fathername', 'eidos', 'perid',
            'koinid', 'sindid', 'aa', 'comments'
        ]

        labels = {
            'surname': _('Επίθετο'),
            'firstname': _('Όνομα'),
            'fathername': _('Όν. Πατρός'),
            'comments': _('Παρατηρήσεις'),
            'perid': _('Εκλ. Περιφέρεια'),
            'koinid': _('Κοινότητα'),
            'sindid': _('Συνδυασμός'),
            'aa': _('ΑΑ'),
        }
        help_texts = {
            'aa': _('Με ποιο ΑΑ συμμετέχει o υποψήφιος στις εκλογές'),
        }

    def __init__(self, eklid, *args, **kwargs):
        super(SimbouloiForm, self).__init__(*args, **kwargs)

        # SOS!!! κάνω override την μέθοδο Init και αρχικοποίηση των dropdown perid, sindid, koinid
        # Παίρνω μόνο perid, sindid, koinid που έχουν καταχωρηθεί στην τρέχουσα εκλ. αναμέτρηση μόνο
        self.fields['perid'].queryset = Perifereies.objects.filter(
            perid__in=Eklper.objects.filter(eklid=eklid).values_list('perid'))

        self.fields['koinid'].queryset = Koinotites.objects.filter(
            koinid__in=Eklperkoin.objects.filter(
                eklid=eklid).values_list('koinid'))

        self.fields['perid'].widget.attrs['id'] = 'perid_of_simbouloi'

        q = Q(sindid__in=Eklsind.objects.filter(
            eklid=eklid).values_list('sindid')) | Q(
                sindid__in=Eklsindkoin.objects.filter(
                    eklid=eklid).values_list('sindid'))

        self.fields['sindid'].queryset = Sindiasmoi.objects.filter(q)

        self.fields['hiddenid'].widget = forms.HiddenInput()

    def clean(self):
        cleaned_data = super(SimbouloiForm, self).clean()
        surname = cleaned_data.get('surname')
        firstname = cleaned_data.get('firstname')
        fathername = cleaned_data.get('fathername')
        eidos = cleaned_data['eidos']
        comments = cleaned_data.get('comments')
        aa = cleaned_data.get('aa')
        sindid = cleaned_data.get('sindid')
        perid = cleaned_data.get('perid')
        koinid = cleaned_data.get('koinid')
        hiddenid = cleaned_data.get('hiddenid')

        #Έλεγχος αν ξέχασε να βάλει ο χρήστης Κοινότητα, αν πρόκειται για σύμβουλο Κοινότητας
        if eidos == '0' and koinid == None:
            raise forms.ValidationError(
                "Το πεδίο Κοινότητα πρέπει να συμπληρωθεί αφού πρόκειται για υποψήφιο Κοινότητας!"
            )
        if eidos == '1' and sindid == None:
            raise forms.ValidationError(
                "Το πεδίο Συνδυασμός πρέπει να συμπληρωθεί αφού πρόκειται για υποψήφιο Δημοτικό Σύμβουλο!"
            )
Exemplo n.º 11
0
class RegistrationForm(forms.Form):
    email = forms.EmailField(
        max_length=70,
        error_messages=my_default_errors,
        required=True,
        label='',
        widget=forms.TextInput(
            attrs={
                'placeholder': 'پست الکترونیک',
                'style': "margin-top: 0px; direction: ltr;",
                'class': "form-control register-inputs",
                'type': 'email'
            }))
    password = Password(
        max_length=50,
        error_messages=my_default_errors,
        label='',
        widget=forms.PasswordInput(
            attrs={
                'placeholder': '(رمز عبور (حداقل ۶ کاراکتر',
                'style': "direction: ltr;",
                'class': "form-control register-inputs",
                'type': 'password'
            }),
        required=True,
    )
    confirm_password = Password(
        max_length=50,
        error_messages=my_default_errors,
        label='',
        widget=forms.PasswordInput(
            attrs={
                'placeholder': ' تکرار رمز عبور',
                'style': "direction: ltr;",
                'class': "form-control register-inputs",
                'type': 'password'
            }),
        required=True)
    first_name = forms.CharField(
        max_length=100,
        error_messages=my_default_errors,
        label='',
        required=True,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'نام (فارسی)',
                'style': "direction: rtl;",
                'class': "form-control register-inputs"
            }))
    last_name = forms.CharField(max_length=100,
                                error_messages=my_default_errors,
                                label='',
                                required=True,
                                widget=forms.TextInput(
                                    attrs={
                                        'placeholder': 'نام خانوادگی (فارسی)',
                                        'style': "direction: rtl;",
                                        'class': "form-control register-inputs"
                                    }))
    mobile_number = Mobile_Number(
        max_length=100,
        error_messages=my_default_errors,
        label='',
        required=True,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'تلفن همراه (۱۱ رقم وارد کنید.)',
                'style': "direction: lrt;",
                'class': "form-control register-inputs"
            }))
    last_educational_level = forms.ChoiceField(
        error_messages=my_default_errors,
        label='',
        widget=forms.Select(
            attrs={
                'class': "form-control register-inputs",
                'style': "text-align-last:center;"
            }),
        choices=educational_level_types,
        required=True,
    )
    last_educational_University = forms.CharField(
        error_messages=my_default_errors,
        max_length=500,
        label='',
        widget=forms.TextInput(
            attrs={
                'placeholder': 'آخرین دانشگاه محل تحصیل (فارسی)',
                'style': "direction: rtl;",
                'class': "form-control register-inputs"
            }))
    day = forms.CharField(
        required=False,
        max_length=2,
        label='تاریخ تولد:',
        error_messages='',
        widget=forms.TextInput(
            attrs={
                'placeholder': ' روز',
                'style':
                "direction: ltr; width:60px; text-align-last:center; display:inline;",
                'class': "form-control register-inputs"
            }))
    month = forms.CharField(
        required=False,
        max_length=2,
        label='',
        error_messages='',
        widget=forms.TextInput(
            attrs={
                'placeholder': ' ماه',
                'style':
                "direction: ltr; width:60px; text-align-last:center; display:inline;",
                'class': "form-control register-inputs"
            }))
    year = forms.CharField(
        required=False,
        max_length=4,
        label='',
        error_messages='',
        widget=forms.TextInput(
            attrs={
                'placeholder': ' (سال(چهار رقم',
                'style':
                "direction: ltr; width:60px; text-align-last:center; display:inline;",
                'class': "form-control register-inputs"
            }))
    city = forms.ChoiceField(
        label='',
        widget=forms.Select(
            attrs={
                'class': "form-control register-inputs",
                'style': "text-align-last:center;"
            }),
        choices=city_types,
        required=True,
    )
    captcha = CaptchaField(label='',
                           required=True,
                           error_messages=captcha_errors)
    sending_daily_email = forms.BooleanField(
        required=False,
        label='',
        widget=forms.CheckboxInput(
            attrs={
                'class':
                "form-control register-inputs",
                'style':
                " position: relative;right: 26px !important; top: 14px !important;"
            }))

    def clean(self):
        cleaned_data = super(RegistrationForm, self).clean()
        pw1 = cleaned_data.get("password")
        pw2 = cleaned_data.get("confirm_password")
        new_email = cleaned_data.get('email')
        previous_user = User.objects.filter(username=new_email)
        city = cleaned_data.get('city')
        year = cleaned_data.get('year')
        month = cleaned_data.get('month')
        day = cleaned_data.get('day')

        if previous_user.__len__() != 0:
            print(type(previous_user))
            raise ValidationError(
                "* کاربر با ایمیل داده شده در سامانه موجود است.",
                code="password_confirmation_error")
        if pw1 != pw2:
            raise ValidationError("* رمز عبور و تکرار آن یکسان نمی‌باشد.",
                                  code="password_confirmation_error")
        if (str(year).__len__() != 4 or year == '' or int(year) < 1310):
            raise ValidationError(
                "* لطفا سال را چهار رقمی  و معتبر وارد کنید.",
                code="password_confirmation_error")
        if str(month).__len__() > 2 or int(month) > 12 or int(month) < 1:
            raise ValidationError(
                "* لطفا ماه را حداکثر دو رقمی  و کمتر از ۱۲ وارد کنید.",
                code="password_confirmation_error")
        if str(day).__len__() > 2 or int(day) > 31 or int(day) < 1:
            raise ValidationError(
                "* لطفا روز را حداکثر دو رقمی  و کمتر از ۳۲ وارد کنید.",
                code="password_confirmation_error")
        return cleaned_data
Exemplo n.º 12
0
class Edit_registrtaion(forms.Form):
    first_name = forms.CharField(
        max_length=100,
        error_messages=my_default_errors,
        label='',
        required=False,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'نام (فارسی)',
                'style': "direction: rtl;",
                'class': "form-control register-inputs"
            }))
    last_name = forms.CharField(max_length=100,
                                error_messages=my_default_errors,
                                label='',
                                required=False,
                                widget=forms.TextInput(
                                    attrs={
                                        'placeholder': 'نام خانوادگی (فارسی)',
                                        'style': "direction: rtl;",
                                        'class': "form-control register-inputs"
                                    }))
    mobile_number = Mobile_Number(
        max_length=100,
        error_messages=my_default_errors,
        label='',
        required=False,
        widget=forms.TextInput(
            attrs={
                'placeholder': 'تلفن همراه ،۱۱ رقم وارد کنید.',
                'style': "direction: ltr;",
                'class': "form-control register-inputs"
            }))
    last_educational_level = forms.ChoiceField(
        error_messages=my_default_errors,
        label='',
        widget=forms.Select(
            attrs={
                'class': "form-control register-inputs",
                'style': "text-align-last:center;"
            }),
        choices=educational_level_types,
        required=False,
    )
    last_educational_University = forms.CharField(
        error_messages=my_default_errors,
        max_length=500,
        label='',
        widget=forms.TextInput(
            attrs={
                'placeholder': 'آخرین دانشگاه محل تحصیل (فارسی)',
                'style': "direction: rtl;",
                'class': "form-control register-inputs"
            }),
        required=False)
    day = forms.CharField(
        required=False,
        max_length=2,
        label='تاریخ تولد:',
        error_messages='',
        widget=forms.TextInput(
            attrs={
                'placeholder': ' روز',
                'style':
                "direction: ltr; width:60px; text-align-last:center; display:inline;",
                'class': "form-control register-inputs"
            }))
    month = forms.CharField(
        required=False,
        max_length=2,
        label='',
        error_messages='',
        widget=forms.TextInput(
            attrs={
                'placeholder': ' ماه',
                'style':
                "direction: ltr; width:60px; text-align-last:center; display:inline;",
                'class': "form-control register-inputs"
            }))
    year = forms.CharField(
        required=False,
        max_length=4,
        label='',
        error_messages='',
        widget=forms.TextInput(
            attrs={
                'placeholder': ' (سال(دو رقم',
                'style':
                "direction: ltr; width:60px; text-align-last:center; display:inline;",
                'class': "form-control register-inputs"
            }))
    city = forms.ChoiceField(
        label='',
        widget=forms.Select(
            attrs={
                'class': "form-control register-inputs",
                'style': "text-align-last:center;"
            }),
        choices=city_types,
        required=False,
    )
    # image = forms.ImageField(required=False, label='محل قرار دادن فایل')
    sending_daily_email = forms.BooleanField(
        required=False,
        label='',
        widget=forms.CheckboxInput(
            attrs={
                'class':
                "",
                'style':
                " position: relative; right: 50px !important; top: 9px !important;"
            }))

    def clean(self):
        cleaned_data = super(Edit_registrtaion, self).clean()
        pw1 = cleaned_data.get("password")
        pw2 = cleaned_data.get("confirm_password")
        new_email = cleaned_data.get('email')
        year = cleaned_data.get('year')
        month = cleaned_data.get('month')
        day = cleaned_data.get('day')

        if pw1 != pw2:
            raise ValidationError("* رمز عبور و تکرار آن یکسان نمی‌باشد.",
                                  code="password_confirmation_error")
        if (str(year).__len__() != 4 or year == '' or int(year) < 1310):
            raise ValidationError("* لطفا سال را چهار رقمی و معتبر وارد کنید.",
                                  code="password_confirmation_error")
        if (month != '' and
            (str(month).__len__() > 2 or int(month) > 12 or int(month) < 1)):
            raise ValidationError(
                "* لطفا ماه را حداکثر دو رقمی  و کمتر از ۱۲ وارد کنید.",
                code="password_confirmation_error")
        if (day != ''
                and (str(day).__len__() > 2 or int(day) > 31 or int(day) < 1)):
            raise ValidationError(
                "* لطفا روز را حداکثر دو رقمی  و کمتر از ۳۲ وارد کنید.",
                code="password_confirmation_error")
        return cleaned_data