source: seiven/economico/forms.py @ 40567da

Last change on this file since 40567da was 40567da, checked in by Fundación CENDITEL <cenditel@…>, 7 años ago

agregado anho_base al panel administrativo y las relaciones con los distintos modelos que están en la app economico

  • Propiedad mode establecida a 100644
File size: 19.8 KB
Línea 
1"""
2Sistema Estadístico Integral de Venezuela - (SEIVEN)
3
4Copyleft (@) 2015 CENDITEL nodo Mérida - https://mpv.cenditel.gob.ve/seiven
5"""
6## @namespace economico.forms
7#
8# Contiene las clases, atributos y métodos para los formularios a implementar en el módulo económico
9# @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
10# @author <a href='http://www.cenditel.gob.ve'>Centro Nacional de Desarrollo e Investigación en Tecnologías Libres
11# (CENDITEL) nodo Mérida - Venezuela</a>
12# @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
13from __future__ import unicode_literals
14
15from django.utils.encoding import python_2_unicode_compatible
16from django.utils.translation import ugettext_lazy as _
17
18import logging
19
20from django import forms
21from django.forms import (
22    ModelForm, TextInput, EmailInput, CharField, EmailField, PasswordInput,
23    Select, MultiWidget, MultiValueField, ChoiceField
24)
25
26from base.constant import (
27    DOMINIO_PRECIOS, DOMINIO_PIB, DOMINIO_AGREGADO_MONETARIO, TIPO_PIB, TIPO_DEMANDA_GLOBAL, TIPO_OFERTA_GLOBAL, TRIMESTRES, MESES,
28    DOMINIO_COMERCIAL, DOMINIO_CAMBIO, DOMINIO_CUENTA_CAPITAL, TIPO_BALANZA_COMERCIAL, DOMINIO_BALANZA_COMERCIAL, DOMINIO_TASAS_INTERES,
29    PERIODICIDAD
30)
31from base.functions import cargar_anho_base, cargar_anho
32
33
34"""!
35Contiene el objeto que registra la vitacora de eventos del módulo económico.
36(configuración en el settings de la aplicación)
37"""
38logger = logging.getLogger("economico")
39
40
41@python_2_unicode_compatible
42class DominioForm(forms.Form):
43    """!
44    Clase que contiene el campo común para la selección del dominio
45
46    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
47    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
48    @date 20-09-2016
49    @version 1.0.0
50    """
51
52    ## Dominio del registro
53    dominio = ChoiceField(
54        label=_(u"Dominio"), choices=(),
55        widget=Select(attrs={
56            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
57            'title': _(u"Seleccione el dominio a registrar")
58        })
59    )
60
61
62@python_2_unicode_compatible
63class TipoForm(forms.Form):
64    """!
65    Clase que contiene el campo común para la selección del tipo
66
67    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
68    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
69    @date 20-09-2016
70    @version 1.0.0
71    """
72
73    ## Tipo de registro
74    tipo = ChoiceField(
75        label=_(u"Tipo"), choices=(),
76        widget=Select(attrs={
77            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
78            'title': _(u"Seleccione el tipo a registrar")
79        })
80    )
81
82
83@python_2_unicode_compatible
84class AnhoBaseForm(forms.Form):
85    """!
86    Clase que contiene el campo común para la selección del año base
87
88    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
89    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
90    @date 20-09-2016
91    @version 1.0.0
92    """
93
94    ## Año base a registrar
95    anho_base = ChoiceField(
96        label=_(u"Año Base"), choices=(),
97        widget=Select(attrs={
98            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
99            'title': _(u"Seleccione el año base")
100        })
101    )
102
103    def __init__(self, *args, **kwargs):
104        super(AnhoBaseForm, self).__init__(*args, **kwargs)
105        self.fields['anho_base'].choices = cargar_anho
106
107@python_2_unicode_compatible
108class PeriodicidadForm(forms.Form):
109    """!
110    Clase que contiene el campo común para la selección de la periodicidad
111
112    @author Edgar A. Linares (elinares 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 26-04-2017
115    @version 1.0.0
116    """
117
118    ## Opciones de periodicidad
119    periodicidad = ChoiceField(
120        label=_(u"Periodicidad"), choices=(),
121        widget=Select(attrs={
122            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
123            'title': _(u"Seleccione la periodicidad")
124        })
125    )
126
127@python_2_unicode_compatible
128class MesIniForm(forms.Form):
129    """!
130    Clase que contiene el campo común para la selección del período del mes inicial
131
132    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
133    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
134    @date 20-09-2016
135    @version 1.0.0
136    """
137
138    ## Mes inicial
139    periodo_mes_ini = ChoiceField(
140        label=_(u"Desde"), choices=MESES,
141        widget=Select(attrs={
142            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
143            'title': _(u"Seleccione el mes inicial")
144        })
145    )
146
147
148@python_2_unicode_compatible
149class MesFinForm(forms.Form):
150    """!
151    Clase que contiene el campo común para la selección del período del mes final
152
153    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
154    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
155    @date 20-09-2016
156    @version 1.0.0
157    """
158
159    ## Mes final
160    periodo_mes_fin = ChoiceField(
161        label=_(u"Hasta"), choices=MESES,
162        widget=Select(attrs={
163            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
164            'title': _(u"Seleccione el mes final")
165        })
166    )
167
168
169@python_2_unicode_compatible
170class AnhoIniForm(forms.Form):
171    """!
172    Clase que contiene el campo común para la selección del período del año inicial
173
174    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
175    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
176    @date 20-09-2016
177    @version 1.0.0
178    """
179
180    ## Año inicial
181    periodo_anho_ini = ChoiceField(
182        label=_('Desde'), choices=(),
183        widget=Select(attrs={
184            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
185            'title': _(u"Seleccione el año inicial")
186        })
187    )
188
189    def __init__(self, *args, **kwargs):
190        super(AnhoIniForm, self).__init__(*args, **kwargs)
191        self.fields['periodo_anho_ini'].choices = cargar_anho_base(anho_inicial='2007')
192
193
194@python_2_unicode_compatible
195class AnhoFinForm(forms.Form):
196    """!
197    Clase que contiene el campo común para la selección del período del año final
198
199    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
200    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
201    @date 20-09-2016
202    @version 1.0.0
203    """
204
205    ## Año final
206    periodo_anho_fin = ChoiceField(
207        label=_('Hasta'), choices=(),
208        widget=Select(attrs={
209            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
210            'title': _(u"Seleccione el año final")
211        })
212    )
213
214    def __init__(self, *args, **kwargs):
215        super(AnhoFinForm, self).__init__(*args, **kwargs)
216        self.fields['periodo_anho_fin'].choices = cargar_anho_base(anho_inicial='2007')
217
218
219@python_2_unicode_compatible
220class TrimestreIniForm(forms.Form):
221    """!
222    Clase que contiene el campo común para la selección del período del trimestre inicial
223
224    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
225    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
226    @date 20-09-2016
227    @version 1.0.0
228    """
229
230    ## Trimestre inicial
231    periodo_trimestre_ini = ChoiceField(
232        label=_(u"Desde"), choices=TRIMESTRES,
233        widget=Select(attrs={
234            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
235            'title': _(u"Seleccione el trimestre inicial")
236        })
237    )
238
239
240@python_2_unicode_compatible
241class TrimestreFinForm(forms.Form):
242    """!
243    Clase que contiene el campo común para la selección del período del trimestre final
244
245    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
246    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
247    @date 20-09-2016
248    @version 1.0.0
249    """
250
251    ## Trimestre final
252    periodo_trimestre_fin = ChoiceField(
253        label=_(u"Hasta"), choices=TRIMESTRES,
254        widget=Select(attrs={
255            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
256            'title': _(u"Seleccione el trimestre final")
257        })
258    )
259
260
261@python_2_unicode_compatible
262class SemanaIniForm(forms.Form):
263    """!
264    Clase que contiene el campo común para la selección del período de la semana inicial
265
266    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
267    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
268    @date 20-09-2016
269    @version 1.0.0
270    """
271
272    ## Semana inicial
273    periodo_semana_ini = ChoiceField(
274        label=_("Desde"), choices=(),
275        widget=Select(attrs={
276            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
277            'title': _(u"Seleccione la semana inicial")
278        })
279    )
280
281
282@python_2_unicode_compatible
283class SemanaFinForm(forms.Form):
284    """!
285    Clase que contiene el campo común para la selección del período de la semana final
286
287    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
288    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
289    @date 20-09-2016
290    @version 1.0.0
291    """
292
293    ## Semana final
294    periodo_semana_fin = ChoiceField(
295        label=_("Hasta"), choices=(),
296        widget=Select(attrs={
297            'class': 'select2 select2-offscreen form-control', 'data-toggle': 'tooltip',
298            'title': _(u"Seleccione la semana final")
299        })
300    )
301
302
303@python_2_unicode_compatible
304class StartDateForm(forms.Form):
305    """!
306    Clase que contiene el campo común para la fecha inicial de consulta
307
308    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
309    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
310    @date 20-09-2016
311    @version 1.0.0
312    """
313    start_date = CharField(label=_('Desde'), max_length=10, widget=TextInput(attrs={
314        'class': 'form-control fecha', 'data-toggle': 'tooltip', 'title': _('Indique la fecha inicial'),
315    }))
316
317
318@python_2_unicode_compatible
319class EndDateForm(forms.Form):
320    """!
321    Clase que contiene el campo común para la fecha final de consulta
322
323    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
324    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
325    @date 20-09-2016
326    @version 1.0.0
327    """
328    end_date = CharField(label=_('Hasta'), max_length=10, widget=TextInput(attrs={
329        'class': 'form-control fecha', 'data-toggle': 'tooltip', 'title': _('Indique la fecha final')
330    }))
331
332
333@python_2_unicode_compatible
334class RealPreciosForm(AnhoBaseForm, DominioForm, MesIniForm, MesFinForm, AnhoIniForm, AnhoFinForm):
335    """!
336    Clase que contiene el formulario para la carga de datos de precios
337
338    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
339    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
340    @date 19-09-2016
341    @version 1.0.0
342    """
343
344    def __init__(self, *args, **kwargs):
345        super(RealPreciosForm, self).__init__(*args, **kwargs)
346        self.fields['dominio'].choices = DOMINIO_PRECIOS
347
348
349@python_2_unicode_compatible
350class PIBForm(TipoForm, AnhoBaseForm, DominioForm, AnhoIniForm, AnhoFinForm, TrimestreIniForm, TrimestreFinForm):
351    """!
352    Clase que contiene el formulario para la carga de datos de PIB
353
354    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
355    @author Edgar A. Linares (elinares at cenditel.gob.ve)
356    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
357    @date 19-09-2016
358    @date 05-04-2017
359    @version 1.0.0
360    """
361
362    def __init__(self, *args, **kwargs):
363        super(PIBForm, self).__init__(*args, **kwargs)
364        self.fields['dominio'].choices = DOMINIO_PIB
365        self.fields['tipo'].choices = TIPO_PIB
366
367
368@python_2_unicode_compatible
369class RealDemandaGlobalForm(AnhoBaseForm, AnhoIniForm, AnhoFinForm, TrimestreIniForm, TrimestreFinForm, TipoForm):
370    """!
371    Clase que contiene el formulario para la carga de datos de demanda global
372
373    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
374    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
375    @date 19-09-2016
376    @version 1.0.0
377    """
378
379    def __init__(self, *args, **kwargs):
380        super(RealDemandaGlobalForm, self).__init__(*args, **kwargs)
381        self.fields['tipo'].choices = TIPO_DEMANDA_GLOBAL
382
383@python_2_unicode_compatible
384class RealOfertaGlobalForm(AnhoBaseForm, AnhoIniForm, AnhoFinForm, TrimestreIniForm, TrimestreFinForm, TipoForm):
385    """!
386    Clase que contiene el formulario para la carga de datos de Oferta global
387
388    @author Ing. Luis Barrios (lbarrios at cenditel.gob.ve)
389    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
390    @date 22-03-2017
391    @version 1.0.0
392    """
393
394    def __init__(self, *args, **kwargs):
395        super(RealOfertaGlobalForm, self).__init__(*args, **kwargs)
396        self.fields['tipo'].choices = TIPO_OFERTA_GLOBAL
397
398@python_2_unicode_compatible
399class MonetarioAgregadosForm(DominioForm, StartDateForm, EndDateForm, SemanaIniForm, SemanaFinForm, MesIniForm, MesFinForm, AnhoIniForm, AnhoFinForm):
400    """!
401    Clase que contiene el formulario para la carga de datos de Agregados Monetarios
402
403    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
404    @author Edgar A. Linares (elinares at cenditel.gob.ve)
405    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
406    @date 19-09-2016
407    @date 30-05-2017
408    @version 1.0.0
409    """
410
411    def __init__(self, *args, **kwargs):
412        super(MonetarioAgregadosForm, self).__init__(*args, **kwargs)
413        self.fields['dominio'].choices = DOMINIO_AGREGADO_MONETARIO
414
415
416@python_2_unicode_compatible
417class MonetarioOperacionesInterbancariasForm(StartDateForm, EndDateForm):
418    """!
419    Clase que contiene el formulario para la carga de datos de Operaciones Interbancarias
420
421    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
422    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
423    @date 19-09-2016
424    @version 1.0.0
425    """
426
427
428@python_2_unicode_compatible
429class MonetarioTasasInteresForm(DominioForm, PeriodicidadForm, StartDateForm, EndDateForm, SemanaIniForm, SemanaFinForm, MesIniForm, MesFinForm, AnhoIniForm, AnhoFinForm):
430    """!
431    Clase que contiene el formulario para la carga de datos de Tasas de Interés
432
433    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
434    @author Edgar A. Linares (elinares at cenditel.gob.ve)
435    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
436    @date 19-09-2016
437    @date 26-04-2017
438    @version 1.0.0
439    """
440
441    def __init__(self, *args, **kwargs):
442        super(MonetarioTasasInteresForm, self).__init__(*args, **kwargs)
443        self.fields['dominio'].choices = DOMINIO_TASAS_INTERES
444        self.fields['periodicidad'].choices = PERIODICIDAD
445
446@python_2_unicode_compatible
447class MonetarioInstrumentoPoliticaForm(MesIniForm, MesFinForm, AnhoIniForm, AnhoFinForm):
448    """!
449    Clase que contiene el formulario para la carga de datos de Instrumentos de Políticas
450
451    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
452    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
453    @date 19-09-2016
454    @version 1.0.0
455    """
456
457@python_2_unicode_compatible
458class ExternoBalanzaComercialForm(TipoForm, DominioForm, AnhoBaseForm, TrimestreIniForm, TrimestreFinForm, AnhoIniForm, AnhoFinForm):
459    """!
460    Clase que contiene el formulario para la carga de datos de Balanza Comercial
461
462    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
463    @author Rodrigo Boet (rboet at cenditel.gob.ve)
464    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
465    @date 19-09-2016
466    @version 1.0.0
467    """
468
469    def __init__(self, *args, **kwargs):
470        super(ExternoBalanzaComercialForm, self).__init__(*args, **kwargs)
471        self.fields['tipo'].choices = TIPO_BALANZA_COMERCIAL
472        self.fields['dominio'].choices = DOMINIO_BALANZA_COMERCIAL
473        self.fields['anho_base'].choices = cargar_anho_base(anho_inicial='1997',anho_final='1997')
474        self.fields['anho_base'].required = False
475        ## Se deshabilitan los campos
476        self.fields['dominio'].widget.attrs.update({'disabled': True})
477        self.fields['anho_base'].widget.attrs.update({'disabled': True})
478        self.fields['periodo_trimestre_ini'].widget.attrs.update({'disabled': True})
479        self.fields['periodo_trimestre_fin'].widget.attrs.update({'disabled': True})
480        self.fields['periodo_anho_ini'].widget.attrs.update({'disabled': True})
481        self.fields['periodo_anho_fin'].widget.attrs.update({'disabled': True})
482        ## Se agregan las funciones javascript
483        self.fields['tipo'].widget.attrs.update({'onchange': 'edit_dom_bc($(this).val(),"id_dominio");'})
484
485
486@python_2_unicode_compatible
487class ExternoCuentaCapitalForm(forms.Form):
488    """!
489    Clase que contiene el formulario para la carga de datos de Cuentas de Capital
490
491    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
492    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
493    @date 19-09-2016
494    @version 1.0.0
495    """
496    pass
497
498
499@python_2_unicode_compatible
500class ExternoReservaCambioForm(
501    DominioForm, StartDateForm, EndDateForm, SemanaIniForm, SemanaFinForm, MesIniForm, MesFinForm, AnhoIniForm, AnhoFinForm
502):
503    """!
504    Clase que contiene el formulario para la carga de datos de Reservas - Tipo de Cambio
505
506    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
507    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
508    @date 19-09-2016
509    @version 1.0.0
510    """
511
512    def __init__(self, *args, **kwargs):
513        super(ExternoReservaCambioForm, self).__init__(*args, **kwargs)
514        self.fields['dominio'].choices = DOMINIO_CAMBIO
515
516
517@python_2_unicode_compatible
518class FiscalForm(AnhoIniForm, AnhoFinForm):
519    """!
520    Clase que contiene el formulario para la carga de datos de Registros Fiscales
521
522    @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve)
523    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
524    @date 19-09-2016
525    @version 1.0.0
526    """
527   
528   
529@python_2_unicode_compatible
530class CapitalForm(DominioForm, TrimestreIniForm, TrimestreFinForm, AnhoIniForm, AnhoFinForm):
531    """!
532    Clase que contiene el formulario para la carga de datos de Cuenta Capital
533
534    @author Rodrigo Boet (rboet at cenditel.gob.ve)
535    @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
536    @date 23-03-2017
537    @version 1.0.0
538    """
539    def __init__(self, *args, **kwargs):
540        super(CapitalForm, self).__init__(*args, **kwargs)
541        self.fields['dominio'].choices = DOMINIO_CUENTA_CAPITAL
542        ## Se deshabilitan los campos
543        self.fields['periodo_trimestre_ini'].widget.attrs.update({'disabled': True})
544        self.fields['periodo_trimestre_fin'].widget.attrs.update({'disabled': True})
545        self.fields['periodo_anho_ini'].widget.attrs.update({'disabled': True})
546        self.fields['periodo_anho_fin'].widget.attrs.update({'disabled': True})
547        ## Se agregan las funciones en javascript
548        self.fields['dominio'].widget.attrs.update({'onchange': 'edit_fields_cc($(this).val());'})
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.