示例#1
0
 class Meta:
     exclude = (
         'member',
         'created_at',
         'updated_at',
         'enabled',
     )
     model = Profile
     labels = {
         'level': 'Education level',
         'relocation': 'Ready for relocation',
         'official_journey': 'Ready for official journey',
     }
     widgets = {
         'birth_date':
         forms.SelectDateWidget(
             years=[i for i in range(1950,
                                     now().year - 17)][::-1],
             empty_label=('Select year of birth', 'month of birth',
                          'day of birth'),
         ),
         'address':
         AddressWidget(),
     }
示例#2
0
class AddTransactionForm(forms.ModelForm):
    date = forms.DateField(widget=forms.SelectDateWidget(), initial=datetime.now())
    comments = forms.CharField(required=False)

    class Meta:
        model = Transaction
        fields = ('budget', 'user', 'date', 'envelope', 'type', 'description', 'sum', 'comments')

    def __init__(self, *args, **kwargs):
        super(AddTransactionForm, self).__init__(*args, **kwargs)
        self.fields['budget'].queryset = BudgetAccount.objects.filter(pk=kwargs['initial']['id_budget'])
        self.fields['budget'].widget = forms.HiddenInput()
        self.fields['user'].queryset = User.objects.filter(pk=kwargs['initial']['id_user'])
        self.fields['user'].widget = forms.HiddenInput()
        self.fields['envelope'].queryset = Envelope.objects.exclude(is_inactive=True)

    def save(self, commit=True):
        transaction = super(AddTransactionForm, self).save(commit)
        if transaction is not None:
            transaction.update_envelope()
        return transaction
    
    def is_valid(self):
        if super(AddTransactionForm, self).is_valid():
            if self.fields['type'] == Transaction.TYPE_INCOME:
                return True
            envelope = self.cleaned_data['envelope']
            transaction_sum = self.cleaned_data['sum']
            if transaction_sum <= 0:
                self.add_error('sum', exceptions.ValidationError)
                return False
            if envelope.check_sufficient_funds(transaction_sum):
                return True
            else:
                self.add_error('sum', exceptions.ValidationError)
        return False
示例#3
0
class ProfileView(forms.ModelForm):
    user_name = forms.CharField(validators=[validators.MinLengthValidator(3)])
    first_name = forms.CharField(
        required=False,
        widget=forms.TextInput(attrs={"placeholder": "optional"}))

    last_name = forms.CharField(
        required=False,
        widget=forms.TextInput(attrs={"placeholder": "optional"}))

    YEARS = [x for x in range(1940, 2003)]
    birthdate = forms.DateField(initial="1994-06-21",
                                widget=forms.SelectDateWidget(years=YEARS))

    class Meta:
        model = Profile
        fields = [
            "user_name", "first_name", "last_name", "gender", "birthdate"
        ]

    def clean(self):
        user_name = self.cleaned_data["user_name"]
        if Profile.objects.filter(user_name=user_name).exists():
            raise forms.ValidationError("This username is already taken")
示例#4
0
class EnquiryForm(forms.Form):
    name = forms.CharField(label="Enter Your Data ",
                           widget=forms.TextInput(attrs={
                               'placeholder': 'Your name',
                               'class': 'form-control'
                           }))
    mobile = forms.IntegerField(
        label="Enter Your Mobile NO",
        widget=forms.NumberInput(attrs={
            'placeholder': 'your mobile no',
            'class': 'form-control'
        }))
    email = forms.EmailField(
        label="Your Email ID",
        widget=forms.EmailInput(attrs={
            'placeholder': 'youe Email',
            'class': 'form-control'
        }))
    COURSE_CHOICES = (('PTYHON', 'Python'), ('DJANGO', 'Django'), ('UI', 'Ui'),
                      ('REST API', 'Rest Api'))
    courses = MultiSelectFormField(choices=COURSE_CHOICES,
                                   label="select Required Field")

    TRAINERS_CHOICES = (('SAI', 'Sai'), ('NANI', 'Nani'), ('SATYA', 'Satya'))
    trainers = MultiSelectFormField(choices=TRAINERS_CHOICES,
                                    label="select Required Trainer")

    BRANCHES_CHOICES = (('HYD', 'Hyd'), ('BANG', 'Bang'), ('CHENNAI',
                                                           'Chennai'))
    branches = MultiSelectFormField(choices=BRANCHES_CHOICES,
                                    label="Select Your Branches")
    GENDER_CHOICES = (('MALE', 'Male'), ('FEMALE', 'Female'))
    gender = forms.ChoiceField(widget=forms.RadioSelect(),
                               choices=GENDER_CHOICES,
                               label="select your Gender ")
    start_date = forms.DateField(widget=forms.SelectDateWidget())
示例#5
0
class ProfileUpdateForm(forms.ModelForm):

    bio = forms.CharField(widget=TinyMCE(attrs={
        'required': False,
        'cols': 30,
        'rows': 10
    }))

    BIRTH_YEAR_CHOICES = range(1950, datetime.now().year + 1)
    profile_pic = forms.ImageField(widget=forms.ClearableFileInput)
    Date_Of_Birth = forms.DateField(
        widget=forms.SelectDateWidget(years=BIRTH_YEAR_CHOICES),
        input_formats=['%Y-%m-%d'],
        help_text='Format:YYYY-MM-DD')
    Gender = forms.ChoiceField(widget=forms.RadioSelect,
                               choices=[('Male', 'Male'), ('Female', 'Female'),
                                        ('Other', 'Other')])

    class Meta:
        model = Profile
        fields = [
            'bio', 'profile_pic', 'Date_Of_Birth', 'Address', 'location',
            'Gender'
        ]
示例#6
0
class PostForm(forms.ModelForm):
    """
    # AUTOMAGICALLY: little html select heleper in Form to choose each element of a date
    # ADDITIONS:
        - year's selector in a range of 5 years before today & 10 years after today
        - default date in selector: today's timestamp
    """
    published_at = forms.DateField(
        widget=forms.SelectDateWidget(years=range(timezone.now().year - 5,
                                                  timezone.now().year + 10)),
        initial=timezone.now().date())
    """
    FROM: http://stackoverflow.com/questions/18738486/control-the-size-textarea-widget-look-in-django-admin#answer-18738715
    styling form fields
    """
    class Meta:
        model = Post
        fields = [
            'title', 'category', 'content', 'picture', 'draft', 'published_at'
        ]
        widgets = {
            'content':
            forms.Textarea(attrs={
                'rows': 10,
                'cols': 1,
                'class': 'pure-u-1-1',
                'id': 'content'
            }),
            'title':
            forms.TextInput(attrs={
                'class': 'pure-u-1-1',
                'id': 'title'
            })
        }

    """
示例#7
0
 class Meta:
     model = Perfil
     fields = (
         'nombreArtista',
         'nombreReal',
         'imagen',
         'sexo',
         'fechaNacimiento',
         'telefono',
         'email',
         'descripcion',
         'categoria',
     )
     label = {
         'nobmreArtista': 'Nombre artistico:',
         'nombreReal': 'Nombre real:',
         'imagen': 'Insertar imagen',
         'sexo': 'Genero:',
         'fechaNacimiento': 'Fecha de nacimiento:',
         'telefono': 'Telfeno:',
         'email': 'Correo electronico:',
         'descripcion': 'Descripcion (opcional):',
     }
     exclude = ('visitas', 'autorizado', 'fechaRegistro')
     CHOICES = ((
         '1',
         'Masculino',
     ), (
         '0',
         'Femenino',
     ))
     widgets = {
         'fechaNacimiento': forms.SelectDateWidget(years=range(1900, 2001)),
         'sexo':
         forms.RadioSelect(choices=CHOICES)  #'imagen': forms.FileInput(),
     }
示例#8
0
class PostForm(forms.ModelForm):
    title = forms.CharField(required=True,
                            label="",
                            widget=forms.TextInput(
                                attrs={
                                    'class': 'form-control',
                                    'id': 'id_title',
                                    'placeholder': "article title",
                                    'label': ''
                                }))

    timestamp = forms.DateField(label='Select Publish Date',
                                initial=datetime.datetime.now(),
                                widget=forms.SelectDateWidget(
                                    attrs={
                                        'class': 'form-control',
                                    },
                                    years=YEAR_CHOICES))

    content = forms.CharField(label="",
                              widget=forms.Textarea(
                                  attrs={
                                      'class': 'form-control',
                                      'id': 'id_content',
                                      'rows': 10,
                                      'placeholder': "article body",
                                      'label': ''
                                  }))

    class Meta:
        model = Post
        fields = [
            'title',
            'content',
            'timestamp',
        ]
示例#9
0
class Task(forms.Form):
    name = forms.CharField(label='Task',
                           max_length=100,
                           widget=forms.TextInput(attrs={
                               'id': 'New',
                               'class': 'form'
                           }))
    favorite_colors = forms.MultipleChoiceField(
        required=False,
        widget=forms.CheckboxSelectMultiple(attrs={'class': 'form'}),
        choices=FAVORITE_COLORS_CHOICES,
    )
    birth_year = forms.DateField(widget=forms.SelectDateWidget(
        years=BIRTH_YEAR_CHOICES))
    choice_field = forms.ChoiceField(
        widget=forms.RadioSelect(attrs={'class': 'form'}), choices=CHOICES)
    birth_year.widget.attrs.update({'class': 'form'})

    def clean_name(self):
        name = self.cleaned_data.get("name")
        if not "play" in name:
            raise forms.ValidationError("Please include play")
        else:
            return name
class MetaMixin:
    current_year = datetime.datetime.now().year

    MONTHS = {
        1: "januari",
        2: "februari",
        3: "mars",
        4: "april",
        5: "maj",
        6: "juni",
        7: "juli",
        8: "augusti",
        9: "september",
        10: "oktober",
        11: "november",
        12: "december",
    }

    widgets = {
        "birthday":
        django_forms.SelectDateWidget(years=range(current_year,
                                                  current_year - 80, -1),
                                      months=MONTHS),
    }
class MenuForm(forms.ModelForm):
    """added expiration date required formats and select date widget"""
    date_range = 5
    this_year = timezone.now().year
    expiration_date = forms.DateTimeField(
        input_formats=['%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y'],
        widget=forms.SelectDateWidget(years=range(this_year, this_year +
                                                  date_range)))

    class Meta:
        model = Menu
        fields = [
            'season',
            'items',
            'expiration_date',
        ]

    def clean_expiration_date(self):
        """added clean method so expiration date is greater than created_at"""
        expiration_date = self.cleaned_data['expiration_date']
        if expiration_date <= timezone.now():
            raise forms.ValidationError(
                "Menu Expiration date should be a future date")
        return expiration_date
示例#12
0
 class Meta:
     model = Task
     fields = [
         #'text',
         'status',
         'priority',
         'category',
         'assignee',
         'occurence',
         'occurence_desc',
         'percent_complete',
         'time_estimate_val',
         'time_estimate_metric',
         'time_actual_val',
         'time_actual_metric',
         'location',
         'due_date',
     ]
     widgets = {
         #'text' : forms.TextInput(
         #  attrs = {'class' : 'form-control', 'placeholder': 'enter todo item', 'aria-label': 'Todo', 'aria-describedby': 'add-btn' }
         #),
         'due_date': forms.SelectDateWidget()
     }
示例#13
0
class TrainingTransactionForm(forms.ModelForm):

    class Meta:
        model = TrainingTransaction
        #fields = '__all__'
        fields ={'trainer','date','time','note'}
    list_of_hour ={
            (6,"06:00"),
            (7,"07:00"),
            (8, "08:00"),
            (9, "09:00"),
            (10, "10:00"),
            (11, "11:00"),
            (12, "12:00"),
            (13, "13:00"),
            (14, "14:00"),
            (15, "15:00"),
            (16, "16:00"),
            (17, "17:00"),
            (18, "18:00"),
            (19, "19:00"),
            (20, "20:00"),
            (21, "21:00"),
            (22, "22:00"),
            (23, "23:00"),
            (24, "24:00"),
            (1, "01:00"),
            (2, "02:00"),
            (3, "03:00"),
            (4, "04:00"),
            (5, "05:00"),}
    trainer = forms.ModelChoiceField(queryset=User.objects.all().filter(profile__user_grup="Eğitmen"))
   # member = forms.ModelChoiceField(queryset=User.objects.all().filter(profile__user_grup="Uye"))
    date = forms.DateField(required=True, widget=forms.SelectDateWidget(years=timezone.now().year), label="Tarih")
    time = forms.ChoiceField(choices=list_of_hour,label='Saat')
    note = forms.Textarea()
示例#14
0
class PostForm(forms.ModelForm):

    categories = Category.objects.all()
    categories_list = []
    for category in categories:
        list_a = [category.title, category.title]
        categories_list.append(list_a)
    tuple(categories_list)
    categories = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,
                                           choices=categories_list,
                                           required=False)
    publish = forms.DateField(widget=forms.SelectDateWidget())

    class Meta:
        model = Post
        fields = (
            "title",
            "categories",
            "content",
            "image",
            "video_url",
            "draft",
            "publish",
        )
示例#15
0
class ProfileUpdateForm(forms.ModelForm):
	birth_date= forms.DateField(
		label='Date of Birth',
		required=False,
		widget=forms.SelectDateWidget(years=YEARS,))

	city = forms.CharField(
		label='City',
		required=False,
		)

	gender = forms.ChoiceField(
		choices = Gender_Option,
		required=False,
		widget=forms.RadioSelect())

	class Meta:
		model = Profile
		fields =[
		'birth_date',
		'city',
		'gender',
		'image',
		]
示例#16
0
 class Meta:
     model = Comentario
     fields = ('titulo','comentario','producto_id', 'fecha_de_compra')
     label = {
         'Titulo':'titulo',
         'comentario':'comentario',
         'producto_id': 'productos relacionados al comentario',
         'fecha_de_compra': 'Fecha en la que compro el producto'
     }
     widgets = {
         'titulo':forms.TextInput(
             attrs = {
                 'class':'form-control',
                 'placeholder':'Ingrese el titulo de comentario max 30 caracteres',
                 'id':'titulo'
             }
         ),
         'comentario': forms.Textarea(
             attrs = {
                 'class':'form-control',
                 'placeholder': 'Ingrese su comentario',
                 'id':'descripcion'
             }
         ),
         'producto_id': forms.SelectMultiple(
             attrs = {
                 'class':'form-control'
             }
         ),
         'fecha_de_compra': forms.SelectDateWidget(
             attrs = {
                 'class': 'form-control'
             }
         )
         
     }
示例#17
0
class AuthorForm(forms.ModelForm):
    title = forms.ChoiceField(widget=forms.RadioSelect, choices=Author.TITLE_CHOICES)
    birth_date = forms.DateField(widget=forms.SelectDateWidget(years=BIRTH_YEAR_CHOICES))

    class Meta:
        model = Author
        fields = ['name', 'title', 'birth_date']
        widgets = {
            'name': Textarea(attrs={'cols': 80, 'rows': 20}),
        }
        labels = {
            'name': _('Writer'),
        }
        help_texts = {
            'name': _('Some useful help text.'),
        }
        error_messages = {
            'name': {
                'max_length': _("This writer's name is too long."),
            },
        }

    def clean_name(self):
        name = self.cleaned_data.get('name')
        if len(name) < 2:
            raise ValidationError('name must be longer!!')
        return name

    def clean(self):
        cleaned_data = super().clean()
        name = cleaned_data.get('name')

        if name and name.isdigit():
            msg = 'Name can not be a number! - Author'
            self.add_error('name', msg)
        return cleaned_data
示例#18
0
class TambahBSForm(ModelForm):
    """
    Render the basic crud create form
    """
    nama_sampah = forms.ModelChoiceField(queryset=Sampah.objects.all())

    nama_lokasi = forms.ModelChoiceField(
        queryset=LokasiKecamatan.objects.all())

    tanggal = forms.DateField(widget=forms.SelectDateWidget(
        attrs={
            'class': 'form-control',
            'placeholder': 'Tanggal'
        }))

    jumlah = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'form-control',
            'placeholder': 'Masukkan jumlah sampah'
        }))

    class Meta:
        model = InputBS
        fields = ('nama_sampah', 'nama_lokasi', 'tanggal', 'jumlah')
示例#19
0
class TweetFilter(django_filters.FilterSet):
    tweet = django_filters.CharFilter(lookup_expr='icontains',
                                      label='Search terms')
    country = django_filters.CharFilter(lookup_expr='icontains',
                                        label='Country')
    gender_predicted = django_filters.MultipleChoiceFilter(
        choices=gender_choice,
        widget=forms.CheckboxSelectMultiple,
        label='Gender')
    sentiment_type = django_filters.MultipleChoiceFilter(
        choices=sentiment_choice,
        widget=forms.CheckboxSelectMultiple,
        label='sentiment')
    dateTime = django_filters.DateTimeFilter(widget=forms.SelectDateWidget(),
                                             lookup_expr="date",
                                             label="Date",
                                             initial=date.today())

    class Meta:
        model = Tweets
        fields = [
            'tweet', 'country', 'gender_predicted', 'dateTime',
            'sentiment_type'
        ]
示例#20
0
class RegistrationForm(forms.ModelForm):
    name = forms.CharField(label = 'NAME' , widget= forms.TextInput (attrs= { "placeholder" : "your name"}))
    dob = forms.CharField(label='D.O.B' , widget=forms.SelectDateWidget(years=YEARS ,attrs={'class' :"dateofbirth"}))
    GENDER = (
    ('male' , 'M'),
    ('female' , 'F'),
    ('other' , 'O')
)
    gender = forms.ChoiceField(choices=GENDER)
    address = forms.CharField(
        label = 'ADDRESS',
        widget= forms.Textarea(
            attrs= {
                "placeholder" : "your address",
                "rows" : 5,
                "cols" : 30,
                'class' :"address-name"
            })
        )
    pincode = forms.CharField(label= "PINCODE")
    city = forms.CharField(label="CITY" , widget= forms.TextInput( attrs= {"placeholder" : "your city", 'class' :"city-name"}))
    country = forms.CharField(label="COUNTRY" , widget= forms.TextInput( attrs= {"placeholder" : "your country", 'class' :"country-name"}))
    image = forms.ImageField(label= "select an image")
    vehicleregform = forms.FileField(label="Vehicle Reg.Form")
    vehicleinsform = forms.FileField(label="Vehicle Insurance")
    drivinglicenseform = forms.FileField(label="DRIVING LICENSE")
    aadharform= forms.FileField(label="Aadhar form")
    DESIGNATION = (
    ('ACCOUNTS', 'ACCOUNTS'),
    ('IT' , 'IT'),
    ('SALES' , 'SALES'),
    ('CUSTOMER SERVICE' , 'CUSTOMER SERVICE'),
    ('DELIVERY SERVICE' , 'DELIVERY SERVICE')
 )
    designation = forms.ChoiceField(choices=DESIGNATION)
    aadharno = forms.IntegerField(label= "AADHAR CARD NO " , widget= forms.TextInput (attrs= {"placeholder" : "your addhar number", 'class' :"aadharno"}))
    drivingno = forms.IntegerField(label= "DRIVING LICENSE NO" , widget=forms.TextInput(attrs= {"placeholder" : "licese no", 'class' :"licenseno"}))
    contactno1 = forms.CharField(label= 'CONTACT NUMBER 1' , widget=forms.NumberInput(attrs= {"placeholder" : "your number", 'class' :"contact1"}))
    contactno2 = forms.CharField(label= 'CONTACT NUMBER 2', widget=forms.NumberInput(attrs= {"placeholder" : "your number", 'class' :"contact2"}))
    email =  forms.EmailField(label="EMAIL ID" , widget= forms.EmailInput(attrs={"placeholder" : "your mail id", 'class' :"email-id"}))
    bankaccount = forms.IntegerField(label='BANK ACCOUNT NO', widget=forms.NumberInput(attrs= {"placeholder" : "your number", 'class' :"bankaccount"}))
    ifsc = forms.CharField(label="IFSC NUMBER")
    remarks = forms.BooleanField()



    class Meta :
        model = Jobform
        fields = [
            'name',
            'dob',
            'gender',
            'address',
            'pincode',
            'city',
            'country',
            'designation',
            'aadharno',
            'drivingno',
            'contactno1',
            'contactno2',
            'email',
            'bankaccount',
            'ifsc',
            'image',
            'vehicleregform',
            'vehicleinsform',
            'drivinglicenseform',
            'aadharform'
            
        ]

        
示例#21
0
class SimpleMultiWidgetForm(TapeformMixin, forms.Form):
    widget_template_overrides = {'birthdate': 'basic/select_date_widget.html'}

    birthdate = forms.DateField(widget=forms.SelectDateWidget())
示例#22
0
class TurnosForm(forms.ModelForm):

    nombre = forms.CharField(label='Nombre y apellido',
                             required=True,
                             widget=forms.TextInput(attrs={
                                 'class': "form-control",
                                 'placeholder': "Nombre"
                             }))
    obra_social = forms.CharField(
        label='Obra Social',
        required=True,
        widget=forms.TextInput(attrs={
            'class': "form-control",
            'placeholder': "Obra Social"
        }))
    email = forms.EmailField(label='Email',
                             required=True,
                             widget=forms.EmailInput(attrs={
                                 'class': "form-control",
                                 'placeholder': "Email"
                             }))
    edad = forms.IntegerField(label='Edad',
                              required=True,
                              widget=forms.NumberInput(attrs={
                                  'class': "form-control",
                                  'placeholder': "Edad"
                              }))
    dni = forms.IntegerField(label='DNI',
                             required=True,
                             widget=forms.NumberInput(attrs={
                                 'class': "form-control",
                                 'placeholder': "DNI"
                             }))
    telefono = forms.CharField(
        label='Telefono',
        required=True,
        widget=forms.TextInput(attrs={
            'class': "form-control",
            'placeholder': "Telefono"
        }))
    direccion = forms.CharField(
        label='Direccion',
        required=True,
        widget=forms.TextInput(attrs={
            'class': "form-control",
            'placeholder': "Direccion"
        }))
    #fecha_consulta = forms.ChoiceField(choices= fecha, label='Fecha de Consulta', required=True, widget= forms.)
    #hora_consulta = forms.TimeField(label='Hora Consulta', widget=forms.)
    fecha_consulta = forms.DateField(label='Fecha Consulta',
                                     widget=forms.SelectDateWidget(
                                         years=range(2020, 2021),
                                         attrs={
                                             'class': "form-control",
                                             'placeholder': "Fecha Consulta"
                                         }))

    class Meta:

        model = Turno
        fields = [
            'nombre', 'obra_social', 'email', 'edad', 'dni', 'telefono',
            'direccion'
        ]
示例#23
0
 class Meta:
     model = models.Edition
     exclude = [
         "remote_id",
         "origin_id",
         "created_date",
         "updated_date",
         "edition_rank",
         "authors",
         "parent_work",
         "shelves",
         "connector",
         "search_vector",
         "links",
         "file_links",
     ]
     widgets = {
         "title":
         forms.TextInput(attrs={"aria-describedby": "desc_title"}),
         "subtitle":
         forms.TextInput(attrs={"aria-describedby": "desc_subtitle"}),
         "description":
         forms.Textarea(attrs={"aria-describedby": "desc_description"}),
         "series":
         forms.TextInput(attrs={"aria-describedby": "desc_series"}),
         "series_number":
         forms.TextInput(attrs={"aria-describedby": "desc_series_number"}),
         "languages":
         forms.TextInput(
             attrs={
                 "aria-describedby": "desc_languages_help desc_languages"
             }),
         "publishers":
         forms.TextInput(
             attrs={
                 "aria-describedby": "desc_publishers_help desc_publishers"
             }),
         "first_published_date":
         forms.SelectDateWidget(
             attrs={"aria-describedby": "desc_first_published_date"}),
         "published_date":
         forms.SelectDateWidget(
             attrs={"aria-describedby": "desc_published_date"}),
         "cover":
         ClearableFileInputWithWarning(
             attrs={"aria-describedby": "desc_cover"}),
         "physical_format":
         forms.Select(attrs={"aria-describedby": "desc_physical_format"}),
         "physical_format_detail":
         forms.TextInput(
             attrs={"aria-describedby": "desc_physical_format_detail"}),
         "pages":
         forms.NumberInput(attrs={"aria-describedby": "desc_pages"}),
         "isbn_13":
         forms.TextInput(attrs={"aria-describedby": "desc_isbn_13"}),
         "isbn_10":
         forms.TextInput(attrs={"aria-describedby": "desc_isbn_10"}),
         "openlibrary_key":
         forms.TextInput(
             attrs={"aria-describedby": "desc_openlibrary_key"}),
         "inventaire_id":
         forms.TextInput(attrs={"aria-describedby": "desc_inventaire_id"}),
         "oclc_number":
         forms.TextInput(attrs={"aria-describedby": "desc_oclc_number"}),
         "ASIN":
         forms.TextInput(attrs={"aria-describedby": "desc_ASIN"}),
     }
示例#24
0
 def __init__(self, *args, **kwargs):
     super(MenuForm, self).__init__(*args, **kwargs)
     self.fields["items"].widget = forms.widgets.SelectMultiple()
     self.fields["items"].queryset = models.Item.objects.all()
     self.fields["expiration_date"].widget = forms.SelectDateWidget(
         empty_label=("Choose Year", "Choose Month", "Choose Day"), )
示例#25
0
class InvoicesForm(ModelForm):

    ORGANISATION = (
        ("Linco Care", "Linco Care"),
        ("QHorizons", "QHorizons"),
    )

    PAYMENT_CHOICES = (
        ('Credit Card', 'Credit Card'),
        ('Bank Transfer', 'Bank Transfer'),
        ('Cheque', 'Cheque'),
        ('Cash', 'Cash'),
    )
    EXPENSE_TYPE = (
        ('Stationary', 'Stationary'),
        ('IT', 'IT'),
        ('PR and Social Media', 'PR and Social Media'),
        ('Marketing', 'Marketing'),
        ('Equipment', 'Equipment'),
        ('Transport', 'Transport'),
        ('Maintenance', 'Maintenance'),
        ('Print', 'Print'),
        ('Others', 'Others'),
    )
    CURRENCY = (
        (u'£', 'British Pound'),
        (u'$', 'United States Dollar'),
        (u'€', 'EURO'),
    )

    organisation = forms.ChoiceField(
        label=('organisation'),
        required=True,
        choices=ORGANISATION,
        widget=forms.Select(attrs={'class': 'form-control'}))
    supplier_name = forms.ModelChoiceField(
        queryset=Supplier.objects.all(),
        initial=0,
        widget=forms.Select(attrs={'class': 'form-control'}))
    invoice_date = forms.DateField(
        initial=datetime.date.today,
        required=False,
        widget=forms.SelectDateWidget(attrs={'class': 'custom-select'}))
    invoice = forms.FileField(
        label=('Upload Screenshot'),
        required=False,
        help_text='Upload a the invoice',
        widget=forms.FileInput(attrs={'class': 'form-control-file'}))
    payment_method = forms.ChoiceField(
        label=('payment_method'),
        required=True,
        choices=PAYMENT_CHOICES,
        widget=forms.Select(attrs={'class': 'form-control'}))
    expense_type = forms.ChoiceField(
        label=('expense_type'),
        required=True,
        choices=EXPENSE_TYPE,
        widget=forms.Select(attrs={'class': 'form-control'}))
    refund = forms.BooleanField(
        label=('refund'),
        required=False,
        widget=forms.CheckboxInput(attrs={'class': 'form-check'}))
    currency = forms.ChoiceField(
        label=('currency'),
        required=True,
        choices=CURRENCY,
        widget=forms.Select(attrs={'class': 'form-control'}))
    purchased_item = forms.CharField(
        label='purchased_item',
        max_length=400,
        required=True,
        widget=forms.TextInput(attrs={'class': 'form-control'}))

    class Meta:
        model = Invoices
        fields = (
            'organisation',
            'supplier_name',
            'purchased_item',
            'invoice_date',
            'invoice',
            'invoice_value',
            'vat_amount',
            'payment_method',
            'expense_type',
            'refund',
            'currency',
        )
示例#26
0
class UserForm(forms.Form):
    # Widget - Charfield
    #username = forms.CharField(label='Username', max_length=100, initial='Enter user name')
    username = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'Username', 'class': 'djangoform'}), required=True, max_length="8")
    # Widget - Password
    # password = forms.CharField(widget=forms.PasswordInput())
    password = forms.CharField(widget=forms.PasswordInput(attrs={'placeholder': 'Password', 'class': 'djangoform'}))

    # Widget - Email
    # email = forms.EmailField(label='Email', initial='We need your email')
    # email = forms.EmailField(widget=forms.TextInput(attrs={'placeholder': 'Email'}), required = True)

    email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'Email', 'class': 'djangoform'}),
                                 required=True)

    # Widget - Integer Field - Same used for Phone number
    # contact = forms.IntegerField(widget=forms.NumberInput(attrs={'placeholder': 'Phone number', 'min':10}), required = True )
    contact = forms.IntegerField(
            widget=forms.NumberInput(attrs={'placeholder': 'Phone number', 'class': 'djangoform'}),
            required=True)

    # upload Multiple files
    #upload_image = forms.FileField(widget=forms.ClearableFileInput(attrs={'multiple': True,'class': 'fileupload'}), required=False)
    upload_image = forms.ImageField(widget=forms.ClearableFileInput(attrs={'multiple': True, 'class': 'fileupload'}),
                                   required=False)
    #upload_image = forms.FileField(widget=forms.ClearableFileInput(attrs={'class': 'fileupload'}), required=False)

    # Date and Time Widgets
    # date = forms.DateField(widget=forms.SelectDateWidget)
    # date = forms.DateTimeField(widget = forms.SelectDateWidget())
    # date = forms.DateTimeField(widget = DatePickerInput(format='%m/%d/%Y'))
    # date = forms.DateField(widget=DatePicker(options={"format": "mm/dd/yyyy", "autoclose": True }))
    # date = forms.DateField(widget=widgets.AdminDateWidget)
    # date = forms.DateField(widget= forms.DateInput(format='%d/%m/%Y'))
    # # Using AdminDate and Time widget ##

    date = forms.DateField(widget=widgets.AdminDateWidget(attrs={'placeholder': 'Date'}), required=False)
    #time = forms.DateField(widget=widgets.AdminTimeWidget(attrs={'placeholder': 'Time'}), required=False)
    time = forms.TimeField(widget=widgets.AdminTimeWidget(attrs={'placeholder': 'Time'}), required=False)

    #  SelectDateWidget:
    BIRTH_YEAR_CHOICES = ['1980', '1981', '1982']
    birth_year = forms.DateField(widget=forms.SelectDateWidget(years=BIRTH_YEAR_CHOICES))

    # Widget Multiple Chocies
    FAVORITE_COLORS_CHOICES = [
        ('blue', 'Blue'),
        ('green', 'Green'),
        ('black', 'Black'),
    ]

    favorite_color = forms.MultipleChoiceField(widget=forms.SelectMultiple(), required=False, choices=FAVORITE_COLORS_CHOICES)
    favorite_colors = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, required=False,
                                                choices=FAVORITE_COLORS_CHOICES)


    # Widget - Radio Chocies Widget
    CHOICES = [('1', 'First'), ('2', 'Second')]
    choice_field = forms.ChoiceField(widget=forms.RadioSelect(), choices=CHOICES, required=False)

    # Widget - url
    url = forms.URLField(widget=forms.URLInput(attrs={'Placeholder':'Enter url'}), required=False)

    """
示例#27
0
class NewsForm(forms.ModelForm):
    publish_date = forms.DateField(widget=forms.SelectDateWidget())

    class Meta:
        model = NewsItem
        fields = ('title', 'description', 'image', 'publish_date')
    class Meta:
        model = Local
        fields = '__all__'

        widgets = {"fecha_alta": forms.SelectDateWidget()}
示例#29
0
class ReviewExpensesForm(forms.Form):
    user = forms.HiddenInput()
    from_date = forms.DateField(widget=forms.SelectDateWidget())
    to_date = forms.DateField(widget=forms.SelectDateWidget())
示例#30
0
class QuoteRequestForm(forms.ModelForm):
    name = forms.CharField(max_length=600,
                           required=True,
                           label='Please enter your full name')
    email = forms.EmailField(required=True, label='Enter your email')
    telephone = forms.CharField(required=False,
                                label='Contact telephone (optional)')

    date_trip = forms.DateField(required=True,
                                label='Estimated date of arrival?',
                                widget=forms.SelectDateWidget())
    party_size = forms.ChoiceField(
        required=True,
        label='How many people in your party?',
        choices=(('', '-- Please select --'), ('1', '1'), ('2', '2'), ('3',
                                                                       '3'),
                 ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8'),
                 ('9', '9'), ('10', '10'), ('11-15', '11-15'), ('15+', '15+')))
    days = forms.ChoiceField(required=True,
                             label='How long do you want to visit (days)?',
                             choices=(
                                 ('', '-- Please select --'),
                                 ('1', '1'),
                                 ('2', '2'),
                                 ('3', '3'),
                                 ('4', '4'),
                                 ('5', '5'),
                                 ('6', '6'),
                                 ('7', '7'),
                                 ('8', '8'),
                                 ('9', '9'),
                                 ('10', '10'),
                                 ('11', '11'),
                                 ('12', '12'),
                                 ('13', '13'),
                                 ('14', '14'),
                                 ('15', '15'),
                                 ('16', '16'),
                                 ('17', '17'),
                                 ('18', '18'),
                                 ('19', '19'),
                             ))
    country_indexes = forms.ModelMultipleChoiceField(
        label="Where do you want to visit?",
        required=True,
        widget=forms.CheckboxSelectMultiple(
            attrs={'class': 'country_indexes'}),
        queryset=CountryIndex.objects.all())

    #country = forms.ModelChoiceField(
    #    queryset=Country.objects.all().order_by('name'),
    #    required=False,
    #    widget=forms.Select(attrs={'class': "select2"}),
    #    label='What country are you from?')

    additional_information = forms.CharField(
        required=False,
        label=
        "Additional information (Are there any parks you want to see or do you have special requirements?)",
        widget=forms.Textarea(attrs={'rows': 3}))

    def clean_date_trip(self):
        date_trip = self.cleaned_data['date_trip']
        if date_trip <= datetime.date.today():
            raise forms.ValidationError(
                "Date of arrival must be in the future")
        return date_trip

    def __init__(self, *args, **kwargs):
        super(QuoteRequestForm, self).__init__(*args, **kwargs)
        self.fields['date_trip'].initial = add_months(datetime.datetime.now(),
                                                      1)

    class Meta:
        model = QuoteRequest
        fields = ('name', 'email', 'telephone', 'itinerary_type', 'date_trip',
                  'days', 'party_size', 'country_indexes', 'country',
                  'additional_information')