[57f6191] | 1 | # -*- coding: utf-8 -*- |
---|
[a376adf] | 2 | """ |
---|
[72e62e0] | 3 | Sistema Automatizado de Planificación Integral Comunal SAPIC |
---|
[a376adf] | 4 | |
---|
| 5 | Copyleft (@) 2017 CENDITEL nodo Mérida - Copyleft (@) 2017 CENDITEL nodo Mérida - https://planificacion.cenditel.gob.ve/trac/wiki/WikiStart#a5.-SistemaAutomatizadodePlanificaciónIntegralComunalSAPIC |
---|
| 6 | """ |
---|
| 7 | ## @package explicacion_situacional.forms |
---|
| 8 | # |
---|
| 9 | # Formularios correspondientes a la explicacion situacional |
---|
| 10 | # @author Ing. Leonel Paolo Hernandez Macchiarulo (lhernandez at cenditel.gob.ve) |
---|
| 11 | # @author <a href='http://www.cenditel.gob.ve'>Centro Nacional de Desarrollo e Investigación en TecnologÃas Libres |
---|
| 12 | # (CENDITEL) nodo Mérida - Venezuela</a> |
---|
| 13 | # @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 14 | # @version 1.0 |
---|
| 15 | |
---|
[c7b7e3b] | 16 | from django.core.exceptions import ValidationError |
---|
[f35bc20] | 17 | from django.contrib.gis import forms |
---|
[c609db6] | 18 | from django.forms.fields import ( |
---|
[c7b7e3b] | 19 | CharField, |
---|
| 20 | BooleanField, |
---|
[c609db6] | 21 | ) |
---|
[57f6191] | 22 | |
---|
[c7b7e3b] | 23 | |
---|
[f35bc20] | 24 | from explicacion_situacional.modelsExplicacion.modelsExplicacionesSituacional import * |
---|
| 25 | |
---|
[c7b7e3b] | 26 | from explicacion_situacional.modelsEncuestas.modelsParticipacion import * |
---|
| 27 | |
---|
[f35bc20] | 28 | |
---|
| 29 | class ExplicacionForms(forms.ModelForm): |
---|
[a376adf] | 30 | """! |
---|
| 31 | Clase que permite crear el formulario para la explicacion situacional |
---|
| 32 | |
---|
| 33 | @author Ing. Leonel P. Hernandez M. (lhernandez at cenditel.gob.ve) |
---|
| 34 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 35 | @date 09-01-2017 |
---|
| 36 | @version 1.0.0 |
---|
| 37 | """ |
---|
[f35bc20] | 38 | |
---|
| 39 | class Meta: |
---|
[a376adf] | 40 | """! |
---|
| 41 | Clase que construye los meta datos del formulario |
---|
| 42 | |
---|
| 43 | @author Ing. Leonel P. Hernandez M. (lhernandez at cenditel.gob.ve) |
---|
| 44 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 45 | @date 18-09-2017 |
---|
| 46 | @version 1.0.0 |
---|
| 47 | """ |
---|
[f35bc20] | 48 | model = ExplicacionSituacional |
---|
| 49 | fields = '__all__' |
---|
| 50 | |
---|
| 51 | def __init__(self, *args, **kwargs): |
---|
[a376adf] | 52 | """! |
---|
| 53 | Funcion que muestra el init del formulario |
---|
| 54 | |
---|
| 55 | @author Ing. Leonel P. Hernandez M. (lhernandez at cenditel.gob.ve) |
---|
| 56 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 57 | @date 18-09-2017 |
---|
| 58 | """ |
---|
[f35bc20] | 59 | super(ExplicacionForms, self).__init__(*args, **kwargs) |
---|
[428e173] | 60 | self.fields["fk_organizacion"].widget.attrs.update({ |
---|
| 61 | "class": "form-control", "onchange": "cargar_datos_ubicacion($(this).val())" |
---|
| 62 | }) |
---|
| 63 | self.fields['fk_organizacion'].empty_label = 'Seleccione la organización social' |
---|
| 64 | self.fields['fk_organizacion'].label = 'Organización Social' |
---|
[02a0ec1] | 65 | self.fields['fk_organizacion'].required = True |
---|
[f35bc20] | 66 | |
---|
[428e173] | 67 | forms.OSMWidget.template_name = "openlayers-es.html" |
---|
| 68 | self.fields["coordenadas"].widget = forms.OSMWidget.template_name |
---|
[02a0ec1] | 69 | self.fields['coordenadas'].widget = forms.OSMWidget(attrs={ |
---|
[428e173] | 70 | 'default_zoom': 5.2, 'map_width': 600, |
---|
| 71 | 'map_height': 400, 'default_lat': 8, |
---|
| 72 | 'default_lon': -66 |
---|
| 73 | }) |
---|
[02a0ec1] | 74 | self.fields['coordenadas'].required = True |
---|
[54ea7ad] | 75 | |
---|
[428e173] | 76 | self.fields['map_cartografico'].widget.attrs.update({ |
---|
| 77 | 'class':'form-control', |
---|
| 78 | 'data-show-preview':'true', |
---|
| 79 | 'accept':'image/*' |
---|
| 80 | }) |
---|
| 81 | self.fields['map_cartografico'].label = 'Mapa cartográfico' |
---|
[54ea7ad] | 82 | self.fields['map_cartografico'].required = True |
---|
[c609db6] | 83 | |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | class UbicacionForms(forms.Form): |
---|
| 87 | """! |
---|
| 88 | Clase que permite crear el formulario para el tipo de preguntas que requieren ubicacion |
---|
| 89 | |
---|
| 90 | @author Ing. Leonel P. Hernandez M. (lhernandez at cenditel.gob.ve) |
---|
| 91 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 92 | @date 20-09-2017 |
---|
| 93 | @version 1.0.0 |
---|
| 94 | """ |
---|
| 95 | ubicacion = CharField() |
---|
| 96 | |
---|
| 97 | class Meta: |
---|
| 98 | """! |
---|
| 99 | Clase que construye los meta datos del formulario |
---|
| 100 | |
---|
| 101 | @author Ing. Leonel P. Hernandez M. (lhernandez at cenditel.gob.ve) |
---|
| 102 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 103 | @date 18-09-2017 |
---|
| 104 | @version 1.0.0 |
---|
| 105 | """ |
---|
| 106 | fields = ('ubicacion') |
---|
| 107 | |
---|
| 108 | def __init__(self, *args, **kwargs): |
---|
| 109 | """! |
---|
| 110 | Funcion que muestra el init del formulario |
---|
| 111 | |
---|
| 112 | @author Ing. Leonel P. Hernandez M. (lhernandez at cenditel.gob.ve) |
---|
| 113 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 114 | @date 18-09-2017 |
---|
| 115 | """ |
---|
| 116 | super(UbicacionForms, self).__init__(*args, **kwargs) |
---|
[72e62e0] | 117 | |
---|
[c609db6] | 118 | self.fields['ubicacion'].widget = forms.OSMWidget.template_name = 'openlayers-es.html' |
---|
| 119 | self.fields['ubicacion'].widget = forms.OSMWidget(attrs={ |
---|
| 120 | 'default_zoom': 5.2, 'map_width': 600, |
---|
| 121 | 'map_height': 400, 'default_lat': 8, |
---|
| 122 | 'default_lon': -66}) |
---|
[fcafdfc] | 123 | self.fields['ubicacion'].required = True |
---|
[c7b7e3b] | 124 | |
---|
| 125 | class RespuestaSinoForm(forms.Form): |
---|
| 126 | """! |
---|
| 127 | Clase que permite crear el formulario para las respuestas de tipo SiNo |
---|
| 128 | |
---|
| 129 | @author Manuel Zambrano |
---|
| 130 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 131 | @date 29-08-2018 |
---|
| 132 | @version 1.0.0 |
---|
| 133 | """ |
---|
| 134 | |
---|
[96973f4] | 135 | respuesta = forms.BooleanField(label = 'Respuesta', |
---|
| 136 | widget = forms.Select(choices = ((True,'Si'), |
---|
[c7b7e3b] | 137 | (False,'No') |
---|
| 138 | ) |
---|
| 139 | ), |
---|
[96973f4] | 140 | required = False |
---|
[c7b7e3b] | 141 | ) |
---|
[96973f4] | 142 | justificacion = forms.CharField(label = 'Respuesta', |
---|
| 143 | widget = forms.Textarea(), |
---|
| 144 | required = False, |
---|
| 145 | max_length = 2000, |
---|
[c7b7e3b] | 146 | ) |
---|
| 147 | |
---|
| 148 | def __init__(self,*arg,**kwargs): |
---|
| 149 | """! |
---|
| 150 | Funcion que muestra el init del formulario |
---|
| 151 | |
---|
| 152 | @author Manuel Zambrano |
---|
| 153 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 154 | @date 29-08-2018 |
---|
| 155 | @version 1.0.0 |
---|
| 156 | """ |
---|
| 157 | super(RespuestaSinoForm, self).__init__(*arg,**kwargs) |
---|
| 158 | self.fields['justificacion'].widget.attrs.update({'placeholder': 'Justificacion','style':'width:370px;height:191px;'}) |
---|
| 159 | |
---|
| 160 | def clean(self): |
---|
| 161 | """! |
---|
| 162 | Funcion que sobreescribe el metodo clean() de la clase, validación para el campo de justificacion |
---|
| 163 | |
---|
| 164 | @author Manuel Zambrano |
---|
| 165 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 166 | @date 29-08-2018 |
---|
| 167 | @version 1.0.0 |
---|
| 168 | """ |
---|
| 169 | cleaned_data = super(RespuestaSinoForm,self).clean() |
---|
| 170 | clean_respuesta = cleaned_data.get('respuesta') |
---|
| 171 | clean_justificacion = cleaned_data.get('justificacion') |
---|
| 172 | if not clean_respuesta: |
---|
| 173 | if not clean_justificacion: |
---|
| 174 | raise forms.ValidationError( |
---|
| 175 | "Verifique el campo de justificacion", |
---|
| 176 | code = "justificacion_error" |
---|
| 177 | ) |
---|
| 178 | |
---|
| 179 | class RespuestaAbiertaForm(forms.Form): |
---|
| 180 | """! |
---|
| 181 | Clase que permite crear el formulario para las respuestas de tipo Abierta |
---|
| 182 | |
---|
| 183 | @author Manuel Zambrano |
---|
| 184 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 185 | @date 29-08-2018 |
---|
| 186 | @version 1.0.0 |
---|
| 187 | """ |
---|
| 188 | |
---|
[96973f4] | 189 | respuesta = forms.CharField(label = 'Respuesta', |
---|
| 190 | widget = forms.Textarea(), |
---|
| 191 | max_length = 2000, |
---|
[c7b7e3b] | 192 | ) |
---|
| 193 | |
---|
| 194 | def __init__(self,*arg,**kwargs): |
---|
| 195 | """! |
---|
| 196 | Funcion que muestra el init del formulario |
---|
| 197 | |
---|
| 198 | @author Manuel Zambrano |
---|
| 199 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 200 | @date 29-08-2018 |
---|
| 201 | @version 1.0.0 |
---|
| 202 | """ |
---|
| 203 | |
---|
| 204 | super(RespuestaAbiertaForm, self).__init__(*arg,**kwargs) |
---|
[39b8a44] | 205 | self.fields['respuesta'].widget.attrs.update({'placeholder': 'Respuesta','style':'width:370px;height:191px;'}) |
---|
[c7b7e3b] | 206 | |
---|
| 207 | class RespuestaOpcionesForm(forms.Form): |
---|
| 208 | """! |
---|
| 209 | Clase que permite crear el formulario para las respuestas de tipo Opciones |
---|
| 210 | |
---|
| 211 | @author Manuel Zambrano |
---|
| 212 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 213 | @date 29-08-2018 |
---|
| 214 | @version 1.0.0 |
---|
| 215 | """ |
---|
| 216 | |
---|
| 217 | respuesta = forms.ModelChoiceField(label = 'Opcion', |
---|
| 218 | queryset = Opcion.objects.all(), |
---|
[96973f4] | 219 | required = True, |
---|
| 220 | empty_label = None |
---|
[c7b7e3b] | 221 | ) |
---|
| 222 | |
---|
| 223 | def __init__(self,*arg,**kwargs): |
---|
| 224 | """! |
---|
| 225 | Funcion que muestra el init del formulario |
---|
| 226 | |
---|
| 227 | @author Manuel Zambrano |
---|
| 228 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 229 | @date 29-08-2018 |
---|
| 230 | @version 1.0.0 |
---|
| 231 | """ |
---|
| 232 | |
---|
| 233 | super(RespuestaOpcionesForm, self).__init__(*arg,**kwargs) |
---|
| 234 | |
---|
| 235 | |
---|
| 236 | |
---|
| 237 | |
---|
| 238 | |
---|
| 239 | |
---|
| 240 | |
---|
| 241 | |
---|