def __init__(self, *args, **kwargs): super(EmpleadosForm, self).__init__(*args, **kwargs) self.fields['nombre'].widget = forms.TextInput( attrs={'class': 'form-control m-input'}) self.fields['cedula'].widget = forms.TextInput( attrs={'class': 'form-control m-input'}) self.fields['telefono'].widget = forms.TextInput( attrs={'class': 'form-control m-input'}) self.fields['comision'].widget = forms.NumberInput( attrs={'class': 'form-control m-input'}) self.fields['fecha_nacimiento'] = forms.DateField( widget=DatePicker(attrs={'class': 'form-control m-input'}, options={ "format": "mm/dd/yyyy", "autoclose": True })) self.fields['fecha_ingreso'] = forms.DateField( widget=DatePicker(attrs={'class': 'form-control m-input'}, options={ "format": "mm/dd/yyyy", "autoclose": True }))
class ReportGenerationForm(forms.Form): report_type = forms.ChoiceField(choices=REPORT_CHOICES, widget=forms.HiddenInput(), required=True) start_date = forms.DateField( widget=DatePicker(options={ 'placeholder': 'YYYY-MM-DD', 'format': 'yyyy-mm-dd', 'autoclose': True }), required=False) end_date = forms.DateField( widget=DatePicker(options={ 'placeholder': 'YYYY-MM-DD', 'format': 'yyyy-mm-dd', 'autoclose': True }), required=False) email_to = SimpleArrayField(forms.EmailField(), required=True) email_from = forms.EmailField(widget=forms.EmailInput( attrs={'placeholder': 'Address the email is from'}), required=False) email_subject = forms.CharField( widget=forms.TextInput(attrs={'placeholder': 'Subject for email'}), required=False)
class VictimaForm(forms.ModelForm): fecha = forms.DateField(widget=DatePicker(options={ "format": "dd/mm/yyyy", "autoclose": True }), input_formats=['%d/%m/%Y']) fecha_nacimiento = forms.DateField( widget=DatePicker(options={ "format": "dd/mm/yyyy", "autoclose": True }), input_formats=['%d/%m/%Y']) #import pdb; pdb.set_trace() #def clean_fecha(self): # fecha = self.cleaned_data['date'] #if fecha < datetime.date.today(): #raise forms.ValidationError("The date cannot be in the past!") #return fecha class Meta: model = Victima fields = [ 'nombres', 'apellido', 'fecha', 'dni', 'nacionalidad', 'lugar_residencia', 'genero', 'fecha_nacimiento' ]
class SummaryDeliveryInstructionsJobForm(forms.Form): frmj = forms.DateField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True }), label='Start Date') toj = forms.DateField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True }), label="Final Date") commentj = forms.CharField(label="Comment")
class UserForm(forms.Form): keyword = forms.CharField(max_length=180) twitter = forms.BooleanField(required=False) reddit = forms.BooleanField(required=False) startdate = forms.DateTimeField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True })) enddate = forms.DateTimeField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True })) def clean(self): cleaned_data = super(UserForm, self).clean() ##print(cleaned_data) keyword = cleaned_data.get('keyword') twitter = cleaned_data.get('twitter') reddit = cleaned_data.get('reddit') start_date = cleaned_data.get('startdate') ##print(start_date) end_date = cleaned_data.get('enddate') ##print(end_date) if not keyword: raise forms.ValidationError('Please Enter a Keyword.') if not start_date: raise forms.ValidationError('Please enter a start date.') if not start_date: raise forms.ValidationError('Please enter an end date.') if not twitter and not reddit: raise forms.ValidationError('Please select a platform.') elif twitter and reddit: raise forms.ValidationError('You can only select one platform.') else: ##print('else') if end_date.date() > datetime.datetime.now().date( ) or start_date.date() > datetime.datetime.now().date(): raise forms.ValidationError('You can\'t search the future!') if end_date.date() < start_date.date(): raise forms.ValidationError( 'Please make sure the start date is before the end date.') if twitter and not reddit: onewk = datetime.datetime.now() - datetime.timedelta(days=7) ##print(onewk) if end_date.date() < onewk.date(): raise forms.ValidationError( 'Twitter can only get results from 7 days ago. You have selected a date that is over 7 days ago.' )
class SummaryDeliveryInstructionsForm(forms.Form): frm = forms.DateField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True }), label='Start Date') to = forms.DateField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True }), label="Final Date") dist = forms.ModelChoiceField(\ queryset=Address.objects.filter(typ__name="lbm_dist") ) comment = forms.CharField(label="Comment")
class Meta: model = Orden_Reparacion fecha = forms.DateField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True })) fields = ('falla', 'demandante', 'fecha', 'tecnico_asignado', 'estado')
def __init__(self, *args, **kwargs): super(ContestForm, self).__init__(*args, **kwargs) self.fields['date'] = forms.DateField( input_formats=['%Y/%m/%d'], widget=DatePicker(options={ "format": "yyyy/mm/dd", "autoclose": True }))
class DateTestForm(forms.Form): todo = forms.CharField(widget=forms.TextInput( attrs={"class": "form-control"})) date = forms.DateField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True }))
class TodoForm(forms.ModelForm): duedate = forms.DateField(widget=DatePicker(options={ "format": "yyyy-mm-dd", "autoclose": True })) class Meta: model = Todo fields = "__all__"
class ProfileEdit(forms.ModelForm): def __init__(self, *args, **kwargs): super(ProfileEdit, self).__init__(*args, **kwargs) user = kwargs.get('instance') profile = Profile.objects.get(user_id=user.id) self.fields['date_of_birth'].initial = profile.date_of_birth self.fields['biography'].initial = profile.biography self.fields['contacts'].initial = profile.contacts date_of_birth = forms.DateField(widget=DatePicker(options={ "format": "yyyy-mm-dd", "autoclose": True })) biography = forms.CharField(widget=forms.Textarea(), required=False) contacts = forms.CharField(widget=forms.Textarea(), required=False) password = forms.CharField(widget=forms.PasswordInput()) password2 = forms.CharField(widget=forms.PasswordInput(), required=False) class Meta: model = User fields = ('email', 'username', 'password', 'biography', 'contacts', 'date_of_birth') def clean(self): cleaned_data = super().clean() if not self.errors: if cleaned_data['password'] and cleaned_data['password2']: if cleaned_data['password'] != cleaned_data['password2']: raise forms.ValidationError('Passwords do not match!') return cleaned_data def save(self, commit=True): user = super().save(commit=False) # no save to database user.set_password( self.cleaned_data['password']) # password should be hashed! user.save( update_fields=['password', 'email', 'first_name', 'last_name']) profile = Profile.objects.get(user_id=user.id) profile.ip = self.instance.ip profile.biography = self.cleaned_data['biography'] profile.contacts = self.cleaned_data['contacts'] profile.date_of_birth = self.cleaned_data['date_of_birth'] profile.save( update_fields=['biography', 'contacts', 'date_of_birth', 'ip']) return user
class Meta: model = ReserverDay fields = ('__all__') widgets = { 'date_reserver': DatePicker(options={ "format": "yyyy-mm-dd", "autoclose": True }) }
class ShiftChangeForm(forms.Form): options = { "format": "dd/mm/yyyy", "autoclose": True, "weekStart": 1, "calendarWeeks": True, "daysOfWeekHighlighted": [5, 6, 0], "startDate": '01/01/2016', "endDate": '31/12/2030', "todayHighlight": True, "language": "es" } first_date_picker_widget = DatePicker(options=options) second_date_picker_widget = DatePicker(options=options) first_date = forms.DateField(widget=first_date_picker_widget, label='Primera fecha') second_date = forms.DateField(widget=second_date_picker_widget, label='Segunda fecha')
class RegionBibleForm(forms.Form): region = forms.ModelChoiceField(label=("Select Region"), queryset=Region.objects.all()) date = forms.DateField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True }), required=False) homeno = forms.BooleanField(label=("Home No"), required=False) mobileno = forms.BooleanField(label=("Mobile No"), required=False)
def __init__(self, *args, **kwargs): super(ReservacionesForm, self).__init__(*args, **kwargs) self.fields['empleado'] = forms.ModelChoiceField( queryset=Empleados.objects.all(), empty_label=None, widget=forms.Select(attrs={'class': 'form-control m-input'})) self.fields['vehiculo'] = forms.ModelChoiceField( queryset=Vehiculo.objects.all(), empty_label=None, widget=forms.Select(attrs={'class': 'form-control m-input'})) self.fields['cliente'] = forms.ModelChoiceField( queryset=Clientes.objects.all(), empty_label=None, widget=forms.Select(attrs={'class': 'form-control m-input'})) self.fields['fecha_renta'] = forms.DateField( widget=DatePicker(attrs={'class': 'form-control m-input'}, options={ "format": "mm/dd/yyyy", "autoclose": True })) self.fields['fecha_devolucion'] = forms.DateField( widget=DatePicker(attrs={'class': 'form-control m-input'}, options={ "format": "mm/dd/yyyy", "autoclose": True })) self.fields['monto_dia'].widget = forms.NumberInput( attrs={'class': 'form-control m-input'}) self.fields['cantidad_dia'].widget = forms.NumberInput( attrs={'class': 'form-control m-input'}) self.fields['comentario'].widget = forms.Textarea( attrs={'class': 'form-control m-input'})
class DistBibleForm(forms.Form): dist = forms.ModelChoiceField( label=("Distributor"), queryset=Address.objects.filter(typ__name="lbm_contractor")) date = forms.DateField( widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True, "todayHighlight": True }), required=False) homeno = forms.BooleanField(label=("Home No"), required=False) mobileno = forms.BooleanField(label=("Mobile No"), required=False) emailno = forms.BooleanField(label=("E-mail Address"), required=False)
def __init__(self, *args, **kwargs): super(ClientesForm, self).__init__(*args, **kwargs) TYPE_PERSON_CHOISES = ( ('Fisica', 'Fisica'), ('Juridica', 'Juridica'), ) SEX_CHOISES = ( ('M', 'Masculino'), ('F', 'Femenino'), ) self.fields['nombre'].widget = forms.TextInput( attrs={'class': 'form-control m-input'}) self.fields['cedula'].widget = forms.TextInput( attrs={'class': 'form-control m-input'}) self.fields['no_tjcredito'] = forms.CharField( label="No. de Tarjeta de Credito") self.fields['no_tjcredito'].widget = forms.TextInput( attrs={'class': 'form-control m-input'}) self.fields['limite_credito'].widget = forms.NumberInput( attrs={'class': 'form-control m-input'}) self.fields['tipo_persona'].widget = forms.Select( choices=TYPE_PERSON_CHOISES, attrs={'class': 'form-control m-input'}) self.fields['sexo'].widget = forms.Select( choices=SEX_CHOISES, attrs={'class': 'form-control m-input'}) self.fields['fecha_nacimiento'] = forms.DateField( widget=DatePicker(attrs={'class': 'form-control m-input'}, options={ "format": "mm/dd/yyyy", "autoclose": True })) self.fields['licencia'] = forms.CharField(label="No. de Licencia") self.fields['licencia'].widget = forms.TextInput( attrs={'class': 'form-control m-input'}) self.fields['direccion'].widget = forms.TextInput( attrs={'class': 'form-control m-input'})
class SiniestroForm(forms.ModelForm): fecha = forms.DateField(widget=DatePicker(options={ "format": "dd/mm/yyyy", "autoclose": True }), input_formats=['%d/%m/%Y']) cantidad_de_victimas_fatales = forms.IntegerField(min_value=1) class Meta: model = Siniestro fields = [ 'lugar', 'provincia', 'posicion', 'fecha', 'causa_principal', 'mensaje' ]
class BookingForm(forms.Form): date = forms.DateField(widget=DatePicker( options={ "maxViewMode": 0, "todayBtn": True, "language": "pl-PL", "daysOfWeekDisabled": "0,7", "daysOfWeekHighlighted": "1,2,3,4,5,6", "calendarWeeks": True, "todayHighlight": True, "format": "yyyy-mm-dd", "autoclose": True, })) time = forms.TimeField(widget=forms.Select)
class NetworkForm(forms.ModelForm): class Meta: model = Network fields = ('code', 'name', 'start_time', 'end_time', 'status', 'describe') start_time = forms.DateField(label="开始时间", widget=DatePicker( attrs={ 'class': 'test-123', }, options={ "format": "yyyy-mm-dd", "autoclose": True, }, ), required=False) end_time = forms.DateField(label="结束时间", required=False, widget=DatePicker(options={ "format": "yyyy-mm-dd", "autoclose": True }, ))
class AddressDetails(forms.Form): distrib = forms.ModelChoiceField( label=("Distributor"), queryset=Address.objects.filter(typ__name="lbm_contractor")) date = forms.DateField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True }), required=False) isc = forms.BooleanField(label=("Is Current"), required=False) distb = forms.BooleanField(label=("Distributor"), required=False) sdistb = forms.BooleanField(label=("Sub Distributor"), required=False) contrc = forms.BooleanField(label=("Contractor"), required=False) hacontrc = forms.BooleanField(label=("Has Agency Contract"), required=False) hccontrc = forms.BooleanField(label=("Has Coural Contract"), required=False)
class Meta: model = Contest fields = [ 'name', 'source', 'date', 'num_of_problem', 'contest_type', 'contest_link' ] widgets = { 'date': DatePicker(options={ "format": "yyyy/mm/dd", "autoclose": True }) } labels = { 'name': 'Contest Name', 'source': 'Contest Source', 'date': 'Contest Start Time', 'num_of_problem': 'Number of Problems', 'contest_link': 'Link', }
class ProfileEdit(forms.ModelForm): date_naiss = forms.DateField( widget=DatePicker(options={"format": "dd/mm/yyyy", "autoclose": True})) class Meta: model = Profile fields = [ 'date_naiss', 'pays', 'ville', 'contact', 'facebook', 'twitter', 'linkedin', 'sexe', 'emploie', 'image', 'bio', ]
class FileForm(forms.ModelForm): SEXO_CHOICES = (('M', "Masctulino "), ('F', "Feminino")) CHOICES = [(True, 'SI'), (False, 'NO')] region = forms.CharField(label='Region', max_length=100) province = forms.CharField(label='Provincia', max_length=100) district = forms.CharField(label='Distrito') community = forms.CharField(label='Comunidad') address = forms.CharField(label='Dirección') family_name = forms.CharField(label='Nombre de la familia') intervention_sector = forms.CharField( label='Sector de intervención( Según mapa del distrito)') reluctant_houses = forms.ChoiceField( label='Casas renuente o cerrada( solo cuando corresponda)', choices=CHOICES, widget=forms.RadioSelect(), required=False) members = forms.IntegerField(label='N° de integrantes') sex = forms.ChoiceField(label='Sexo ', choices=SEXO_CHOICES) registration_date = forms.DateField( label='Fecha', input_formats=['%d/%m/%Y'], widget=DatePicker(options={ "format": "dd/mm/yyyy", "autoclose": True })) class Meta: model = File fields = ( 'region', 'province', 'district', 'community', 'address', 'family_name', 'intervention_sector', 'reluctant_houses', 'members', 'registration_date', 'sex', )
class ValeForm(forms.ModelForm): valor = forms.IntegerField(widget=forms.TextInput, initial=123) correlativo = forms.IntegerField(widget=forms.TextInput, initial=111111) correlativo.disabled = True hora_llamado = forms.DateField(widget=DatePicker(options={ "format": "dd/mm/yyyy", "autoclose": True })) class Meta: model = Vale fields = ('datos_movil', 'correlativo', 'cliente', 'tipo_Vale', 'direccion_origen', 'direccion_destino', 'hora_llamado', 'valor', 'observacion', 'responsable_ingreso', 'datoPeriodoFacturacion') def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['city'].queryset = City.objects.none()
class PriceForm(forms.ModelForm): #date = forms.DateField(initial=saturday, widget=forms.SelectDateWidget( # empty_label=('year_label', 'month_label', 'day_label'))) date = forms.DateField(initial=saturday, widget=DatePicker( attrs={'class': 'datepicker datepicker-inline'}, options={ "format": "mm/dd/yyyy", "autoclose": True, })) duration = forms.IntegerField(widget=forms.NumberInput, initial=4, min_value=4, max_value=12, label='Number of hours') # extend date validation def clean_date(self): date = self.cleaned_data['date'] # Don't allow before today if date < today: raise forms.ValidationError("\ The reservation date is before today.") return date class Meta: model = Reservation fields = [ 'date', 'duration', 'email', ] labels = { 'date': 'Reservation Date', 'duration': 'Number of hours', }
class RecordForm(forms.Form): name = forms.ModelChoiceField( queryset=DonorInfo.objects.all().order_by('name')) date = forms.DateField(widget=DatePicker(options={ "format": "mm/dd/yyyy", "autoclose": True })) payment_recvd = forms.BooleanField(required=False) def clean_recvd_date(self): data = self.cleaned_data['payment_recvd'] if data > datetime.date.today(): raise ValidationError(_('Date Cannot Be in the Future')) return data class Meta: model = DonorInfo fields = [ 'name', 'payment_recvd', 'date_recvd', 'street_address', 'city', 'state', 'zipcode', 'email', 'phone' ]
def __init__(self): DatePicker.__init__(self,format="%Y-%m-%d")
class ToDoForm(forms.Form): todo = forms.CharField(widget=forms.TextInput( attrs={"class": "form-control"})) date = forms.DateField( widget=DatePicker(options={"format": "YYYY-MM-DD"}, fontawesome=True))