Ejemplo n.º 1
0
class SearchForm(forms.Form):
    empty_choices = [('', '')]
    empty_choices.extend(list(UserProfile.school_choices))
    schools = tuple(empty_choices)
    restrict_school = forms.ChoiceField(required=False,
                                        label="School",
                                        choices=schools)
    empty_choices = [('', '')]
    empty_choices.extend(list(UserProfile.year_choices))
    years = tuple(empty_choices)
    restrict_year = forms.ChoiceField(required=False,
                                      label="Year",
                                      choices=years)
    empty_choices = [('', '')]
    empty_choices.extend(list(UserProfile.major_choices))
    majors = tuple(empty_choices)
    restrict_major = forms.ChoiceField(required=False,
                                       label="Major",
                                       choices=majors)
    class_subject = forms.CharField(
        required=False,
        label="Course Designation",
        widget=forms.TextInput(attrs={'style': 'width:160px'}))
    class_number = forms.CharField(required=False, label="Course Number")
    class_name = forms.CharField(required=False, label="Course Title")
Ejemplo n.º 2
0
 def __init__(self, *args, **kwargs):
     user = kwargs.pop('user', '')
     super(UpdateEventForm1, self).__init__(*args, **kwargs)
     self.fields['branch'] = forms.ChoiceField(choices=[('CSE', 'CSE'), ('IT', 'IT'), ('ECE', 'ECE'), ('EEE', 'EEE')])
     self.fields['section'] = forms.ChoiceField(choices=[('A', 'A'), ('B', 'B'), ('both', 'both')])
     self.fields['date'] = forms.DateField()
     self.fields['venue'] = forms.ModelMultipleChoiceField(queryset=Resources.objects.all(),widget=forms.SelectMultiple)
     self.fields['starttime'] = forms.TimeField()
     self.fields['endtime'] = forms.TimeField()
Ejemplo n.º 3
0
class FileLicenseForm(ModelForm):
    class Meta:
        fields = "__all__"
        model = FileLicense

    license = forms.ChoiceField()
    file = forms.ChoiceField()

    def __init__(self, *args, **kwargs):
        super(FileLicenseForm, self).__init__(*args, **kwargs)
        self.fields['license'].choices = license_choices()
        self.fields['file'].choices = file_choices()
Ejemplo n.º 4
0
class LibLicenseForm(ModelForm):
    class Meta:
        fields = "__all__"
        model = LibLicense

    license = forms.ChoiceField()
    library = forms.ChoiceField()

    def __init__(self, *args, **kwargs):
        super(LibLicenseForm, self).__init__(*args, **kwargs)
        self.fields['license'].choices = license_choices()
        self.fields['library'].choices = library_choices()
Ejemplo n.º 5
0
class PolicyForm(ModelForm):
    class Meta:
        fields = "__all__"
        model = Policy

    tlicense = forms.ChoiceField()
    dlicense = forms.ChoiceField()

    def __init__(self, *args, **kwargs):
        super(PolicyForm, self).__init__(*args, **kwargs)
        self.fields['tlicense'].choices = license_choices()
        self.fields['dlicense'].choices = license_choices()
Ejemplo n.º 6
0
class EventRegistrationForm(forms.Form):
    eventname=forms.CharField(max_length=30,label="eventname",required=True,error_messages={'invalid':'Event Name should be unique'})
    description=forms.CharField(max_length=500, label="description", required=True)
    year=forms.ChoiceField(choices=[('1','1'),('2','2'),('3','3'),('4','4')])
    resourceperson=forms.CharField(max_length=30,required = True)

    res_person_workplace=forms.CharField(max_length=100,required=True)
    branch=forms.ChoiceField(choices=[('CSE','CSE'),('IT','IT'),('ECE','ECE'),('EEE','EEE')])
    section=forms.ChoiceField(choices=[('A','A'),('B','B'),('both','both')])
    date=forms.DateField()
    venue = forms.ModelMultipleChoiceField(queryset=Resources.objects.all(),widget=forms.SelectMultiple)
    starttime=forms.TimeField()
    endtime=forms.TimeField()
Ejemplo n.º 7
0
class EditSoltoonForm(ModelForm):
    primary_uniform = forms.ChoiceField(
        label=_('primary uniform'),
        widget=ChooseUniformWidget(postfix='a'),
        choices=Soltoon._uniforms)
    secondary_uniform = forms.ChoiceField(
        label=_('secondary uniform'),
        widget=ChooseUniformWidget(postfix='b'),
        choices=Soltoon._uniforms)

    class Meta:
        model = Soltoon
        exclude = ['user', 'created_at', 'achievements', 'code']
        layout = [('Field', 'name'),
                  ('Two Fields', ('Field', 'primary_uniform'),
                   ('Field', 'secondary_uniform'))]
Ejemplo n.º 8
0
class SurfaceForm(CleanVulnerableFieldsMixin, forms.ModelForm):
    """Form for creating or updating surfaces.
    """
    class Meta:
        model = Surface
        fields = ('name', 'description', 'category', 'creator', 'tags')

    def __init__(self, *args, **kwargs):
        autocomplete_tags = kwargs.pop('autocomplete_tags')
        super().__init__(*args, **kwargs)

        self.fields['tags'] = TagField(
            required=False,
            autocomplete_tags=autocomplete_tags,  # set special values for user
            help_text=TAGS_HELP_TEXT,
        )

    helper = FormHelper()
    helper.form_method = 'POST'
    helper.form_show_errors = False  # crispy forms has nicer template code for errors

    category = forms.ChoiceField(widget=forms.RadioSelect,
                                 choices=Surface.CATEGORY_CHOICES)

    helper.layout = Layout(
        Div(Field('name'), Field('description'), Field('category'),
            Field('tags'), Field('creator', type='hidden')),
        FormActions(
            Submit('save', 'Save'),
            HTML("""
                    <a class="btn btn-default" id="cancel-btn" onclick="history.back(-1)">Cancel</a>
                """),
        ), ASTERISK_HELP_HTML)
Ejemplo n.º 9
0
class UpdateEventForm(forms.Form):
    eventname=forms.CharField(max_length=30,label="eventname",required=True,error_messages={'invalid':'Event Name should be unique'})
    description = forms.CharField(max_length=500, label="description", required=True)
    year = forms.ChoiceField(choices=[('1', '1'), ('2', '2'), ('3', '3'), ('4', '4')])
    resourceperson = forms.CharField(max_length=30, required=True)
    res_person_workplace = forms.CharField(max_length=100, required=True)
    branch = forms.ChoiceField(choices=[('CSE', 'CSE'), ('IT', 'IT'), ('ECE', 'ECE'), ('EEE', 'EEE')])
    section = forms.ChoiceField(choices=[('A', 'A'), ('B', 'B'), ('both', 'both')])
    date = forms.DateField()
    venue = forms.ModelMultipleChoiceField(queryset=Resources.objects.all(), widget=forms.SelectMultiple)
    starttime = forms.TimeField()
    endtime = forms.TimeField()

    def __init__(self, *args, **kwargs):
        request = kwargs.pop('instance')
        self.instance = request
        super(UpdateEventForm, self).__init__(*args, **kwargs)
Ejemplo n.º 10
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)
Ejemplo n.º 11
0
class ExampleForm(forms.Form):
    field1 = forms.ChoiceField(
        required=True,
        widget=forms.RadioSelect(attrs={'class': 'Radio'}),
        choices=(
            ('enterprise', 'enterprise'),
            ('residential', 'residential'),
        ))
Ejemplo n.º 12
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",
    )
Ejemplo n.º 13
0
class HouseForm(forms.ModelForm):
    category = forms.ModelChoiceField(queryset=Category.objects.all(),
                                      required=False)
    status = forms.ChoiceField(required=True, choices=OPTIONS)
    furnished = forms.ChoiceField(required=True, choices=OPTIONS)
    balconied = forms.ChoiceField(required=True, choices=OPTIONS)
    withintheSite = forms.ChoiceField(required=True, choices=OPTIONS)
    detail = forms.CharField(widget=CKEditorWidget())
    image = forms.ImageField(widget=forms.FileInput())

    class Meta:
        model = House
        fields = [
            'category', 'title', 'keywords', 'description', 'slug', 'image',
            'rent', 'detail', 'status', 'area', 'location', 'room',
            'buildingFloor', 'floorLocation', 'furnished', 'balconied',
            'heating', 'withintheSite', 'fromWho'
        ]
Ejemplo n.º 14
0
class AliasesForm(ModelForm):
    class Meta:
        fields = "__all__"
        model = Aliases

    license = forms.ChoiceField()

    def __init__(self, *args, **kwargs):
        super(AliasesForm, self).__init__(*args, **kwargs)
        self.fields['license'].choices = license_choices()
Ejemplo n.º 15
0
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,
    )
Ejemplo n.º 16
0
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,
    )
Ejemplo n.º 17
0
class Responsable_Form(forms.Form):
    Numero_Dni = forms.CharField(
        label='Numero de Dni',
        required=True,
        widget=forms.TextInput(attrs={
            'class': 'form-control input-sm',
            'placeholder': 'Numero DNI'
        }))
    Nombre_Responsable = forms.CharField(
        label='Nombres',
        required=True,
        widget=forms.TextInput(attrs={
            'class': 'form-control input-sm',
            'placeholder': 'Nombre Completo'
        }))
    Apellido_Paterno_Responsable = forms.CharField(
        label='Apellido Paterno',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
    Apellido_Materno_Responsable = forms.CharField(
        label='Apellido Paterno',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
    Nombre_Usuario = forms.CharField(
        label='Nombre Usuario',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
    Email = forms.EmailField(
        label='Direccion Email',
        required=True,
        widget=forms.EmailInput(attrs={'class': 'form-control input-sm'}))
    Telefono = forms.CharField(
        label='Numero de telefono',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
    Region = forms.ChoiceField(label='Region encargada',
                               required=True,
                               widget=forms.Select,
                               choices=choices_regiones)
    contra1 = forms.CharField(
        label='Contraseña',
        required=True,
        widget=forms.PasswordInput(attrs={'class': 'form-control input-sm'}))
    contra2 = forms.CharField(
        label='Confirmar contraseña',
        required=True,
        widget=forms.PasswordInput(attrs={'class': 'form-control input-sm'}))
    clave = forms.CharField(
        label='Clave Unica',
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control input-sm'}))
Ejemplo n.º 18
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'}))
class StudentsInformationForm(forms.Form):
    fullname = forms.CharField(max_length=64, required=True)
    options = [('Masters', 'Masters'), ('Graduation', 'Graduation'),
               ('UnderGraduate', 'Under Graduate')]
    qualification = forms.ChoiceField(widget=forms.RadioSelect(),
                                      choices=options,
                                      required=True)
    university = forms.CharField(max_length=32, required=True)
    phonenumber = forms.CharField(max_length=12, required=True)
    country = forms.CharField(max_length=32, required=True)

    def clean_phonenumber(self):
        if (self.cleaned_data['phonenumber'].__len__() < 10):
            raise forms.ValidationError("Invalid Phone Number")
        else:
            return self.cleaned_data['phonenumber']
Ejemplo n.º 20
0
    def __init__(self, *args, **kwargs):
        data_source_choices = kwargs.pop('data_source_choices')
        autocomplete_tags = kwargs.pop('autocomplete_tags')
        self._surface = kwargs.pop('surface')
        super(TopographyMetaDataForm, self).__init__(*args, **kwargs)
        self.fields['data_source'] = forms.ChoiceField(
            choices=data_source_choices)

        self.fields['tags'] = TagField(required=False,
                                       autocomplete_tags=autocomplete_tags,
                                       help_text=TAGS_HELP_TEXT)
        measurement_date_help_text = MEASUREMENT_DATE_HELP_TEXT
        if self.initial['measurement_date']:
            measurement_date_help_text += f" The date \"{self.initial['measurement_date']}\" is the latest date " \
                                          "we've found over all channels in the data file."
        else:
            measurement_date_help_text += f" No valid measurement date could be read from the file."
        self.fields['measurement_date'] = forms.DateField(
            widget=DatePickerInput(format=MEASUREMENT_DATE_INPUT_FORMAT),
            help_text=measurement_date_help_text)
Ejemplo n.º 21
0
class RegisterForm(forms.Form):
    gender = (
        ('male', "男"),
        ('female', "女"),
    )
    username = forms.CharField(
        label="用户名",
        max_length=128,
        widget=forms.TextInput(attrs={'class': 'form-control'}))
    password1 = forms.CharField(
        label="密码",
        max_length=256,
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))
    password2 = forms.CharField(
        label="确认密码",
        max_length=256,
        widget=forms.PasswordInput(attrs={'class': 'form-control'}))
    email = forms.EmailField(
        label="邮箱地址", widget=forms.EmailInput(attrs={'class': 'form-control'}))
    sex = forms.ChoiceField(label='性别', choices=gender)
class RegistrationForm(forms.Form):
    username = forms.CharField(
        max_length=30,
        label="username",
        required=True,
        error_messages={'invalid': 'Username should be unique'})
    email = forms.EmailField(label="emailid", required=True)
    password1 = forms.CharField(max_length=30,
                                widget=forms.PasswordInput(),
                                label="password",
                                required=True)
    password2 = forms.CharField(max_length=30,
                                widget=forms.PasswordInput(),
                                label="password(again)",
                                required=True)
    options = [('teacher', 'Teacher'), ('student', 'Student')]
    role = forms.ChoiceField(widget=forms.RadioSelect(),
                             label="Account Type",
                             required=True,
                             choices=options)

    def clean_username(self):
        u = self.cleaned_data['username']
        try:
            u = User.objects.get(username__exact=u)
        except User.DoesNotExist:
            return self.cleaned_data['username']
        raise forms.ValidationError(
            "Username Already Exists . Please Try another name",
            code='invalid')

    def clean(self):
        p1 = self.cleaned_data['password1']
        p2 = self.cleaned_data['password2']
        if p1 is not None and p2 is not None:
            if p1 != p2:
                raise forms.ValidationError("Two passwords did not match")
            else:
                return self.cleaned_data
        else:
            raise forms.ValidationError("Both fields should match")
Ejemplo n.º 23
0
class TimeCardAcceptForm(ModelForm):

    AcceptorDecline = forms.ChoiceField(choices=Choices, label='Review')

    class Meta:
        model = Timecard
        labels = {
            'Sitecode': 'Site Code',
            'nameofcontracter': 'Name of contracter',
            'Totalhrs': 'Total Hours',
            'Totalamount': 'Total Amount',
        }
        exclude = ('State', )

    def __init__(self, *args, **kwargs):
        super(TimeCardAcceptForm, self).__init__(*args, **kwargs)
        instance = getattr(self, 'instance', None)
        if instance and instance.id:
            self.fields['Sitecode'].widget.attrs['readonly'] = True
            self.fields['nameofcontracter'].widget.attrs['readonly'] = True
            self.fields['Totalhrs'].widget.attrs['readonly'] = True
            self.fields['Totalamount'].widget.attrs['readonly'] = True
class TeacherInformationForm(forms.Form):
    fullname = forms.CharField(max_length=64, required=True)
    options = [('Masters', 'Masters'), ('Graduation', 'Graduation'),
               ('UnderGraduate', 'Under Graduate')]
    qualification = forms.ChoiceField(widget=forms.RadioSelect(),
                                      choices=options,
                                      required=True)
    university = forms.CharField(max_length=32, required=True)
    phonenumber = forms.CharField(max_length=12, required=True)
    country = forms.CharField(max_length=32, required=True)
    experience = forms.IntegerField()

    def clean_experience(self):
        if (self.cleaned_data['experience'] <= 0):
            raise forms.ValidationError("Experience should be greater than 0")
        else:
            return self.cleaned_data['experience']

    def clean_phonenumber(self):
        if (self.cleaned_data['phonenumber'].__len__() < 10):
            raise forms.ValidationError("Invalid Phone Number")
        else:
            return self.cleaned_data['phonenumber']
Ejemplo n.º 25
0
class login_form(ModelForm):
    user_type = forms.ChoiceField(choices=[(1, 'همیار'), (2, 'مددجو'), (3, 'مددکار'), (4, 'مدیر سامانه')],
                                  label="ورود به عنوانِ")

    class Meta:
        model = models.active_user
        fields = ['username', 'password']
        widgets = {
            'password': forms.TextInput(attrs={'type': 'password'})
        }

    def clean(self):
        cleaned_data = super(login_form, self).clean()
        username = cleaned_data["username"]
        password = cleaned_data["password"]
        type = cleaned_data["user_type"]
        user = authenticate(self.data, username=username, password=password)

        print('!!')
        if user is None:
            # print("!")
            raise forms.ValidationError("kooft")

        return cleaned_data
Ejemplo n.º 26
0
class Calculate(forms.Form):
    course = forms.ModelChoiceField(queryset=Course.objects.all(),
                                    empty_label=None)
    year = forms.ChoiceField()
Ejemplo n.º 27
0
class ResultFacultyForm(forms.Form):
    program = forms.CharField(max_length=10)
    semester = forms.ChoiceField(choices=[(tag.name, tag.value)
                                          for tag in Semester])
    year = forms.IntegerField()
Ejemplo n.º 28
0
class JiraConfirmationForm(Form):
    title = forms.CharField(max_length=1000)
    description = forms.CharField(widget=forms.Textarea)
    project = forms.ChoiceField()
    reporter = forms.ChoiceField(choices=get_user_list)
Ejemplo n.º 29
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(
                "Το πεδίο Συνδυασμός πρέπει να συμπληρωθεί αφού πρόκειται για υποψήφιο Δημοτικό Σύμβουλο!"
            )
Ejemplo n.º 30
0
class CheckForm(forms.Form):
    isTrue = forms.ChoiceField(choices=CHOICES)

    def getSol(self):
        return Solution.objects.get(id=self.prefix)