Conjunto de cambios 252e445 en seiven para economico


Ignorar:
Fecha y hora:
28/03/2017 11:36:07 (hace 7 años)
Autor:
root <root@…>
Branches:
master, carga
Children:
fddad90
Parents:
a5e36b8
Mensaje:

creada el template de oferta y creacion de archivos excel

Ubicación:
economico
Ficheros:
4 editados

Leyenda

No modificado
Añadido
Eliminado
  • economico/models.py

    r8ad3344 r252e445  
    873873        self.total_consolidado = self.total_petrolera + self.total_no_petrolera
    874874        super(PIBActividad, self).save(*args, **kwargs)
     875
     876
     877#-----------------------------Económico Real - Demanda Global
     878
     879@python_2_unicode_compatible
     880class DemandaGlobal(models.Model):
     881   
     882    ## Año base del registro
     883    anho_base = models.CharField(max_length=4, null=True)
     884
     885    ## Año al que pertenece el(los) registro(s)
     886    anho = models.CharField(max_length=4, verbose_name=_("Año"))
     887
     888    ## Trimestre seleccionado
     889    trimestre = models.CharField(max_length=2, choices=TRIMESTRES[1:], verbose_name=_("Trimestre"))
     890
     891   
     892    def gestion_init(self, *args, **kwargs):
     893        """!
     894        Método que permite descargar un archivo con los datos a gestionar
     895
     896        @author Ing. Luis Barrios (lbarrios at cenditel.gob.ve)
     897        @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
     898        @date 27-03-2017
     899        @param self <b>{object}</b> Objeto que instancia la clase
     900        @param args <b>{tupla}</b> Tupla con argumentos opcionales
     901        @param kwargs <b>{dic}</b> Diccionario con filtros opcionales
     902        @return Devuelve los datos a incluír en el archivo
     903        """
     904
     905        fields = [
     906            [
     907                {'tag': str(_("Año")), 'color': 'indigo', 'text_color': 'white', 'cabecera': True},
     908                {'tag': str(_("Trimestre")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     909                {'tag': str(_("Demanda Agregada Interna")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     910                {'tag': str(_("Gasto de consumo final del gobierno")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     911                {'tag': str(_("Gasto de consumo final privado")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     912                {'tag': str(_("Formación bruta de capital fijo")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     913                {'tag': str(_("Variación de existencias")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     914                {'tag': str(_("Exportaciones de bienes y servicios")), 'color': 'black', 'text_color': 'white', 'cabecera': True}
     915            ]
     916        ]
     917
     918        return {'fields': fields, 'output': 'demanda'}
     919
     920    def gestion_process(self, file, user, *args, **kwargs):
     921        """!
     922        Método que permite cargar y gestionar datos
     923
     924        @author Ing. Luis Barrios (lbarrios at cenditel.gob.ve)
     925        @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
     926        @date 27-03-2017
     927        @param self <b>{object}</b> Objeto que instancia la clase
     928        @param file <b>{string}</b> Ruta y nombre del archivo a gestionar
     929        @param user <b>{object}</b> Objeto que contiene los datos del usuario que realiza la acción
     930        @param args <b>{tupla}</b> Tupla con argumentos opcionales
     931        @param kwargs <b>{dic}</b> Diccionario con filtros opcionales
     932        @return Devuelve el resultado de la acción con su correspondiente mensaje
     933        """
     934        load_file = pyexcel.get_sheet(file_name=file)
     935        anho_base, i, col_ini, errors, result, message = '', 0, 2, '', True, ''
     936        load_data_msg = str(_("Datos Cargados"))
     937
     938
     939        if errors:
     940            message = str(_("Error procesando datos. Verifique su correo para detalles del error"))
     941            load_data_msg = str(_("Error al procesar datos del área Económica - Real"))
     942
     943
     944        ## Envia correo electronico al usuario indicando el estatus de la carga de datos
     945        enviar_correo(user.email, 'gestion.informacion.load.mail', EMAIL_SUBJECT_LOAD_DATA, {
     946            'load_data_msg': load_data_msg, 'administrador': administrador, 'admin_email': admin_email,
     947            'errors': errors
     948        })
     949
     950        return {'result': result, 'message': message}
     951
     952#-----------------------------Económico Real - Oferta Global
     953
     954@python_2_unicode_compatible
     955class OfertaGlobal(models.Model):
     956   
     957    ## Año base del registro
     958    anho_base = models.CharField(max_length=4, null=True)
     959
     960    ## Año al que pertenece el(los) registro(s)
     961    anho = models.CharField(max_length=4, verbose_name=_("Año"))
     962
     963    ## Trimestre seleccionado
     964    trimestre = models.CharField(max_length=2, choices=TRIMESTRES[1:], verbose_name=_("Trimestre"))
     965
     966   
     967    def gestion_init(self, *args, **kwargs):
     968        """!
     969        Método que permite descargar un archivo con los datos a gestionar
     970
     971        @author Ing. Luis Barrios (lbarrios at cenditel.gob.ve)
     972        @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
     973        @date 27-03-2017
     974        @param self <b>{object}</b> Objeto que instancia la clase
     975        @param args <b>{tupla}</b> Tupla con argumentos opcionales
     976        @param kwargs <b>{dic}</b> Diccionario con filtros opcionales
     977        @return Devuelve los datos a incluír en el archivo
     978        """
     979
     980        fields = [
     981            [
     982                {'tag': str(_("Año")), 'color': 'indigo', 'text_color': 'white', 'cabecera': True},
     983                {'tag': str(_("Trimestre")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     984                {'tag': str(_("Oferta Global")), 'color': 'blue', 'text_color': 'white', 'cabecera': True},
     985                {'tag': str(_("PIB")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     986                {'tag': str(_("Petróleo")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     987                {'tag': str(_("No Petróleo")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     988                {'tag': str(_("Derechos de Importación")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     989                {'tag': str(_("Impuestos netos sobre los productos")), 'color': 'orange', 'text_color': 'white', 'cabecera': True},
     990                {'tag': str(_("Importaciones y servicios")), 'color': 'black', 'text_color': 'white', 'cabecera': True}
     991
     992            ]
     993        ]
     994
     995        return {'fields': fields, 'output': 'oferta'}
     996
     997    def gestion_process(self, file, user, *args, **kwargs):
     998        """!
     999        Método que permite cargar y gestionar datos
     1000
     1001        @author Ing. Luis Barrios (lbarrios at cenditel.gob.ve)
     1002        @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a>
     1003        @date 27-03-2017
     1004        @param self <b>{object}</b> Objeto que instancia la clase
     1005        @param file <b>{string}</b> Ruta y nombre del archivo a gestionar
     1006        @param user <b>{object}</b> Objeto que contiene los datos del usuario que realiza la acción
     1007        @param args <b>{tupla}</b> Tupla con argumentos opcionales
     1008        @param kwargs <b>{dic}</b> Diccionario con filtros opcionales
     1009        @return Devuelve el resultado de la acción con su correspondiente mensaje
     1010        """
     1011        load_file = pyexcel.get_sheet(file_name=file)
     1012        anho_base, i, col_ini, errors, result, message = '', 0, 2, '', True, ''
     1013        load_data_msg = str(_("Datos Cargados"))
     1014
     1015
     1016        if errors:
     1017            message = str(_("Error procesando datos. Verifique su correo para detalles del error"))
     1018            load_data_msg = str(_("Error al procesar datos del área Económica - Real"))
     1019
     1020
     1021        ## Envia correo electronico al usuario indicando el estatus de la carga de datos
     1022        enviar_correo(user.email, 'gestion.informacion.load.mail', EMAIL_SUBJECT_LOAD_DATA, {
     1023            'load_data_msg': load_data_msg, 'administrador': administrador, 'admin_email': admin_email,
     1024            'errors': errors
     1025        })
     1026
     1027        return {'result': result, 'message': message}
     1028
  • economico/templates/economico.demanda.global.html

    rc822701 r252e445  
    6262                <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">{{ form.periodo_anho_fin }}</div>
    6363            </div>
    64             {% include 'base.down.up.files.html' %}
     64            {% include 'base.down.up.files.html' with app='economico' mod='DemandaGlobal' %}
    6565        </div>
    6666    </div>
    6767{% endblock %}
     68{% block extra_footer %}
     69    <script>
     70        var tipo = $('#{{ form.tipo.auto_id }}');
     71        var anho_base = $("#{{ form.anho_base.auto_id }}");
     72        var periodo_trimestre_ini = $("#{{ form.periodo_trimestre_ini.auto_id }}");
     73        var periodo_trimestre_fin = $("#{{ form.periodo_trimestre_fin.auto_id }}");
     74        var periodo_anho_ini = $("#{{ form.periodo_anho_ini.auto_id }}");
     75        var periodo_anho_fin = $("#{{ form.periodo_anho_fin.auto_id }}");
     76
     77        /**
     78         * Función que configura los filtros de acuerdo a la selección del usuario
     79         */
     80        function set_filters() {
     81            var filters = $("#filters"), json_filter = '';
     82
     83            if (tipo.val()) {
     84                json_filter += "\"tipo\": \"" + tipo.val() + "\",";
     85            }
     86            if (anho_base.val()) {
     87                json_filter += "\"anho_base\": \"" + anho_base.val() + "\",";
     88            }
     89            if (periodo_trimestre_ini.val()) {
     90                json_filter += "\"fecha__month__gte\": \"" + periodo_trimestre_ini.val() + "\",";
     91            }
     92            if (periodo_trimestre_fin.val()) {
     93                json_filter += "\"fecha__month__lte\": \"" + periodo_trimestre_fin.val() + "\",";
     94            }
     95            if (periodo_anho_ini.val()) {
     96                json_filter += "\"fecha__year__gte\": \"" + periodo_anho_ini.val() + "\",";
     97            }
     98            if (periodo_anho_fin.val()) {
     99                json_filter += "\"fecha__year__lte\": \"" + periodo_anho_fin.val() + "\",";
     100            }
     101
     102            if (json_filter) {
     103                json_filter = json_filter.slice(0, -1);
     104                filters.val(json_filter);
     105            }
     106        }
     107
     108        $(document).ready(function() {
     109            tipo.on('change', function() { set_filters() });
     110            anho_base.on('change', function() { set_filters() });
     111            periodo_trimestre_ini.on('change', function() { set_filters() });
     112            periodo_trimestre_fin.on('change', function() { set_filters() });
     113            periodo_anho_ini.on('change', function() { set_filters() });
     114            periodo_anho_fin.on('change', function() { set_filters() });
     115        });
     116    </script>
     117{% endblock %}
  • economico/templates/economico.oferta.global.html

    rc822701 r252e445  
    6262                <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">{{ form.periodo_anho_fin }}</div>
    6363            </div>
    64             {% include 'base.down.up.files.html' %}
     64            {% include 'base.down.up.files.html' with app='economico' mod='OfertaGlobal' %}
    6565        </div>
    6666    </div>
    6767{% endblock %}
     68{% block extra_footer %}
     69    <script>
     70        var tipo = $('#{{ form.tipo.auto_id }}');
     71        var anho_base = $("#{{ form.anho_base.auto_id }}");
     72        var periodo_trimestre_ini = $("#{{ form.periodo_trimestre_ini.auto_id }}");
     73        var periodo_trimestre_fin = $("#{{ form.periodo_trimestre_fin.auto_id }}");
     74        var periodo_anho_ini = $("#{{ form.periodo_anho_ini.auto_id }}");
     75        var periodo_anho_fin = $("#{{ form.periodo_anho_fin.auto_id }}");
     76
     77        /**
     78         * Función que configura los filtros de acuerdo a la selección del usuario
     79         */
     80        function set_filters() {
     81            var filters = $("#filters"), json_filter = '';
     82
     83            if (tipo.val()) {
     84                json_filter += "\"tipo\": \"" + tipo.val() + "\",";
     85            }
     86            if (anho_base.val()) {
     87                json_filter += "\"anho_base\": \"" + anho_base.val() + "\",";
     88            }
     89            if (periodo_trimestre_ini.val()) {
     90                json_filter += "\"fecha__month__gte\": \"" + periodo_trimestre_ini.val() + "\",";
     91            }
     92            if (periodo_trimestre_fin.val()) {
     93                json_filter += "\"fecha__month__lte\": \"" + periodo_trimestre_fin.val() + "\",";
     94            }
     95            if (periodo_anho_ini.val()) {
     96                json_filter += "\"fecha__year__gte\": \"" + periodo_anho_ini.val() + "\",";
     97            }
     98            if (periodo_anho_fin.val()) {
     99                json_filter += "\"fecha__year__lte\": \"" + periodo_anho_fin.val() + "\",";
     100            }
     101
     102            if (json_filter) {
     103                json_filter = json_filter.slice(0, -1);
     104                filters.val(json_filter);
     105            }
     106        }
     107
     108        $(document).ready(function() {
     109            tipo.on('change', function() { set_filters() });
     110            anho_base.on('change', function() { set_filters() });
     111            periodo_trimestre_ini.on('change', function() { set_filters() });
     112            periodo_trimestre_fin.on('change', function() { set_filters() });
     113            periodo_anho_ini.on('change', function() { set_filters() });
     114            periodo_anho_fin.on('change', function() { set_filters() });
     115        });
     116    </script>
     117{% endblock %}
  • economico/templates/economico.precios.html

    r17dcd3a r252e445  
    6060                <div class="col-xs-2 col-sm-2 col-md-2 col-lg-2">{{ form.periodo_anho_fin }}</div>
    6161            </div>
    62             {% include 'base.down.up.files.html' with app='economico' mod='Precios' %}
     62            {% include 'base.down.up.files.html' with app='economico' mod='Demanda Global' %}
    6363        </div>
    6464    </div>
Nota: Vea TracChangeset para ayuda en el uso del visor de conjuntos de cambios.