class AverageOnReturnBeliefForm(forms.ModelForm): answer = forms.IntegerField(widget=forms.NumberInput(attrs={'required': True}), min_value=0, max_value=Constants.endowment * Constants.coef, required=True)
class FormNuevoProductoLente(forms.Form): nombre_lente = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}), max_length=64, label="Nombre lente") precio_lente = forms.DecimalField(widget=forms.NumberInput(attrs={'class': 'form-control'}), decimal_places=2, max_digits=5, min_value=0) lejos_o_cerca = forms.ModelChoiceField(widget=forms.Select(attrs={'class': 'form-control'}), queryset = LejosCerca.objects.all()) izquierda_o_derecha = forms.ModelChoiceField(widget=forms.Select(attrs={'class': 'form-control'}), queryset=IzquierdaDerecha.objects.all()) armazon = forms.ModelChoiceField(widget=forms.Select(attrs={'class': 'form-control'}), queryset= Armazon.objects.all())
class QuantityForms(forms.Form): amount = forms.DecimalField(widget=forms.NumberInput( attrs={'placeholder': "Enter Quantity"}))
class signup_form(forms.Form): name = forms.CharField(widget=forms.TextInput(attrs={ "class": "form-control", "id": "defaultForm-name" })) branch = forms.CharField( widget=forms.Select(choices=CHOICES, attrs={ "class": "multiple", "id": "defaultForm-college" })) #branch=forms.CharField(widget=forms.TextInput(attrs={"class":"form-control","id":"defaultForm-branch"})) contact = forms.DecimalField(widget=forms.NumberInput( attrs={ "class": "form-control", "id": "defaultForm-year" })) year = forms.DecimalField( max_value=3, min_value=1, widget=forms.NumberInput(attrs={ "class": "form-control", "id": "defaultForm-year" })) college = forms.CharField(widget=forms.TextInput( attrs={ "class": "form-control", "id": "defaultForm-college" })) email = forms.EmailField(widget=forms.EmailInput( attrs={ "class": "form-control", "id": "defaultForm-email" })) password = forms.CharField( min_length=8, widget=forms.PasswordInput(attrs={ "class": "form-control", "id": "defaultForm-password" })) confirm_password = forms.CharField(widget=forms.PasswordInput( attrs={ "class": "form-control", "id": "defaultForm-confirm_pass" })) def clean_email(self): email = self.cleaned_data.get("email") qs = User.objects.filter(username=email) if qs.exists(): raise forms.ValidationError("Email Taken !") elif ("@" not in email) or (".com" not in email): raise forms.ValidationError("Please Enter a Valid Email !") return email # def clean(self): # data=self.cleaned_data # password=self.cleaned_data.get("password") # password1=self.cleaned_data.get("confirm_password") # if password1 != password: # raise forms.ValidationError("Password must Match !") # return data def clean_confirm_password(self): data = self.cleaned_data print(data) password = self.cleaned_data.get('password') password1 = self.cleaned_data.get('confirm_password') if password1 != password: raise forms.ValidationError("Password must Match !!") return data
class FormNuevoPedido(forms.Form): paciente = forms.ModelChoiceField(widget=forms.Select(attrs={'class': 'form-control'}), queryset = Paciente.objects.all()) producto = forms.ModelChoiceField(widget=forms.Select(attrs={'class': 'form-control'}), queryset = Producto.objects.all()) cantidad = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-control'}), label="Cantidad", min_value=0, max_value=100) tipo_de_pago = forms.ModelChoiceField(widget=forms.Select(attrs={'class': 'form-control'}), queryset = FormaDePago.objects.all())
class BaseSparkJobForm(FormControlFormMixin, CachedFileModelFormMixin, CreatedByModelFormMixin, forms.ModelForm): identifier = forms.RegexField( required=True, label='Job identifier', regex=r'^[\w-]{1,100}$', widget=forms.TextInput( attrs={ 'required': 'required', 'class': 'identifier-taken-check', 'data-identifier-taken-check-url': reverse_lazy('jobs-identifier-taken'), }), help_text='A brief description of the scheduled Spark job\'s purpose, ' 'visible in the AWS management console.') result_visibility = forms.ChoiceField( choices=models.SparkJob.RESULT_VISIBILITY_CHOICES, widget=forms.Select(attrs={ 'required': 'required', }), label='Job result visibility', help_text='Whether notebook results are uploaded to a public ' 'or private bucket', ) size = forms.IntegerField( required=True, min_value=1, max_value=settings.AWS_CONFIG['MAX_CLUSTER_SIZE'], label='Job cluster size', widget=forms.NumberInput( attrs={ 'required': 'required', 'min': '1', 'max': str(settings.AWS_CONFIG['MAX_CLUSTER_SIZE']), }), help_text='Number of workers to use when running the Spark job ' '(1 is recommended for testing or development).') interval_in_hours = forms.ChoiceField( choices=models.SparkJob.INTERVAL_CHOICES, widget=forms.Select(attrs={ 'required': 'required', }), label='Job interval', help_text='Interval at which the Spark job should be run', ) job_timeout = forms.IntegerField( required=True, min_value=1, max_value=24, label='Job timeout', widget=forms.NumberInput(attrs={ 'required': 'required', 'min': '1', 'max': '24', }), help_text='Number of hours that a single run of the job can run ' 'for before timing out and being terminated.') start_date = forms.DateTimeField( required=True, widget=forms.DateTimeInput(attrs={ 'class': 'datetimepicker', }), label='Job start date', help_text='Date and time on which to enable the scheduled Spark job.', ) end_date = forms.DateTimeField( required=False, widget=forms.DateTimeInput(attrs={ 'class': 'datetimepicker', }), label='Job end date (optional)', help_text='Date and time on which to disable the scheduled Spark job ' '- leave this blank if the job should not be disabled.', ) notebook = CachedFileField( required=True, widget=forms.FileInput(), # no need to specific required attr here label='Analysis Jupyter Notebook', help_text='A Jupyter/IPython Notebook has the file ' 'extension .ipynb.') class Meta: model = models.SparkJob fields = [ 'identifier', 'result_visibility', 'size', 'interval_in_hours', 'job_timeout', 'start_date', 'end_date' ] @property def field_order(self): """ Copy the defined model form fields and insert the notebook field at the second spot """ fields = self._meta.fields[:] fields.insert(1, 'notebook') return fields def clean_notebook(self): notebook_file = self.cleaned_data['notebook'] if notebook_file and not notebook_file.name.endswith(('.ipynb', )): raise forms.ValidationError('Only Jupyter/IPython Notebooks are ' 'allowed to be uploaded') return notebook_file def save(self, commit=True): # create the model without committing, since we haven't # set the required created_by field yet spark_job = super(BaseSparkJobForm, self).save(commit=False) # if notebook was specified, replace the current notebook if 'notebook' in self.changed_data: spark_job.notebook_s3_key = scheduling.spark_job_add( self.cleaned_data['identifier'], self.cleaned_data['notebook']) if commit: # actually save the scheduled Spark job, and return the model object spark_job.save() return spark_job
class Meta: model = Crecimiento fields=['peso',] labels={'peso':'Peso (kg):'} widgets={'peso':forms.NumberInput(attrs={'class':'form-control','min':'0000.00', 'placeholder':'0000,00 Kg'}),}
class RaceStteiForm(forms.Form): jockey_list = [[x.jockey, x.jockey] for x in RaceData.objects.all()] #リストの中の重複を削除 jockey_unique = [("", '指定なし><')] for x in jockey_list: if x not in jockey_unique: jockey_unique.append(x) # 開催日をリスト化 date_list = [[x.start_date, x.end_date] for x in RaceData.objects.all()] # リストの中の重複を削除 #デフォルト値としてdate_listの1番目を設定 #date_unique1 = [ (date_list[0][0], '指定なし><')] date_unique1 = [('2017-01-05 00:00:00', '指定なし><')] for x in date_list: if x not in date_unique1: date_unique1.append(x) #デフォルト値としてdate_listの最後を設定 date_unique2 = [('2017-12-28 00:00:00', '指定なし><')] for x in date_list: if x not in date_unique2: date_unique2.append(x) #距離のリスト化 distance_list = [[x.from_distance, x.to_distance] for x in RaceData.objects.all()] #昇順に並べ替え distance_list = sorted(distance_list) #リストの中の重複を削除 distance_unique1 = [(100, '指定なし><')] for x in distance_list: if x not in distance_unique1: distance_unique1.append(x) distance_unique2 = [(5000, '指定なし><')] for x in distance_list: if x not in distance_unique2: distance_unique2.append(x) ##### リスト化 # jockey_unique = self.jockey_unique # date_unique1 = self.date_unique1 # date_unique2 = self.date_unique2 # distance_unique1 = self.distance_unique1 # distance_unique2 = self.distance_unique2 FOOD_CHOICES = [("中山", "中山"), ("東京", "東京"), ("新潟", "新潟"), ("福島", "福島")] alllist = [("全て", "全て")] ninki_list =[("",""),("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") ] racetype_list = [("芝", "芝"), ("ダ", "ダ"), ("障", "障")] #####入力フィールドの作成 # race_place = forms.ChoiceField( # label='開催場', # widget=forms.CheckboxSelectMultiple, # choices=FOOD_CHOICES, # required=True, # ) # race_place = forms.CharField(label='開催場所', required=False) all_place = forms.ChoiceField(label='開催日全て', widget=forms.CheckboxSelectMultiple, choices=alllist, required=False) race_place = forms.MultipleChoiceField( label='開催場所', widget=forms.CheckboxSelectMultiple(attrs={"checked": ""}), choices=FOOD_CHOICES, required=True, ) start_date = forms.ChoiceField(label='開催日(始)', choices=date_unique1, required=False) end_date = forms.ChoiceField(label='開催日(終)', choices=date_unique2, required=False) # howmany_race = forms.IntegerField(label='開催日から何レース分',required=False,min_value=0) # race_type =forms.ChoiceField(label='芝かダートか障害か',choices=racetype_list,required=False) race_type = forms.MultipleChoiceField( label='芝かダートか障害か', widget=forms.CheckboxSelectMultiple(attrs={"checked": ""}), choices=racetype_list, required=True, ) from_distance = forms.ChoiceField(label='距離(min)', choices=distance_unique1, required=False) to_distance = forms.ChoiceField(label='距離(max)', choices=distance_unique2, required=False) number_horse_min = forms.IntegerField(label='出走馬数(min)', required=False, min_value=0, max_value=18, initial=10) number_horse_max = forms.IntegerField(label='出走馬数(max)', required=False, min_value=0, max_value=18, initial=18) win_ninki = forms.ChoiceField(label='人気馬', choices=ninki_list, required=False, initial=1) target_jockey = forms.ChoiceField(label='騎手', choices=jockey_unique, required=False) odds_minimum = forms.FloatField( label='オッズ(下限)', required=False, widget=forms.NumberInput(attrs={'step': '0.1'})) odds_max = forms.FloatField( label='オッズ(上限)', required=False, widget=forms.NumberInput(attrs={'step': '0.1'}))
class ComprobanteForm(ConditionalValidateForm): class Meta: model = Comprobante fields = ("id", 'empresa', 'punto_vta', 'concepto', 'tipo_cbte', 'condicion_venta', 'condicion_venta_texto', 'remito_nro', 'cbte_asoc', 'fecha_pago', 'fecha_emision', 'fecha_venc_pago', 'cliente', 'tipo_expo', 'moneda', 'idioma', 'incoterms', 'pais_destino', 'id_impositivo', 'moneda_ctz', 'forma_pago', 'observaciones', 'observaciones_comerciales', 'incoterms_ds', 'descuento', 'importe_total') widgets = {'empresa': HiddenInput} def clean_fecha_venc_pago(self): fecha_emision = self.cleaned_data.get("fecha_emision") fecha_venc_pago = self.cleaned_data.get("fecha_venc_pago") if fecha_venc_pago < fecha_emision: self.add_error( "fecha_venc_pago", "La fecha de vencimiento de pago debe ser mayor a la fecha de emisión del comprobante." ) raise forms.ValidationError( "La fecha de vencimiento de pago debe ser mayor a la fecha de emisión del comprobante." ) return fecha_venc_pago def clean(self): cleaned_data = super(ComprobanteForm, self).clean() if cleaned_data.get("tipo_cbte").id_afip == 19: self.validate_required_field(cleaned_data, 'tipo_expo') self.validate_required_field(cleaned_data, 'moneda') self.validate_required_field(cleaned_data, 'moneda_ctz') self.validate_required_field(cleaned_data, 'idioma') self.validate_required_field(cleaned_data, 'pais_destino') if cleaned_data.get("pais_destino") is None: self.validate_required_field(cleaned_data, 'id_impositivo') if cleaned_data.get("tipo_cbte").id_afip in (TipoComprobante.NC_E, TipoComprobante.ND_E): self.validate_required_field(cleaned_data, 'cbte_asoc') if cleaned_data.get("tipo_cbte").id_afip == TipoComprobante.FACTURA_E: self.validate_required_field(cleaned_data, 'fecha_pago') dto = cleaned_data.get("descuento") if dto: if dto < 0 or dto > 100: self.add_error( "descuento", "El descuento a aplicar por porcentaje debe ser mayor a 0 (cero) y menor a 100 (cien)." ) raise forms.ValidationError( "El descuento a aplicar por porcentaje debe ser mayor a 0 (cero) y menor a 100 (cien)." ) if "descuento" in self.errors: del self.errors["descuento"] return cleaned_data def clean_cbte_asoc(self): cbte_asoc = self.cleaned_data['cbte_asoc'] tipo_cbte = self.cleaned_data.get("tipo_cbte").id_afip if tipo_cbte in (TipoComprobante.NC_E, TipoComprobante.ND_E): if not cbte_asoc: error = "Debe informar un comprobante asociado" self.add_error("cbte_asoc", error) else: try: cbte = Comprobante.objects.get(pk=cbte_asoc.id) if cbte.tipo_cbte.id_afip != TipoComprobante.FACTURA_E: error = "El comprobante elegido no es una factura de exportacion" self.add_error("cbte_asoc", error) if not cbte.cae: error = "El comprobante elegido no esta autorizado" self.add_error("cbte_asoc", error) except Comprobante.DoesNotExist: error_log = "Error al consultar comprobante asociado:{}-{}-{}".format( cbte_asoc.tipo_cbte.nombre, cbte_asoc.tipo_cbte.letra, cbte_asoc.nro) logger.error(error_log) error = "Hubo un error al querer validar el comprobante asociado" self.add_error("cbte_asoc", error) return cbte_asoc def clean_fecha_pago(self): fecha_pago = self.cleaned_data['fecha_pago'] tipo_cbte = self.cleaned_data.get("tipo_cbte").id_afip if tipo_cbte == TipoComprobante.FACTURA_E: if not fecha_pago: error = "Debe informar una fecha de pago" self.add_error("fecha_pago", error) else: if fecha_pago < datetime.date.today(): error = "La fecha de pago debe ser mayor o igual a hoy" self.add_error("fecha_pago", error) return fecha_pago tipo_cbte = forms.ModelChoiceField(queryset=TipoComprobante.objects.none()) importe_total = forms.DecimalField(max_digits=19, decimal_places=4) descuento = forms.DecimalField(widget=forms.NumberInput( attrs={ 'placeholder': 'Inserte un porcentaje', 'class': 'form-control', 'min': '0', 'max': '100' }), required=False) # Muestro solo facturas E autorizadas, es decir con cae != '' cbte_asoc = forms.ModelChoiceField(queryset=Comprobante.objects.filter( tipo_cbte=TipoComprobante.FACTURA_E_PK).exclude(cae=''), required=False, label="Factura asociada", empty_label="Ingrese numero") def __init__(self, *args, **kwargs): empresa = Empresa.objects.first() super(ComprobanteForm, self).__init__(*args, **kwargs) self.fields['cliente'].empty_label = "" self.fields['concepto'].initial = empresa.concepto self.fields['punto_vta'].queryset = PuntoDeVenta.objects.filter( activo=True) # self.fields['punto_vta'].queryset = PuntoDeVenta.objects.all() # self.fields['cliente'].queryset = Cliente.objects.all() self.fields['cliente'].queryset = Cliente.objects.filter(activo=True) self.fields['tipo_cbte'].initial = empresa.tipos_cbte.first() self.fields['tipo_cbte'].queryset = empresa.tipos_cbte.all() self.fields['cbte_asoc'].queryset = Comprobante.objects.filter( tipo_cbte=TipoComprobante.FACTURA_E_PK)
class AddSchedule(forms.Form): """ The form is used to placement or pbi schedule. @variables: time - time of placement activity ctc - salary company_name - name of company placement_type - placement type (placement/pbi) location - location of company description - description of company placement_date - date of placement activity """ time = forms.TimeField( label='time', widget=forms.widgets.TimeInput(attrs={ 'type': "time", 'value': "00:00", 'min': "0:00", 'max': "24:00" })) ctc = forms.DecimalField(label="ctc", widget=forms.NumberInput(attrs={'min': 0})) company_name = forms.CharField(widget=forms.TextInput( attrs={ 'max_length': 100, 'class': 'field', 'list': 'company_dropdown1', 'id': 'company_input' }), label="company_name") placement_type = forms.ChoiceField( widget=forms.Select(attrs={'style': "height:45px"}), label="placement_type", choices=Constants.PLACEMENT_TYPE) location = forms.CharField(widget=forms.TextInput(attrs={ 'max_length': 100, 'class': 'field' }), label="location") description = forms.CharField(widget=forms.Textarea(attrs={ 'max_length': 1000, 'class': 'form-control' }), label="description", required=False) attached_file = forms.FileField(required=False) placement_date = forms.DateField( label='placement_date', widget=forms.DateInput(attrs={'class': 'datepicker'})) def clean_ctc(self): ctc = self.cleaned_data['ctc'] # print('form validation \n\n\n\n', ctc) if ctc <= 0: raise forms.ValidationError("CTC must be positive value") return ctc def clean_company_name(self): company_name = self.cleaned_data['company_name'] # print('form validation \n\n\n\n', ctc) if NotifyStudent.objects.filter(company_name=company_name): raise forms.ValidationError("company_name must be unique") return company_name
class LogicForm(forms.Form): # #各種リストの作成 logic_list = [[x.id, x.id] for x in Logic.objects.all()] # logiclist = forms.ChoiceField(label='ロジックリスト', choices=logic_list,required=False) # ninki_or_jockey = [('人気','人気'),('ジョッキー','ジョッキー')] betway_list = [ ('マーチンゲール', 'マーチンゲール '), ('利益率確定法', '利益率確定法'), # ('ダランベール','ダランベール'), # ('ピラミッド','ピラミッド'), # ('ココモ法','ココモ法'), # ('オスカーズグラインド法','オスカーズグラインド法'), # ('ウィナーズ投資法(◯回連続連敗でスタート','ウィナーズ投資法(◯回連続連敗でスタート'), # ('1235法(グッドマン法)','1235法(グッドマン法)'), # ('31法','31法'), # ('ラフィーネ法','ラフィーネ法'), # ('モンテカルロ法','モンテカルロ法'), # ('進化版・数列投資法','進化版・数列投資法'), # ('単位資金配分法','単位資金配分法'), # ('前回投資額の〇倍','前回投資額の〇倍'), # ('目標純利益確定法','目標純利益確定法'), ] # fix_or_variable_list = [('fix', '固定'),('variable', '変動')] select_or_manual_list = [('select', '選択'), ('manual', 'マニュアル')] ninki_list =[("",""),("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") ] # jockey_list = [[x.jockey, x.jockey] for x in RaceData.objects.all()] #リストの中の重複を削除 # jockey_unique = [ ("", '指定なし><')] # for x in jockey_list: # if x not in jockey_unique: # jockey_unique.append(x) # 開催日をリスト化 # race_list = [[x.id, x.id] for x in TargetRaceID.objects.all()] race_list = [] count = 0 for x in TargetRaceID.objects.all(): #仮のレースIDを連番でふって表示し、本物のIDを紐付ける count += 1 race_list.append([x.id, count]) target_race = forms.ChoiceField(label='ターゲットレース', choices=race_list, required=False) # if logiclist != "": # obj =Logic.objects.get(id=logiclist) # budget = obj.budget # else: # budget = forms.IntegerField(label='予算',widget=forms.NumberInput(attrs={'step':'100','min':'100'}),required=True,initial=20000) budget = forms.IntegerField(label='予算', widget=forms.NumberInput(attrs={ 'step': '100', 'min': '100' }), required=True, initial=20000) initial_bet = forms.IntegerField(label='初回ベット金額', widget=forms.NumberInput(attrs={ 'step': '100', 'min': '100' }), required=True, initial=100) #ベット方法から選択するか、マニュアルかの選択 # select_or_manual = forms.ChoiceField(label='ベット方法選択かマニュアルか',widget=forms.RadioSelect,choices=select_or_manual_list,required=True,initial='select') bet_way = forms.ChoiceField(label='ベット方法選択', widget=forms.RadioSelect, choices=betway_list, required=False) #定額か変動額かの選択 # fix_or_variable = forms.ChoiceField(label='定額か変動か',widget=forms.RadioSelect(attrs = { 'onclick' : "hihyoji();"}),choices=fix_or_variable_list,required=True,initial='fix') # fix_or_variable = forms.ChoiceField(label='定額か変動か',widget=forms.RadioSelect,choices=fix_or_variable_list,required=True,initial='fix') # fix_bet = forms.IntegerField(label='定額',required=False,widget=forms.NumberInput(attrs={'step':'100','min':'100'})) # nanbai = forms.FloatField(label='直近ベットの何倍',required=False,widget=forms.NumberInput(attrs={'step':'0.1'})) margin = forms.FloatField(label='マージン(総ベット金額の何倍の利益を得たいか)', required=False, widget=forms.NumberInput(attrs={'step': '0.1'}), initial='1.2') # reset_when_hit = forms.BooleanField(label='的中でベット金額リセットするか',required=False,initial='false') lost_bet_reset = forms.IntegerField(label='ベット額リセット条件(連続不的中数上限)', required=False, min_value=0) #的中ではなく一着であることに注意 win_bet_reset = forms.IntegerField(label='ベット額連続1着リセット', required=False, min_value=0) stopbet_bylost = forms.IntegerField(label='ストップ条件・損失額上限', required=False, min_value=0) stopbet_bymaxbet = forms.IntegerField(label='ストップ条件・次回ベット金額上限', required=False, initial=10000) # stop_when_hit = forms.BooleanField(label='的中でストップするか',required=False) stop_bymaxprofit = forms.IntegerField(label='ストップ条件・合計利益上限', required=False, initial=10000) #対象買い目の選択 # win_bet_select = forms.ChoiceField(label='単勝購入ターゲット',widget=forms.RadioSelect,choices=ninki_or_jockey,required=False,initial="人気") target_ninki = forms.ChoiceField(label='人気馬', choices=ninki_list, required=False) # target_jockey = forms.ChoiceField(label='騎手', choices=jockey_unique,required=False) odds_minimum = forms.FloatField( label='オッズ(下限)', required=False, widget=forms.NumberInput(attrs={'step': '0.1'})) odds_max = forms.FloatField( label='オッズ(上限)', required=False, widget=forms.NumberInput(attrs={'step': '0.1'})) # countdown_select = forms.ChoiceField(label='カウントダウン対象',widget=forms.RadioSelect,choices=ninki_or_jockey,required=False,initial="人気") countdown_ninki = forms.IntegerField(label='カウントダウン対象人気', required=False, min_value=0) # countdown_jockey = forms.ChoiceField(label='カウントダウン騎手', choices=jockey_unique,required=False) start_bet_ninki = forms.IntegerField(label='着外カウントダウン', required=False, min_value=0, initial=1) # start_bet_jockey = forms.IntegerField(label='騎手着外カウントダウン',required=False,min_value=0) target_place = forms.IntegerField(label='対象着', required=False, min_value=1, initial=1)
class SearchStudentRecord(forms.Form): """ The form is used to search from the student record based of various parameters. @variables: name - name of the student rollno - roll no of student programme - programme of student department - department of student cpi - cpi of student skill - skill of student debar - debarred or not debarred placed_type - type of placement """ name = forms.CharField(widget=forms.TextInput(attrs={ 'max_length': 100, 'class': 'field' }), label="name", required=False) rollno = forms.IntegerField(label="rollno", widget=forms.NumberInput(attrs={'min': 0}), required=False) programme = forms.ChoiceField(choices=Con.PROGRAMME, required=False, label="programme", widget=forms.Select( attrs={ 'style': "height:45px", 'onchange': "changeDeptForSearch()", 'id': "id_programme_search" })) dep_btech = forms.MultipleChoiceField(choices=Constants.BTECH_DEP, required=False, label="department", widget=forms.CheckboxSelectMultiple) dep_bdes = forms.MultipleChoiceField(choices=Constants.BDES_DEP, required=False, label="department", widget=forms.CheckboxSelectMultiple) dep_mtech = forms.MultipleChoiceField(choices=Constants.MTECH_DEP, required=False, label="department", widget=forms.CheckboxSelectMultiple) dep_mdes = forms.MultipleChoiceField(choices=Constants.MDES_DEP, required=False, label="department", widget=forms.CheckboxSelectMultiple) dep_phd = forms.MultipleChoiceField(choices=Constants.PHD_DEP, required=False, label="department", widget=forms.CheckboxSelectMultiple) cpi = forms.DecimalField(label="cpi", required=False) skill = forms.ModelMultipleChoiceField(required=False, widget=forms.SelectMultiple(), queryset=Skill.objects.all(), label="skill") debar = forms.ChoiceField( widget=forms.Select(attrs={'style': "height:45px"}), label="debar", required=False, choices=Constants.DEBAR_TYPE) placed_type = forms.ChoiceField( widget=forms.Select(attrs={'style': "height:45px"}), label="placed_type", required=False, choices=Constants.PLACED_TYPE)
class TaskForm(forms.ModelForm): """ Create new task object for with many settings for each field """ wbs_code = forms.CharField( label='WBS код', widget=forms.TextInput(attrs={'class': 'form-control'})) task_type = forms.ChoiceField( choices=TASK_TYPE, label='Тип', widget=forms.Select(attrs={'class': 'form-control'})) name = forms.CharField( label='Название', widget=forms.TextInput(attrs={'class': 'form-control'})) description = forms.CharField(label='Описание', required=False, widget=forms.Textarea(attrs={ 'class': 'form-control', 'rows': 3 })) start_date = forms.DateField( label='Дата начала', required=False, widget=forms.DateInput(attrs={'class': 'datepicker form-control'})) duration = DurationDayFiled( required=False, label='Продолжительность', widget=DurationInput(attrs={'class': 'form-control'})) end_date = forms.DateField( label='Дата завершения', required=False, widget=forms.DateInput(attrs={'class': 'datepicker form-control'})) responsible = forms.ModelChoiceField( label='Исполнитель', queryset=User.objects.all(), required=False, widget=forms.Select(attrs={'class': 'form-control'})) status = forms.ChoiceField( choices=STATUS, label='Статус', widget=forms.Select(attrs={'class': 'form-control'})) percent_complete = forms.IntegerField( label='% выполнения', required=False, min_value=0, max_value=100, widget=forms.NumberInput(attrs={ 'class': 'form-control', 'type': 'number' })) project = forms.ModelChoiceField( label='Проект', queryset=Project.objects.all(), required=False, widget=forms.Select(attrs={'class': 'form-control'})) optimistic_price = forms.FloatField( label='Оптимистичная стоимость', required=False, widget=forms.NumberInput(attrs={ 'class': 'form-control', 'type': 'number' })) realistic_price = forms.FloatField( label='Реалистичная стоимость', required=False, widget=forms.NumberInput(attrs={ 'class': 'form-control', 'type': 'number' })) pessimistic_price = forms.FloatField( label='Пессимистичная стоимость', required=False, widget=forms.NumberInput(attrs={ 'class': 'form-control', 'type': 'number' })) class Meta: model = Task fields = [ 'wbs_code', 'task_type', 'name', 'description', 'start_date', 'duration', 'end_date', 'responsible', 'status', 'percent_complete', 'project', 'optimistic_price', 'realistic_price', 'pessimistic_price' ]
class AverageOnSendBeliefForm(forms.ModelForm): answer = forms.IntegerField(widget=forms.NumberInput(attrs={'required': True}), min_value=0, max_value=100, required=True)
class Meta: model = Carrera fields = [ "localidad_edit", "nombre_edit", "descripcion_edit", "tipo_carrera_edit", # "ieu_acreditadora_edit", "mercado_ocupacional_edit", "area_conocimiento_edit", "sub_area_conocimiento_edit", "periodicidad_edit", # "ieu_acreditadora_edit", "prioritaria_edit", "cod_activacion", "publicar", "editor", ] labels = { "localidad_edit": ("Localidad"), "nombre_edit": ("Nombre"), "descripcion_edit": ("Descripción"), "tipo_carrera_edit": ("Tipo de Programa"), # "ieu_acreditadora_edit": ("Institución Acreditadora"), "mercado_ocupacional_edit": ("Mercado Ocupacional"), "area_conocimiento_edit": ("Área de Conocimiento"), "sub_area_conocimiento_edit": ("Sub Área de Conocimiento"), "duracion_edit": ("Duración"), "periodicidad_edit": ("Periodicidad"), "prioritaria_edit": ("Prioritaria"), } widgets = { "localidad_edit": forms.Select( attrs={ "class": "form-control select2", "style": "width:100%", "data-placeholder": "Localidad...", }), "nombre_edit": forms.TextInput(attrs={ "style": "text-transform:uppercase;", "class": "form-control", "placeholder": "Escribe el nombre de la Carrera", }, ), "descripcion_edit": CKEditorWidget(attrs={ "class": "form-control", "placeholder": "Descripción de la carrera", "rows": 2, }, ), "tipo_carrera_edit": forms.Select( attrs={ "class": "form-control select2", "style": "width:100%", "data-placeholder": "Tipo de Programa...", }), # "ieu_acreditadora_edit": autocomplete.ModelSelect2( # url="oeuacademic:acreditadora", # attrs={ # "class": "form-control", # "data-placeholder": "Institución Acreditadora", # }, # ), "mercado_ocupacional_edit": CKEditorWidget(), "area_conocimiento_edit": forms.Select( attrs={ "class": "form-control select2", "style": "width:100%", "data-placeholder": "Área de Conocimiento...", }), "sub_area_conocimiento_edit": forms.Select( attrs={ "class": "form-control select2", "style": "width:100%", "data-placeholder": "Sub Área de Conocimiento...", }), "periodicidad_edit": forms.Select( attrs={ "class": "form-control select2", "style": "width:100%", "data-placeholder": "Periodicidad...", }), "cine_f_campo_amplio_edit": autocomplete.ModelSelect2( url="oeuacademic:cine-f-campo-amplio", attrs={ "class": "form-control", "data-placeholder": "a Opción" }, ), "cine_f_campo_especifico_edit": autocomplete.ModelSelect2( url="oeuacademic:cine-f-campo-especifico", forward=["cine_f_campo_amplio_edit"], attrs={ "class": "form-control", "data-placeholder": "a Opción" }, ), "cine_f_campo_detallado_edit": autocomplete.ModelSelect2( url="oeuacademic:cine-f-campo-detallado", forward=["cine_f_campo_especifico_edit"], attrs={ "class": "form-control", "data-placeholder": "a Opción" }, ), "duracion_edit": forms.NumberInput(attrs={"class": "form-control"}, ), "prioritaria_edit": forms.CheckboxInput(), "cod_activacion": forms.RadioSelect(), }
class Meta: model = Colaborator exclude = [ 'group', 'status', 'member_type', 'cr_member', 'registration_date', 'cyclos_user', 'bonus_percent_entity', 'bonus_percent_general', 'max_percent_payment', ] widgets = { 'contact_person': forms.TextInput(), 'address': forms.Textarea(attrs={'rows': 3}), 'public_address': forms.Textarea(attrs={'rows': 3}), 'short_description': forms.Textarea(attrs={'rows': 3}), 'latitude': forms.NumberInput(attrs={'readonly': False}), 'longitude': forms.NumberInput(attrs={'readonly': False}), 'networking': forms.Textarea(attrs={'rows': 4}), 'num_workers_male_partners': forms.NumberInput(attrs={'min': 0}), 'num_workers_female_partners': forms.NumberInput(attrs={'min': 0}), 'num_workers_male_non_partners': forms.NumberInput(attrs={'min': 0}), 'num_workers_female_non_partners': forms.NumberInput(attrs={'min': 0}), } # Overriding __init__ here allows us to provide initial data for permissions def __init__(self, *args, **kwargs): # Only in case we build the form from an instance # (otherwise, 'toppings' list should be empty) if kwargs.get('instance'): initial = kwargs.setdefault('initial', {}) # The widget for a ModelMultipleChoiceField expects # a list of primary key for the selected data. initial['categories'] = [ t.pk for t in kwargs['instance'].categories.all() ] forms.ModelForm.__init__(self, *args, **kwargs) def save(self, commit=True): is_new = self.instance.pk is None instance = forms.ModelForm.save(self, False) instance.member_type = MEMBER_COLAB if not instance.public_address or instance.public_address == '': instance.public_address = instance.address # Prepare a 'save_m2m' method for the form, old_save_m2m = self.save_m2m def save_m2m(): old_save_m2m() # This is where we actually link the permissions to the group instance.categories.clear() instance.categories.add(*self.cleaned_data['categories']) self.save_m2m = save_m2m # Do we need to save all changes now? if commit: instance.save() self.save_m2m() return instance
class Meta: model = TeamMember exclude = ('totalAttendances', ) labels = {'idTeam': ''} widgets = {'idTeam': forms.NumberInput(attrs={'hidden': True})}
class SupplierInvoicePartsInline(admin.TabularInline): template = 'admin/sup_invoices/supplierinvoice/edit_inline/tabular.html' verbose_name_plural = 'parts' #model = SupplierInvoiceParts model = SupplierInvoice.purchased_parts.through fields = ('part','quantity','returnedqty','list_price','cost','is_promo','package_size',) exclude = ['retqty'] readonly_fields = ['returnedqty',] #extra = 0 autocomplete_fields = ('part',) formset = SupplierInvoicePartsInlineFormSet form = SupplierPartsInvoiceFormParam(request) #def unit(self,obj): # #return format_html('lol') # return format_html('<span class="unit_tag"></span>') formfield_overrides = { models.FloatField: {'widget': forms.NumberInput(attrs={'size':10})}, models.PositiveIntegerField: {'widget': forms.NumberInput(attrs={'size':10})}, models.DecimalField: {'widget': forms.NumberInput(attrs={'size':10})}, } def get_formset(self, request, obj=None, **kwargs): #print('hehe') #print(request) idcontext = request.GET.get('id') #print(obj) if obj and obj.is_return: #print('ye') self.fields = ('part','quantity','returnedqty','retqty','list_price','cost','is_promo','package_size',) self.exclude = [] #self.readonly_fields = ['part','returnedqty','quantity','list_price','cost','is_promo','package_size',] self.readonly_fields = [] #self.extra = 0 self.max_num = obj.purchased_parts.all().count() self.min_num = self.max_num self.can_delete = False #widget = form.base_fields['part'].widget #widget.can_add_related = False #widget.can_change_related = False elif obj and not obj.is_return: self.fields = ('part','quantity','returnedqty','list_price','cost','is_promo','package_size',) self.exclude = ['retqty'] self.readonly_fields = ['returnedqty',] #self.extra = 0 elif idcontext != None: self.fields = ('part','quantity','returnedqty','retqty','list_price','cost','is_promo','package_size',) self.readonly_fields = [] self.exclude = [] #self.extra = 0 self.can_delete = False #widget = form.base_fields['part'].widget #widget.can_add_related = False #widget.can_change_related = False try: supplierinvoice = SupplierInvoice.objects.get(id=idcontext) self.max_num = supplierinvoice.purchased_parts.all().count() self.min_num = self.max_num except: pass formset = super(SupplierInvoicePartsInline, self).get_formset(request, obj, **kwargs) formset.request = request form = formset.form return formset #return super(SupplierInvoicePartsInline, self).get_formset(request, obj, **kwargs) def get_extra(self, request, obj=None, **kwargs): extra = super(SupplierInvoicePartsInline, self).get_extra(request, obj, **kwargs) idcontext = request.GET.get('id') #print(idcontext) extra = 0 if idcontext == None and not obj: extra = 1 #try: # supplierinvoice = SupplierInvoice.objects.get(id=idcontext) # extra = supplierinvoice.purchased_parts.all().count() #except: # extra = 0 #else: # extra = 0 return extra
def prepare_number(self, field): field_attrs = field.build_field_attrs() widget_attrs = field.build_widget_attrs() field_attrs.update({'widget': forms.NumberInput(attrs=widget_attrs)}) return forms.IntegerField(**field_attrs)
class UploadListing(forms.Form): title = forms.CharField(required=True, widget=forms.TextInput()) description = forms.CharField( required=True, widget=forms.Textarea( attrs={'placeholder': 'Enter description here.'})) price = forms.CharField(required=True, widget=forms.NumberInput()) tags = forms.CharField(required=True, widget=forms.TextInput()) duration = forms.ChoiceField(widget=forms.Select(), choices=DURATION) cover = forms.CharField(required=False, widget=forms.HiddenInput(), initial=0) class Meta: model = Listing def __init__(self, *args, **kwargs): self.request = kwargs.pop('request', None) super(UploadListing, self).__init__(*args, **kwargs) def clean_price(self): data = self.cleaned_data price = data['price'] if not (len(price) in range(5) and price.isdigit()): raise forms.ValidationError('Please enter a valid price.') return price def clean_cover(self): data = self.cleaned_data cover = data['cover'] pictures = self.request.POST.getlist('files') if not pictures: raise forms.ValidationError('Please upload a valid images.') return cover def save(self, artist, FILES): data = self.cleaned_data artist_id = str(artist.id) pictures = FILES.getlist('files') hash_name = ''.join( random.choice(string.ascii_lowercase + string.digits) for x in range(6)) for index, picture in enumerate(pictures): dataUrlPattern = re.compile('data:image/(png|jpeg);base64,(.*)$') my_file = dataUrlPattern.match(picture).group(2) path = MEDIA_URL + 'artists/' + artist_id + '/listings/' + hash_name + '/' if index == int(data["cover"]): full_path = MEDIA_ROOT + 'artists/' + artist_id + '/listings/' + hash_name + '/' + str( index) + '.jpeg' cover = full_path else: full_path = MEDIA_ROOT + 'artists/' + artist_id + '/listings/' + hash_name + '/' + str( index) + '.jpeg' #if the folder doesn't exist, create one d = os.path.dirname(full_path) if not os.path.exists(d): os.makedirs(d) im = Image.open(BytesIO(base64.b64decode(my_file.encode('ascii')))) im.save(full_path, 'JPEG') listing = Listing.objects.create( artist=artist, picture=path, title=data['title'], description=data['description'], picture_cover=cover, price=data['price'], metadata=hash_name, duration=int(data['duration']), ) tags = data['tags'].split(',') tags.append(artist.get_style()) for tag in tags: tag = tag.lower() current_tag = get_object_or_None(Tags, tag=tag) if not current_tag: current_tag = Tags.objects.create(tag=tag) ListingTags.objects.create(listing=listing, tags=current_tag) listing.save() return listing
class Meta: model=Produccion fields=['volumen',] labels={'volumen':'Volumen (l)'} widgets={'volumen':forms.NumberInput(attrs={'class':'form-control','min':'0', 'placeholder':'50 lt'}),}
class Meta: model = Setting fields = ['price'] widgets = { 'price': forms.NumberInput(attrs={'class': 'form-control'}), }
class ContactForm(forms.Form): name = forms.CharField( label='Name', widget=forms.TextInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter name' } ), required=True ) mobile = forms.IntegerField( label='Mobile number', widget=forms.NumberInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter Mobile number' } ), required=True, min_value=10 ) email = forms.EmailField( label='Email address', widget=forms.EmailInput( attrs={ 'class': 'form-control', 'placeholder': 'Enter email' } ), required=True ) COURSE_CHOICES = ( ('py', 'Python'), ('dj', 'Django'), ('ui', 'UI'), ('rest', 'REST API') ) courses = MultiSelectFormField(choices=COURSE_CHOICES, required=True) SHIFT_CHOICES = ( ('mng', 'Morning'), ('aftn', 'Afternoon'), ('evng', 'Evening'), ('ngt', 'Night') ) shifts = MultiSelectFormField(choices=SHIFT_CHOICES, required=True) LOCATION_CHOICES = ( ('hyd', 'Hyderabad'), ('bang', 'Banglore'), ('chen', 'Chennai'), ('pune', 'Pune') ) locations = MultiSelectFormField(choices=LOCATION_CHOICES, required=True) GENDER_CHOICES = ( ('male', 'male'), ('female', 'female') ) gender = forms.ChoiceField(widget=forms.RadioSelect, choices=GENDER_CHOICES) y = range(2019, 1960, -1) start_date = forms.DateField(widget=forms.SelectDateWidget(years=y))
class Student_Registration(forms.Form): CLASS = [ ('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8'), ('9', '9'), ('10', '10'), ('11', '11'), ('12', '12'), ] username = forms.CharField(widget=forms.TextInput( attrs={'class': 'form-control'})) first_name = forms.CharField(widget=forms.TextInput( attrs={'class': 'form-control'})) last_name = forms.CharField(widget=forms.TextInput( attrs={'class': 'form-control'})) student_class = forms.CharField(widget=forms.NumberInput( attrs={'class': 'form-control'})) student_id = forms.CharField(widget=forms.NumberInput( attrs={ 'class': 'form-control', 'placeholder': 'See your I-Card' })) student_email = forms.CharField(widget=forms.EmailInput( attrs={ 'class': 'form-control', 'placeholder': '*****@*****.**' })) student_class = forms.ChoiceField( widget=forms.Select(attrs={'class': 'form-control'}), choices=CLASS) phone_number = forms.CharField( max_length="10", widget=forms.NumberInput(attrs={'class': 'form-control'})) student_password = forms.CharField(widget=forms.PasswordInput( attrs={'class': 'form-control'})) student_password2 = forms.CharField( label='Confirm Password', widget=forms.PasswordInput(attrs={'class': 'form-control'})) # check for username if it is smae give error def clean_username(self): username = self.cleaned_data.get("username") check_name = User.objects.filter(username=username) if check_name.exists(): raise forms.ValidationError("Username is taken think another one") return username # check for password does password1 is password2 or not def clean(self): data = self.cleaned_data password1 = self.cleaned_data.get('student_password') password2 = self.cleaned_data.get('student_password2') if password2 != password1: # we can use or too or len(password1) != 3 but it will confuse the user raise forms.ValidationError("password did't match") if len(password1) < 3: raise forms.ValidationError("Password must contain 3 letters") return data # check for studnet id it should be positive not negative def clean_student_id(self): student_id = self.cleaned_data.get("student_id") if int(student_id) <= 0: raise forms.ValidationError("Check your id") return student_id
class FormNuevoProducto(forms.Form): nombre_producto = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control'}), max_length=64) precio_producto = forms.DecimalField(widget=forms.NumberInput(attrs={'class': 'form-control'}), decimal_places=2, max_digits=5, min_value=0)
class EventForm(forms.ModelForm): location_lat = RoundingDecimalField( max_digits=9, decimal_places=6, widget=forms.NumberInput(attrs={ 'class': 'form-control', 'step': 'any' }), ) location_long = RoundingDecimalField( max_digits=9, decimal_places=6, widget=forms.NumberInput(attrs={ 'class': 'form-control', 'step': 'any' }), ) facebook_pages = forms.ModelMultipleChoiceField( queryset=FacebookPage.objects.all(), required=False, widget=SelectizeSelectMultiple()) twitter_hashtags = ModelMultipleChoiceImplicitCreationField( queryset=Hashtag.objects.all().order_by('hashtag_text'), prefix='__new_hashtag__', attr_name='hashtag_text', required=False) twitter_account_names = ModelMultipleChoiceImplicitCreationField( queryset=TwitterAccount.objects.all().order_by('name'), prefix='__new_account__', attr_name='name', required=False, ) class Meta: model = Event fields = ( 'active', 'counter_event', 'coverage', 'coverage_end', 'coverage_start', 'date', 'facebook_pages', 'internal_notes', 'location', 'location_lat', 'location_long', 'name', 'notes', 'organizer', 'participants', 'repetition_cycle', 'type', 'twitter_account_names', 'twitter_hashtags', 'url', 'time', ) widgets = { 'coverage_start': ClearableBootstrapDatePicker(), 'coverage_end': ClearableBootstrapDatePicker(), 'date': BootstrapDatePicker(), 'internal_notes': forms.Textarea(attrs={ 'class': 'form-control', 'rows': 5 }), 'location': forms.TextInput(attrs={'class': 'form-control'}), 'name': forms.TextInput(attrs={'class': 'form-control'}), 'notes': forms.Textarea(attrs={ 'class': 'form-control', 'rows': 10 }), 'participants': forms.TextInput(attrs={'class': 'form-control'}), 'organizer': forms.TextInput(attrs={'class': 'form-control'}), 'repetition_cycle': forms.TextInput(attrs={'class': 'form-control'}), 'time': ClearableBootstrapTimePicker(), 'type': forms.TextInput(attrs={'class': 'form-control'}), 'url': forms.URLInput(attrs={'class': 'form-control'}), } def __init__(self, *args, **kwargs): super(EventForm, self).__init__(*args, **kwargs) if self.instance.pk: self.initial[ 'facebook_pages'] = self.instance.facebook_pages.values_list( 'pk', flat=True) self.initial[ 'twitter_hashtags'] = self.instance.hashtags.values_list( 'pk', flat=True) self.initial[ 'twitter_account_names'] = self.instance.twitter_accounts.values_list( 'pk', flat=True) def clean(self): cleaned_data = super(EventForm, self).clean() coverage = cleaned_data.get('coverage') twitter_account_names = cleaned_data.get('twitter_account_names') coverage_start = cleaned_data.get('coverage_start') coverage_end = cleaned_data.get('coverage_end') # coverage dates must be in correct order if coverage_start is not None and coverage_end is not None: if coverage_end < coverage_start: msg = "'coverage_start' muss vor 'coverage_end' liegen" self.add_error('coverage_start', msg) self.add_error('coverage_end', msg) # for activating a coverage all required parameters must be set if coverage: msg = "Wird für eine Berichterstattung benötigt" errors = [] if coverage_start is None: errors.append(('coverage_start', msg)) if coverage_end is None: errors.append(('coverage_end', msg)) if twitter_account_names is None or len( twitter_account_names) == 0: errors.append(('twitter_account_names', msg)) if errors: for error in errors: self.add_error(*error) self.add_error( 'coverage', "Nicht alle benötigen Felder wurden ausgefüllt") def save(self, *args, **kwargs): instance = super(EventForm, self).save(*args, **kwargs) if instance.pk: instance.facebook_pages.clear() instance.facebook_pages.add(*self.cleaned_data['facebook_pages']) instance.hashtags.clear() instance.hashtags.add(*self.cleaned_data['twitter_hashtags']) instance.twitter_accounts.clear() instance.twitter_accounts.add( *self.cleaned_data['twitter_account_names']) return instance
class StockEntryProductForm(forms.Form): def __init__(self, *args, **kwargs): shop = kwargs.pop('shop') super(StockEntryProductForm, self).__init__(*args, **kwargs) product_choice = ([(None, 'Sélectionner un produit')] + [ (str(product.pk) + '/' + str(product.get_unit_display()), product.__str__()) for product in Product.objects.filter(shop=shop, is_removed=False) ]) self.fields['product'].choices = product_choice product = forms.ChoiceField(label='Produit', widget=forms.Select( attrs={ 'class': 'form-control selectpicker', 'data-live-search': 'True', 'required': 'required' })) quantity = forms.IntegerField( label='En vente', widget=forms.NumberInput( attrs={ 'class': 'form-control centered_input quantity', 'placeholder': 'Quantité', 'min': 1, 'required': 'required' }), required=False) unit_quantity = forms.ChoiceField( label='Unité quantité', choices=([('UNIT', 'produits'), ('CL', 'cl'), ('L', 'L'), ('G', 'g'), ('KG', 'kg')]), widget=forms.Select( attrs={ 'class': 'form-control selectpicker unit_quantity', 'required': 'required' }), required=False) amount = forms.DecimalField( label='Prix (€)', decimal_places=2, max_digits=9, widget=forms.NumberInput( attrs={ 'class': 'form-control centered_input amount', 'placeholder': 'Montant', 'min': 0, 'required': 'required' })) unit_amount = forms.ChoiceField( label='Unité montant', choices=([('UNIT', '€ / unité'), ('PACKAGE', '€ / lot'), ('L', '€ / L'), ('KG', '€ / kg')]), widget=forms.Select( attrs={ 'class': 'form-control selectpicker unit_amount', 'required': 'required' }), required=False) inventory_quantity = forms.IntegerField( label='Stocks restant', widget=forms.NumberInput( attrs={ 'class': 'form-control centered_input quantity', 'placeholder': 'Stocks rest.', 'min': 0 }), required=False) unit_inventory = forms.ChoiceField( label='Unité quantité', choices=([('UNIT', 'produits'), ('CL', 'cl'), ('L', 'L'), ('G', 'g'), ('KG', 'kg')]), widget=forms.Select( attrs={'class': 'form-control selectpicker unit_quantity'}), required=False) def clean(self): cleaned_data = super(StockEntryProductForm, self).clean()
form.fields[DELETION_FIELD_NAME].label = "" form.fields[DELETION_FIELD_NAME].widget = forms.HiddenInput( attrs={"value": "false"}, ) ############################################################################## """FormSet para asociar los titulos a los programas academicos de pregrado """ TITULO_FORMSET = inlineformset_factory( Carrera, CarreraTituloEdit, fields=["titulo", "duracion"], widgets={ "titulo": autocomplete.ModelSelect2( url="oeuacademic:titulo", attrs={ "class": "form-control formset-select2", "style": "width:100%", "data-placeholder": "Titulo de egreso", }, ), "duracion": forms.NumberInput(attrs={"class": "form-control"}, ), }, formset=BaseProductFormSet, extra=0, can_delete=True, )
class Nouvelle_Annonce_Form(forms.ModelForm): titre = forms.CharField(widget=forms.TextInput( attrs={ "type": "text", "size": "30", "maxlength": "50", "autofocus": "True", "required": "True" })) prix = forms.IntegerField(widget=forms.NumberInput( attrs={ "type": "number", "min": "0", "step": "1", "required": "True" })) description = forms.CharField(widget=forms.Textarea( attrs={ "id": "txt", "rows": "10", "cols": "100", "maxLength": "1500", "placeholder": "1500 caractères au max...", "onkeyup": "follow_textarea();", "required": "True" })) photo1 = forms.ImageField( required=True, widget=forms.FileInput(attrs={ "type": "file", "id": "small_in1", "onchange": "upload_pic(1);" })) photo2 = forms.ImageField( required=False, widget=forms.FileInput( attrs={ "type": "file", "id": "small_in2", "value": "{0}/none_image.png".format(settings.MEDIA_ROOT), "onchange": "upload_pic(2);" })) photo3 = forms.ImageField( required=False, widget=forms.FileInput(attrs={ "type": "file", "id": "small_in3", "onchange": "upload_pic(3);" })) photo4 = forms.ImageField( required=False, widget=forms.FileInput(attrs={ "type": "file", "id": "small_in4", "onchange": "upload_pic(4);" })) photo5 = forms.ImageField( required=False, widget=forms.FileInput(attrs={ "type": "file", "id": "small_in5", "onchange": "upload_pic(5);" })) class Meta: model = models.Produit fields = ["categorie"] widgets = { "categorie": forms.Select(attrs={ "id": "select_cat", "required": "True" }) } del_p2 = forms.IntegerField( required=True, max_value=1, min_value=0, widget=forms.NumberInput(attrs={"id": "del_p2"})) del_p3 = forms.IntegerField( required=True, max_value=1, min_value=0, widget=forms.NumberInput(attrs={"id": "del_p3"})) del_p4 = forms.IntegerField( required=True, max_value=1, min_value=0, widget=forms.NumberInput(attrs={"id": "del_p4"})) del_p5 = forms.IntegerField( required=True, max_value=1, min_value=0, widget=forms.NumberInput(attrs={"id": "del_p5"}))
class Meta: model = Fermentado fields = ['fecha_inicio', 'fecha_fin','hora_inicio', 'hora_fin', 'litros_entrada', 'litros_salida', 'produccion' ] labels = { 'fecha_inicio' :'Fecha de inicio', 'hora_inicio' :'Hora de inicio', 'fecha_fin' :'Fecha de fin', 'hora_fin' :'Hora de fin', 'litros_entrada' :'Litros de entrada', 'litros_salida':'Litros de salida', 'produccion':'Produccion' } widgets = { 'fecha_inicio': forms.DateInput( attrs= { 'placeholder':'Ingrese fecha de inicio del fermentado:', 'id':'datepickerFechaInicio', 'type':'text', 'class':'form-control', 'required':'true', 'name':'fecha_compra', 'autocomplete':'off' } ), 'fecha_fin': forms.DateInput( attrs= { 'placeholder':'Ingrese fecha de fin del fermentado:', 'id':'datepickerFechaFin', 'type':'text', 'class':'form-control', 'required':'true', 'name':'meeting-time', 'autocomplete':'off' } ), 'hora_inicio': forms.TimeInput( attrs= { 'placeholder':'Ingrese hora de inicio del fermentado:', 'type':'time', 'class':'form-control', 'required':'true', 'autocomplete':'off' } ), 'hora_fin': forms.TimeInput( attrs= { 'placeholder':'Ingrese hora de fin del fermentado:', 'type':'time', 'class':'form-control', 'required':'true', 'autocomplete':'off' } ), 'litros_entrada': forms.NumberInput( attrs= { 'placeholder':'Ingrese los litros de entrada:', 'id':'litros_entrada', 'class':'form-control', 'min':'1', 'type':'number' } ), 'litros_salida': forms.NumberInput( attrs= { 'placeholder':'Ingrese los litros de salida', 'id':'litros_salida', 'class':'form-control', 'min':'1', 'type':'number' } ), 'produccion': forms.Select( attrs= { 'placeholder':'Produccion', 'id':'produccion', 'class':'form-control', 'required':'true' } ) }