class NewProjectionPhotoForm(forms.Form): # projection type front_view_photo = "FRT" side_first_view_photo = "SD1" side_second_view_photo = "SD2" back_view_photo = "BCK" projection_view_type = forms.ChoiceField(label=_('Выберите вид к которому относится фото'), widget = forms.Select(attrs = {'class': 'form-control'}), choices = ( (front_view_photo, _('Передний вид')), (side_first_view_photo, _('Боковой вид №1')), (side_second_view_photo, _('Боковой вид №2')), (back_view_photo, _('Задний вид')), ) ) # фото проекции projection_view_photo = forms.ImageField(label=_("Выберите изображение"), widget = forms.ClearableFileInput(attrs = {'class': 'form-control', 'type':'file'})) projection_view_description = forms.CharField(label=_('Описание'), max_length=100, required=False, widget = forms.Textarea(attrs = {'class': 'form-control', 'rows': "5" } ) )
def __init__(self, *args, **kwargs): categorias = GruposCategorias.objects.get( grupo='Infraestructura').idGruposCategorias.values_list( 'categoria') CHOICE_CATEGORIAS = [] # diccionario del menu for choice in categorias: CHOICE_CATEGORIAS.append((choice[0], choice[0])) super(FormInfraestructura, self).__init__(*args, **kwargs) self.fields['nombre'].widget.attrs.update({'class': 'form-control'}) self.fields['id_inst'].widget.attrs.update({'class': 'form-control'}) self.fields['descripcion'].widget.attrs.update({ 'class': 'form-control', 'row': 3 }) self.fields['categoria'] = forms.CharField( label='Categoria', required=False, help_text='Seleccione la categoria', widget=forms.Select(attrs={ 'class': "form-control", 'placeholder': 'Categoria', 'rows': 1 }, choices=CHOICE_CATEGORIAS)) #self.fields['geom']=forms.GeometryField(srid='4326',widget=forms.Textarea) #self.fields['geometria'].widget.attrs.update({'class': 'form-control-file'}) #self.fields['geom'].widget.attrs.update({'template_name':'cynr_app/geomFormItem.html','class': 'form-control'}) self.fields['ficha_tec'].widget.attrs.update( {'class': 'form-control-file'})
def __init__(self, *args, **kwargs): categorias = GruposCategorias.objects.get( grupo='Documentos Institucionales').idGruposCategorias.values_list( 'categoria') CHOICE_CATEGORIAS = [] # diccionario del menu for choice in categorias: CHOICE_CATEGORIAS.append((choice[0], choice[0])) super(FormDocInstitucionales, self).__init__(*args, **kwargs) self.fields['nombre'].widget.attrs.update({'class': 'form-control'}) self.fields['id_inst'].widget.attrs.update({'class': 'form-control'}) self.fields['presentacion'].widget.attrs.update({ 'class': 'form-control', 'row': 3 }) self.fields['categoria'] = forms.CharField( label='Categoria', required=False, help_text='Seleccione la categoria', widget=forms.Select(attrs={ 'class': "form-control", 'placeholder': 'Categoria', 'rows': 1 }, choices=CHOICE_CATEGORIAS)) self.fields['link_doc'].widget.attrs.update({'class': 'form-control'}) self.fields['arch_doc'].widget.attrs.update( {'class': 'form-control-file'}) self.fields['alc_geografico'].widget.attrs.update( {'class': 'form-control'})
class RespuestaSinoForm(forms.Form): """! Clase que permite crear el formulario para las respuestas de tipo SiNo @author Manuel Zambrano @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> @date 29-08-2018 @version 1.0.0 """ respuesta = forms.BooleanField(label='Respuesta', widget=forms.Select(choices=((True, 'Si'), (False, 'No'))), required=False) justificacion = forms.CharField( label='Respuesta', widget=forms.Textarea(), required=False, min_length=128, ) def __init__(self, *arg, **kwargs): """! Funcion que muestra el init del formulario @author Manuel Zambrano @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> @date 29-08-2018 @version 1.0.0 """ super(RespuestaSinoForm, self).__init__(*arg, **kwargs) self.fields['justificacion'].widget.attrs.update({ 'placeholder': 'Justificacion', 'style': 'width:370px;height:191px;' }) def clean(self): """! Funcion que sobreescribe el metodo clean() de la clase, validación para el campo de justificacion @author Manuel Zambrano @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> @date 29-08-2018 @version 1.0.0 """ cleaned_data = super(RespuestaSinoForm, self).clean() clean_respuesta = cleaned_data.get('respuesta') clean_justificacion = cleaned_data.get('justificacion') if not clean_respuesta: if not clean_justificacion: raise forms.ValidationError( "Verifique el campo de justificacion", code="justificacion_error")
class NewParameterData(forms.Form): # gym user name user_parameter = forms.ChoiceField(label=_('Выберите параметр'), widget = forms.Select(attrs = {'class': 'main-inp wide'}), choices = []) # gym user description body_data = '' def __init__(self, *args, **kwargs): super(NewParameterData, self).__init__(*args, **kwargs) user_id = kwargs.pop('user_id', None) # получаем список всех параметров выбранного пользователя all_user_params = BodyParameter.objects.filter(user__user__id=user_id) self.fields['user_parameter'].choices = ((x.id, x.body_title) for x in all_user_params)
class Meta: model = Basemap fields = ['name', 'style', 'zoom', 'location'] widgets = { 'name': forms.TextInput( attrs={'class': 'form-control form-control nav-item'}), 'style': forms.Select( attrs={'class': 'form-control form-control nav-item'}), 'location': forms.HiddenInput(), 'zoom': forms.HiddenInput(), }
class DownloadDataForm(forms.Form): DATA_NAMES = [ ('Kidney_Sample_Annotations.txt', 'Kidney_Sample_Annotations.txt'), ('Kidney_Feature_Annotations.txt', 'Kidney_Feature_Annotations.txt'), ('Kidney_Raw_BioProbeCountMatrix.txt', 'Kidney_Raw_BioProbeCountMatrix.txt'), ('Kidney_Raw_TargetCountMatrix.txt', 'Kidney_Raw_TargetCountMatrix.txt'), ('Kidney_Q3Norm_TargetCountMatrix.txt', 'Kidney_Q3Norm_TargetCountMatrix.txt'), ('Cell_Types_for_Spatial_Decon.txt', 'Cell_Types_for_Spatial_Decon.txt'), ('Young_kidney_cell_profile_matrix.csv', 'Young_kidney_cell_profile_matrix.csv'), ('Kidney_ssGSEA.txt', 'Kidney_ssGSEA.txt'), ] data_name = forms.ChoiceField( label='Name of txt/csv file to download', required=False, choices=DATA_NAMES, widget=forms.Select(attrs={'class': 'form-control mr-sm-1'}))
def __init__(self, *args, **kwargs): # CHOICE INSTITUCIONES ----------------------------------------------------------------------------- inst_categorias = GruposCategorias.objects.get( grupo='Instituciones').idGruposCategorias.values_list('categoria') CHOICE_INSTITUCIONES = [] # diccionario del menu for choice in inst_categorias: CHOICE_INSTITUCIONES.append( (choice[0], choice[0])) # (seleccion,valor) ponemos lo mismo super(FormInstitucion, self).__init__(*args, **kwargs) self.fields['categoria'] = forms.CharField( label='Categoria', required=False, help_text='Seleccione la categoria', widget=forms.Select(attrs={ 'class': "form-control", 'placeholder': 'Categoria', 'rows': 5 }, choices=CHOICE_INSTITUCIONES)) self.fields['nombre'].widget.attrs.update({ 'class': 'form-control', 'type': "text" }) self.fields['presentacion'].widget.attrs.update({ 'class': 'form-control', 'row': 3 }) self.fields['pag_web'].widget.attrs.update({'class': 'form-control'}) self.fields['logo'].widget.attrs.update({'class': 'form-control-file'}) self.fields['direccion'].widget.attrs.update({ 'class': 'form-control', 'row': 3 }) self.fields['tel'].widget.attrs.update({'class': 'form-control'}) self.fields['alc_geografico'].widget.attrs.update( {'class': 'form-control'})
def __init__(self, *args, **kwargs): categorias = GruposCategorias.objects.get( grupo='Documentos').idGruposCategorias.values_list('categoria') CHOICE_CATEGORIAS = [] # diccionario del menu for choice in categorias: CHOICE_CATEGORIAS.append((choice[0], choice[0])) super(FormDoc, self).__init__(*args, **kwargs) self.fields['id_contacto'].widget.attrs.update( {'class': 'form-control'}) self.fields['categoria'] = forms.CharField( label='Categoria', required=False, help_text='Seleccione la categoria', widget=forms.Select(attrs={ 'class': "form-control", 'placeholder': 'Categoria', 'rows': 1 }, choices=CHOICE_CATEGORIAS)) self.fields['titulo'].widget.attrs.update({ 'class': 'form-control', 'type': "text" }) self.fields['descripcion'].widget.attrs.update({ 'class': 'form-control', 'row': 3 }) self.fields['fecha_hora'] = forms.DateTimeField( help_text='Fecha y Hora de creación', widget=forms.DateTimeInput(attrs={ 'type': 'datetime-local', 'class': 'form-control' })) self.fields['fecha_hora'].input_formats = [ "%Y-%m-%dT%H:%M", "%Y-%m-%d %H:%M" ]
class Meta: model = Criteria exclude = ['user', 'unit'] widgets = {field: geoforms.Select() for field in fields_name} #geoforms.RadioSelect() widgets['geom'] = LeafletWidget()
class EmpleadoForm(forms.Form): cedula = forms.CharField(required=False, label=u'Cédula') nombres = forms.CharField(max_length=250, widget=forms.TextInput(attrs={'size': '30'})) apellido_paterno = forms.CharField( max_length=250, widget=forms.TextInput(attrs={'size': '30'})) apellido_materno = forms.CharField( max_length=250, widget=forms.TextInput(attrs={'size': '30'}), required=False) pais = forms.ModelChoiceField( queryset=Pais.objects.all(), empty_label="Escoger un pais", widget=forms.Select(attrs={ 'placeholder': 'País', 'onChange': "getProvincias(this.value)" })) provincia = forms.ModelChoiceField( queryset=Provincia.objects.none(), empty_label="Escoger una provincia", widget=forms.Select( attrs={ 'placeholder': 'Provincia o estado', 'onChange': "getCiudades(this.value)" })) ciudad = forms.ModelChoiceField( queryset=Ciudad.objects.none(), empty_label="Escoger una ciudad", widget=forms.Select(attrs={'placeholder': 'Ciudad o Cantón'})) sexo = forms.ChoiceField(choices=PersonaNatural.SEXO_CHOICES, required=True) fecha_nacimiento = forms.DateField(required=False) observaciones = forms.CharField(widget=forms.Textarea()) usuario = forms.CharField(max_length=13, widget=forms.TextInput(attrs={'size': '30'})) contrasenia = forms.CharField( max_length=13, widget=forms.PasswordInput(attrs={'size': '30'})) email = forms.EmailField(max_length=25, widget=forms.TextInput(attrs={'size': '30'})) plazas_trabajo = forms.ModelMultipleChoiceField( queryset=PlazaTrabajo.objects.all(), widget=forms.SelectMultiple) foto = forms.ImageField(required=False) def modificarQuerySet(self, pais_id, provincia_id): if pais_id not in ('', None): self.fields['provincia'].queryset = Provincia.objects.filter( pais__id=pais_id) if provincia_id not in ('', None): self.fields['ciudad'].queryset = Ciudad.objects.filter( provincia__id=provincia_id) def save(self, empleado=None): cleaned_data = super(EmpleadoForm, self).clean() if empleado is None: persona = Persona() persona.tipo = Persona.TIPO_PERSONA_NATURAL persona.observaciones = cleaned_data["observaciones"] persona.ruc = cleaned_data["cedula"] persona.nombre_comercial = "" persona.save() usuario = User() usuario.username = cleaned_data["usuario"] usuario.set_password(cleaned_data["contrasenia"]) usuario.email = cleaned_data["email"] usuario.save() persona_natural = PersonaNatural() persona_natural.ciudad_nacimiento = cleaned_data['ciudad'] persona_natural.cedula = cleaned_data["cedula"] persona_natural.nombres = cleaned_data["nombres"] persona_natural.apellido_paterno = cleaned_data["apellido_paterno"] persona_natural.apellido_materno = cleaned_data["apellido_materno"] persona_natural.persona = persona persona_natural.sexo = cleaned_data["sexo"] persona_natural.fecha_nacimiento = cleaned_data["fecha_nacimiento"] persona_natural.save() empleado = Empleado() empleado.persona = persona_natural empleado.usuario = usuario empleado.foto = cleaned_data["foto"] empleado.observaciones = cleaned_data["observaciones"] empleado.save() empleado.plazas_trabajo = cleaned_data["plazas_trabajo"] empleado.save() else: empleado.persona.nombres = cleaned_data["nombres"] empleado.persona.apellido_paterno = cleaned_data[ "apellido_paterno"] empleado.persona.apellido_materno = cleaned_data[ "apellido_materno"] empleado.persona.sexo = cleaned_data["sexo"] empleado.persona.cedula = cleaned_data["cedula"] empleado.persona.ciudad_nacimiento = cleaned_data["ciudad"] empleado.persona.save() empleado.usuario.email = cleaned_data["email"] empleado.usuario.save() empleado.foto = cleaned_data["foto"] empleado.observaciones = cleaned_data["observaciones"] empleado.save() empleado.plazas_trabajo = cleaned_data["plazas_trabajo"] empleado.save() return empleado def clean_usuario(self): if self.cleaned_data['usuario']: p = User.objects.filter(username=self.cleaned_data['usuario']) if len(p) > 0: raise forms.ValidationError( _("Ya esxiste un usuario con este username")) return self.cleaned_data['usuario']
class Meta: model = Town # fields = "__all__" fields = [ "codeTown", "nameTown", "surface", "population", "townPostalcode", "codeRegion", "codeDepartement", "centerCoordinateLat", "centerCoordinateLong" ] widgets = { 'codeTown': forms.TextInput( attrs={ 'class': 'm-2 border border-2 border-green-200 focus:outline-none ' 'focus:ring-2 focus:ring-green-600 focus:border-transparent ' 'text-gray-400 font-bold py-2 px-4 rounded-full' }), 'nameTown': forms.TextInput( attrs={ 'placeholder': 'Un nouveau nom ?', 'class': 'm-2 border border-2 border-green-200 focus:outline-none ' 'focus:ring-2 focus:ring-green-600 focus:border-transparent ' 'text-gray-400 font-bold py-2 px-4 rounded-full' }), 'codeRegion': forms.Select( attrs={ 'class': 'm-2 border border-2 border-green-200 focus:outline-none ' 'focus:ring-2 focus:ring-green-600 focus:border-transparent ' 'text-gray-400 font-bold py-2 px-4 rounded-full' }), 'codeDepartement': forms.Select( attrs={ 'class': 'm-2 border border-2 border-green-200 focus:outline-none ' 'focus:ring-2 focus:ring-green-600 focus:border-transparent ' 'text-gray-400 font-bold py-2 px-4 rounded-full' }), 'townPostalcode': forms.TextInput( attrs={ 'class': 'm-2 border border-2 border-green-200 focus:outline-none ' 'focus:ring-2 focus:ring-green-600 focus:border-transparent ' 'text-gray-400 font-bold py-2 px-4 rounded-full' }), 'surface': forms.NumberInput( attrs={ 'class': 'm-2 border border-2 border-green-200 focus:outline-none ' 'focus:ring-2 focus:ring-green-600 focus:border-transparent ' 'text-gray-400 font-bold py-2 px-4 rounded-full' }), 'centerCoordinateLat': forms.NumberInput( attrs={ 'class': 'm-2 border border-2 border-green-200 focus:outline-none ' 'focus:ring-2 focus:ring-green-600 focus:border-transparent ' 'text-gray-400 font-bold py-2 px-4 rounded-full' }), 'centerCoordinateLong': forms.NumberInput( attrs={ 'class': 'm-2 border border-2 border-green-200 focus:outline-none ' 'focus:ring-2 focus:ring-green-600 focus:border-transparent ' 'text-gray-400 font-bold py-2 px-4 rounded-full' }), 'population': forms.NumberInput( attrs={ 'class': 'm-2 border border-2 border-green-200 focus:outline-none ' 'focus:ring-2 focus:ring-green-600 ' 'focus:border-transparent text-gray-400 font-bold py-2 ' 'px-4 rounded-full' }), # 'center': forms.OSMWidget(attrs={'map_width': 800, 'map_height': 500}), }
class Meta: model = PermitRequest fields = [ 'administrative_entity', 'address', 'geom', 'description', 'date_start', 'date_end', 'sitetype', 'length', 'width', 'road_marking_damaged', 'is_green_area', 'invoice_to' ] widgets = { 'geom': SitOpenLayersWidget( attrs={ 'map_width': '100%', 'map_height': settings.OL_MAP_HEIGHT, 'map_srid': 2056, 'default_center': [2539057, 1181111], 'default_zoom': 10, 'display_raw': False, #show coordinate in debug 'map_clear_style': "visibility:visible;", 'edit_geom': True, 'min_zoom': 8, 'wmts_capabilities_url': settings.WMTS_GETCAP, 'wmts_layer': settings.WMTS_LAYER, 'wmts_capabilities_url_alternative': settings.WMTS_GETCAP_ALTERNATIVE, 'wmts_layer_alternative': settings.WMTS_LAYER_ALTERNATIVE, 'administrative_entities_url': 'gpf:adm-entity-geojson', }), 'administrative_entity': forms.Select( attrs={ 'onchange': "gpfMap.zoomToAdminEntity(this.options[this.selectedIndex].value);" }), 'date_start': DatePickerInput( options={ "format": "DD/MM/YYYY", "locale": "fr", "minDate": ( datetime.datetime.today() + datetime.timedelta(days=int(settings.MIN_START_DELAY)) ).strftime('%Y/%m/%d') }).start_of('event days'), 'date_end': DatePickerInput( options={ "format": "DD/MM/YYYY", "locale": "fr", "minDate": ( datetime.datetime.today() + datetime.timedelta(days=int(settings.MIN_START_DELAY)) ).strftime('%Y/%m/%d') }).end_of('event days'), 'description': forms.Textarea(attrs={'rows': '3'}), 'zipcode': forms.TextInput(attrs={'id': 'id_zipcode_permit'}), 'city': forms.TextInput(attrs={'id': 'id_city_permit'}), 'address': RemoteAutocompleteWidget( attrs={ "id": "id_adress_permit", "apiurl": "https://api3.geo.admin.ch/rest/services/api/SearchServer?", "apiurl_detail": "https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bfs.gebaeude_wohnungs_register/", "search_prefix": "true", "origins": "address", "zipcode_field": "zipcode_permit", "city_field": "city_permit", "placeholder": "ex: Rue de la plaine", }), }
class Meta: model = PermitRequest exclude = [] fields = [ 'company', 'project_owner', 'ended', 'archeotype', 'has_archeology', 'amount', 'paid', 'validated', 'sent', 'date_start', 'date_end', 'date_end_work_announcement', 'date_end_work', 'date_request_created', 'road_marking_damaged', 'is_green_area', 'invoice_to', 'sitetype', 'description', 'administrative_entity', 'address', 'length', 'width', 'geom' ] help_texts = { 'validated': "Par le secrétariat uniquement", 'archeotype': "Zone archéologique observée au moment de la fouille", 'has_archeology': "Zone archéologique détectée sur la base des géodonnées cantonales", 'ended': "La fouille a-t-elle été contrôlée par le bureau STE ?", } widgets = { 'geom': SitOpenLayersWidget( attrs={ 'map_width': '100%', 'map_height': settings.OL_MAP_HEIGHT, 'map_srid': 2056, 'default_center': [2539057, 1181111], 'default_zoom': 10, 'display_raw': False, #show coordinate in debug 'map_clear_style': "visibility:visible;", 'edit_geom': False, 'min_zoom': 6, 'wmts_capabilities_url': settings.WMTS_GETCAP, 'wmts_layer': settings.WMTS_LAYER, 'wmts_capabilities_url_alternative': settings.WMTS_GETCAP_ALTERNATIVE, 'wmts_layer_alternative': settings.WMTS_LAYER_ALTERNATIVE, 'administrative_entities_url': 'gpf:adm-entity-geojson', }), 'administrative_entity': forms.Select( attrs={ 'onchange': "gpfMap.zoomToAdminEntity(this.options[this.selectedIndex].value);" }), 'date_start': DatePickerInput(options={ "format": "DD/MM/YYYY", "locale": "fr" }).start_of('event days'), 'date_end': DatePickerInput(options={ "format": "DD/MM/YYYY", "locale": "fr" }).end_of('event days'), 'date_end_work': DatePickerInput(options={ "format": "DD/MM/YYYY", "locale": "fr" }), 'date_end_work_announcement': DatePickerInput(options={ "format": "DD/MM/YYYY", "locale": "fr" }, ), 'date_request_created': forms.TextInput(attrs={'readonly': 'readonly'}), 'description': forms.Textarea(attrs={'rows': '3'}), 'address': RemoteAutocompleteWidget( attrs={ "apiurl": "https://api3.geo.admin.ch/rest/services/api/SearchServer?", "apiurl_detail": "https://api3.geo.admin.ch/rest/services/api/MapServer/ch.bfs.gebaeude_wohnungs_register/", "search_prefix": "true", "origins": "address", "zipcode_field": "zipcode", "city_field": "city", "placeholder": "ex: Place Pestalozzi 2 Yverdon", }), }
def __init__(self, *args, **kwargs): tipo = GruposCategorias.objects.get( grupo='Tipo Obra de Toma').idGruposCategorias.values_list( 'categoria') CHOICE_TIPO = [] for choice in tipo: CHOICE_TIPO.append((choice[0], choice[0])) funcionamiento = GruposCategorias.objects.get( grupo='Funcionamiento Obra de Toma' ).idGruposCategorias.values_list('categoria') CHOICE_FUNCIONAMIENTO = [] for choice in funcionamiento: CHOICE_FUNCIONAMIENTO.append((choice[0], choice[0])) uso = GruposCategorias.objects.get( grupo='Uso Obra de Toma').idGruposCategorias.values_list( 'categoria') CHOICE_USO = [] for choice in uso: CHOICE_USO.append((choice[0], choice[0])) estado = GruposCategorias.objects.get( grupo='Estado de Obra').idGruposCategorias.values_list('categoria') CHOICE_ESTADO = [] for choice in estado: CHOICE_ESTADO.append((choice[0], choice[0])) super(FormObraToma, self).__init__(*args, **kwargs) self.fields['tipo'] = forms.CharField(label='Tipo', required=False, help_text='Seleccione el Tipo', widget=forms.Select( attrs={ 'class': "form-control", 'placeholder': 'Tipo', 'rows': 1 }, choices=CHOICE_TIPO)) self.fields['funcionamiento'] = forms.CharField( label='Funcionamiento', required=False, help_text='Seleccione el Funcionamiento', widget=forms.Select(attrs={ 'class': "form-control", 'placeholder': 'Funcionamiento', 'rows': 1 }, choices=CHOICE_FUNCIONAMIENTO)) self.fields['uso'] = forms.CharField(label='Uso', required=False, help_text='Seleccione el Uso', widget=forms.Select( attrs={ 'class': "form-control", 'placeholder': 'Uso', 'rows': 1 }, choices=CHOICE_USO)) self.fields['estado'] = forms.CharField( label='Estado', required=False, help_text='Seleccione el Estado', widget=forms.Select(attrs={ 'class': "form-control", 'placeholder': 'Estado', 'rows': 1 }, choices=CHOICE_ESTADO)) self.fields['desc_estado'].widget.attrs.update({ 'class': 'form-control', 'row': 3 }) class Meta: model = ObrasToma #fields=['tipo','funcionamiento','uso','estado','desc_estado'] exclude = ()