Conjunto c079de3 en seiven


Ignorar:
Fecha y hora:
08/08/2017 13:58:38 (hace 7 años)
Autor:
Luis Barrios <nikeven@…>
Branches:
master
Children:
e214583
Parents:
40567da
Mensaje:

modificada descarga de archivo para precios

Ficheros:
1 añadido
7 editados

Leyenda

No modificado
Añadido
Eliminado
  • base/constant.py

    r29bb1e1 rc079de3  
    3636
    3737## Asunto del mensaje de información sobre la carga de datos
    38 EMAIL_SUBJECT_LOAD_DATA = "Gestión de Datos - SEIVEN"
     38EMAIL_SUBJECT_LOAD_DATA = "Gestion de Datos - SEIVEN"
    3939
    4040## Asunto del mensaje de información sobre la carga de datos
  • economico/forms.py

    r40567da rc079de3  
    189189    def __init__(self, *args, **kwargs):
    190190        super(AnhoIniForm, self).__init__(*args, **kwargs)
    191         self.fields['periodo_anho_ini'].choices = cargar_anho_base(anho_inicial='2007')
     191        self.fields['periodo_anho_ini'].choices = cargar_anho_base(anho_inicial='1970')
    192192
    193193
     
    214214    def __init__(self, *args, **kwargs):
    215215        super(AnhoFinForm, self).__init__(*args, **kwargs)
    216         self.fields['periodo_anho_fin'].choices = cargar_anho_base(anho_inicial='2007')
     216        self.fields['periodo_anho_fin'].choices = cargar_anho_base(anho_inicial='1970')
    217217
    218218
  • economico/models.py

    r40567da rc079de3  
    1919from django.utils.translation import ugettext_lazy as _
    2020from django.db.models import Q
    21 from datetime import datetime, timedelta
     21from datetime import datetime, date, time, timedelta
    2222from itertools import islice , cycle
    2323
    2424from base.constant import (
    25     DOMINIO, PERIODICIDAD, TRIMESTRES, MESES, ECONOMICO_SUB_AREA, CONVERT_MES, EMAIL_SUBJECT_LOAD_DATA,
     25    DOMINIO, PERIODICIDAD, TRIMESTRES, MESES, ECONOMICO_SUB_AREA, CONVERT_MES, EMAIL_SUBJECT_LOAD_DATA,EMAIL_SUBJECT_CM_RESULT,
    2626    TIPO_BALANZA_COMERCIAL, DOMINIO_BALANZA_COMERCIAL, BALANZA_DATOS, INVERSION_CARTERA, SECTOR_DEUDA
    2727)
    2828from base.functions import enviar_correo, check_val_data
    2929from base.models import AnhoBase
     30
     31import calendar
    3032
    3133import pyexcel
     
    9193            [
    9294                {'tag': str(_('Año')), 'cabecera': True}, {'tag': str(_('Mes')), 'cabecera': True}, {'tag': str(_('INPC')), 'cabecera': True},
     95               
    9396                {'tag': str(_('(1) Alimentos y Bebidas no Alcoholicas')), 'cabecera': True},
    9497                {'tag': str(_('(2) Bebidas Alcoholicas y Tabaco')), 'cabecera': True},
     
    104107                {'tag': str(_('(12) Restaurant y Hotel')), 'cabecera': True},
    105108                {'tag': str(_('(13) Bienes y Servicios Diversos')), 'cabecera': True},
     109
    106110                {'tag': str(_('Bienes durables')), 'cabecera': True},
    107111                {'tag': str(_('Bienes semidurables')), 'cabecera': True},
    108112                {'tag': str(_('Bienes no durables')), 'cabecera': True},
     113
    109114                {'tag': str(_('Bienes')), 'cabecera': True},
    110115                {'tag': str(_('Agrícolas')), 'cabecera': True},
     
    112117                {'tag': str(_('Agroindustrial')), 'cabecera': True},
    113118                {'tag': str(_('Otros manufacturados')), 'cabecera': True},
     119
    114120                {'tag': str(_('Total Servicios')), 'cabecera': True},
    115121                {'tag': str(_('Servicios Básicos')), 'cabecera': True},
    116122                {'tag': str(_('Otros Servicios')), 'cabecera': True},
     123
    117124                {'tag': str(_('Núcleo Inflacionario (NI)')), 'cabecera': True},
    118125                {'tag': str(_('Alimentos Elaborados')), 'cabecera': True},
     
    120127                {'tag': str(_('Bienes industriales excepto alimentos y textiles')), 'cabecera': True},
    121128                {'tag': str(_('Servicios no administrados')), 'cabecera': True},
     129
    122130                {'tag': str(_('Controlados')), 'cabecera': True},
    123131                {'tag': str(_('No Controlados')), 'cabecera': True}
     
    133141                kwargs['dominio'] = None
    134142                kwargs['ciudad'] = kwargs.pop('dominio')
     143                lst=['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']
     144                x = int (kwargs['fecha__month__lte']) - int (kwargs['fecha__month__gte']) + 1 +  12 * (int(kwargs['fecha__year__lte']) - int(kwargs['fecha__year__gte']))
     145                for i, val in enumerate(lst):
     146                    if lst[int(kwargs['fecha__month__gte'])-1] in val:
     147                        desired = list( islice( cycle( lst), i, i+x))
     148                        tmp=0
     149                        lolo=int (kwargs['fecha__year__gte'])
     150                        aux=1
     151                        for a in desired:
     152                            aux1=''
     153                            if a == 'Diciembre':
     154                                aux1=lolo+tmp
     155                                tmp=tmp+1
     156                            else:
     157                                aux1=lolo+tmp
     158                            aux=aux+1
     159                            fields.append([ {'tag': str(_(str(aux1)))}, {'tag': str(_(str(a)))}])
     160
    135161            else:
    136162                dominio, data_type = str(_('Ciudad')), 'C'
     
    140166                fields[0].insert(2, {'tag': '', 'cabecera': True})
    141167                fields[1].insert(2, {'tag': dominio, 'cabecera': True})
     168
     169                lst=['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']
     170                lst1=['Caracas','Maracay','Ciudad Guayana','Barcelona -Pto la Cruz','Valencia','Barquisimeto','Maracaibo','Mérida','Maturín','San Cristóbal','Resto Nacional']
     171
     172                x = int (kwargs['fecha__month__lte']) - int (kwargs['fecha__month__gte']) + 1 +  12 * (int(kwargs['fecha__year__lte']) - int(kwargs['fecha__year__gte']))
     173                for i, val in enumerate(lst):
     174                    if lst[int(kwargs['fecha__month__gte'])-1] in val:
     175                        desired = list( islice( cycle( lst), i, i+x))
     176                        tmp=0
     177                        lolo=int (kwargs['fecha__year__gte'])
     178                        aux,aux2=1,0
     179                        for a in desired:
     180                            aux1=''
     181                            if a == 'Diciembre':
     182                                aux1=lolo+tmp
     183                                tmp=tmp+1
     184                            else:
     185                                aux1=lolo+tmp
     186                            aux=aux+1
     187                            for q in range(0,11):
     188                                if lst1[q] == 'Caracas':
     189                                    fields.append([ {'tag': str(_(str(aux1))),'combine_row':11 }, {'tag': str(_(str(a))), 'combine_row1':11},{'tag': str(_(str(lst1[q])))}])
     190                                else:
     191                                    fields.append([{'tag':''},{'tag':''},{'tag': str(_(str(lst1[q])))}])
     192
     193
    142194
    143195        elif not 'dominio' in kwargs or not kwargs['dominio'] == 'C':
     
    11711223        anho_base, errors, result, message = '', '', True, ''
    11721224        load_data_msg = str(_("Datos Cargados"))
     1225
     1226        self.anho_base=AnhoBase.objects.get(id=kwargs['anho_base'])
     1227       
    11731228        for row in range(1,len(load_file.row_range())):
    11741229           
    11751230            try:
    1176                 real_demanda , created = DemandaGlobal.objects.update_or_create(anho=load_file[row,0], anho_base=kwargs['anho_base'], trimestre=load_file[row,1], demanda_global= load_file[row,2]+load_file[row,7])
     1231                real_demanda , created = DemandaGlobal.objects.update_or_create(anho=load_file[row,0], anho_base=self.anho_base, trimestre=load_file[row,1], demanda_global= load_file[row,2]+load_file[row,7])
    11771232                ## Se crea  o actualiza el objeto de Demanda Agregada Interna luego de validar el valor en la hoja de calculo
    11781233
     
    12001255
    12011256        ## Envia correo electronico al usuario indicando el estatus de la carga de datos
    1202         enviar_correo(user.email, 'gestion.informacion.load.mail', EMAIL_SUBJECT_CM_RESULT, {
     1257        enviar_correo(user.email, 'gestion.informacion.load.mail', EMAIL_SUBJECT_LOAD_DATA, {
    12031258            'load_data_msg': load_data_msg, 'administrador': administrador, 'admin_email': admin_email,
    12041259            'errors': errors
  • economico/templates/economico.precios.html

    rfddad90 rc079de3  
    111111            periodo_anho_ini.on('change', function() { set_filters() });
    112112            periodo_anho_fin.on('change', function() { set_filters() });
     113
     114            $('.fileinput-upload-button').click(function(event){
     115                event.preventDefault();
     116                var fdata = new FormData();
     117                fdata.append('file',file.files[0]);
     118                $.ajax({
     119                    url: URL_CARGAR_ARCHIVO_CM+models,
     120                    data: fdata,
     121                    contentType: false,
     122                    processData: false,
     123                    type: 'POST',
     124                    dataType: 'json',
     125                    success: function(data){
     126                        var msg = data.message ? data.result : data.error;
     127                        bootbox.alert(msg);
     128                    },
     129                    error: function(error){
     130                        console.log(error);
     131                    }
     132                });
     133            });
    113134        });
    114135    </script>
  • economico/templates/economico.reservas.tipo.cambio.html

    r0dd4577 rc079de3  
    5050            </div>
    5151            <div id='TipoCambio' style='display:none;'>
    52                 {% include 'base.down.up.files.html' with url_down='/gestion-informacion/ajax/descargar_archivo' url_up='/gestion-informacion/ajax/cargar_archivo' app='economico' mod='TipoCambio' %}   
     52                {% include 'base.down.up.files.html' with app='economico' mod='TipoCambio'%}    
    5353            </div>
    5454            <div id='ReservasInternacionales' style='display:none;'>
    55                 {% include 'base.down.up.files.html' with url_down='/gestion-informacion/ajax/descargar_archivo' url_up='/gestion-informacion/ajax/cargar_archivo' app='economico' mod='ReservasInternacionales' %}  
     55                {% include 'base.down.up.files.html' with app='economico' mod='ReservasInternacionales'%} 
    5656            </div>
    5757           
     
    135135        */
    136136            $(document).ready(function() {
    137             dominio.on('change', function() {set_filters()});
    138             start_date.on('change', function() { set_filters() });
    139             end_date.on('change', function() { set_filters() });
    140             end_date.on('keyup', function() { set_filters() });
     137                dominio.on('change', function() {set_filters()});
     138                start_date.on('change', function() { set_filters() });
     139                end_date.on('change', function() { set_filters() });
     140                end_date.on('keyup', function() { set_filters() });
    141141
    142         });
     142                $('.fileinput-upload-button').click(function(event){
     143                event.preventDefault();
     144                var fdata = new FormData();
     145                fdata.append('file',file.files[0]);
     146                $.ajax({
     147                    url: URL_CARGAR_ARCHIVO_CM+models,
     148                    data: fdata,
     149                    contentType: false,
     150                    processData: false,
     151                    type: 'POST',
     152                    dataType: 'json',
     153                        success: function(data){
     154                            var msg = data.message ? data.result : data.error;
     155                            bootbox.alert(msg);
     156                        },
     157                        error: function(error){
     158                            console.log(error);
     159                        }
     160                    });
     161                });
     162            });
    143163    </script>
    144164{% endblock %}
  • gestion_informacion/ajax.py

    r2037da0 rc079de3  
    7373        modelo = apps.get_model(app, mod)
    7474        workbook = xlwt.Workbook()
    75         sheet = workbook.add_sheet("Datos")
     75        sheet = workbook.add_sheet("Datos",cell_overwrite_ok=True)
    7676        instance = modelo()
    7777        datos = instance.gestion_init(**filter)
    7878        i = 0
    7979        for con in datos['fields']:
    80             index_col = 0
    81             style='align: horiz center;'
     80            index_col= 0
     81            style='align: horiz center; align: vert center;'
    8282            for cabecera in con:
    8383                if 'color' in cabecera:   
     
    8787                font_bold = xlwt.easyxf(style)
    8888                sheet.write(i, index_col, cabecera['tag'], font_bold)
     89                sheet.set_shrink()
     90               
    8991                if 'cabecera' in cabecera:
    9092                    sheet.col(i).width = int (333 * (len(cabecera['tag']) + 1))
    91                 index_col += 1
     93               
     94                if 'combine' in cabecera and cabecera['combine'] > 0:
     95                    sheet.merge(i, i, index_col, (index_col + (cabecera['combine']-1)), font_bold)
     96                    index_col = cabecera['combine'] + index_col
     97
     98                if 'dominio'in cabecera:
     99                    sheet.write(i, 2, cabecera['tag'], font_bold)
     100                if 'combine_row' in cabecera:
     101                    sheet.write_merge(i, i+10, 0,0, cabecera['tag'],font_bold)
     102                if 'combine_row1' in cabecera:
     103                    sheet.write_merge(i, i+10, 1,1, cabecera['tag'],font_bold)
     104                else:
     105                    index_col += 1           
    92106            i += 1
    93107
  • seiven/database_config.py

    re4d3930 rc079de3  
    44        'ENGINE': 'django.db.backends.postgresql',
    55        'NAME': 'seiven',
    6         'USER': 'postgres',
     6        'USER': 'admin',
    77        'PASSWORD': '123456',
    88        'HOST': 'localhost',
Nota: Vea TracChangeset para ayuda en el uso del visor de conjuntos de cambios.