Пример #1
0
    def get_context_data(self, **kwargs):
        context = super(LocalAnalysisView, self).get_context_data(**kwargs)
        municipio = int(self.request.GET.get("municipio", 3304557))

        horizonte = 60
        toi = 100
        corte = 100
        neg = 100
        try:
            toi = int(self.request.GET['toi'])
            corte = int(self.request.GET['corte'])
            neg = int(self.request.GET['neg'])
            horizonte = int(self.request.GET['horizonte'])
            processos = Simulador.simula_municipio(horizonte, toi, corte, neg, municipio)
        except KeyError:
            messages.error(self.request, "Todos os campos devem ser preenchidos")
            processos = Simulador.simula_municipio(horizonte, toi, corte, neg, municipio)
        #processos = processos.set_index("geocodigo")

        context.update({
            'municipio': geodict[municipio],
            'geocodigo': municipio,
            'mundict': json.dumps(list(mundict.items())),
            'geodict': json.dumps(geodict),
            'processos': int(processos),
            'horizonte': horizonte,
            'toi': toi,
            'corte': corte,
            'neg': neg,


        })
        return context
Пример #2
0
    def get_context_data(self, **kwargs):
        context = super(HomePageView, self).get_context_data(**kwargs)
        # messages.info(self.request, 'Bem Vindo ao Simulador de Processos Judiciais.')
        horizonte = 60
        toi = 100
        corte = 100
        neg = 100
        try:
            toi = int(self.request.GET['toi'])
            corte = int(self.request.GET['corte'])
            neg = int(self.request.GET['neg'])
            horizonte = int(self.request.GET['horizonte'])
            processos = Simulador.simula(horizonte, toi, corte, neg)
        except KeyError:
            messages.error(self.request, "Todos os campos devem ser preenchidos")
            processos = Simulador.simula(horizonte, toi, corte, neg)
        processos = processos.set_index("geocodigo")
        context.update({"processos": processos.Novos.astype(int).to_json() if isinstance(processos,
                                                                             pd.DataFrame) else json.dumps({}),
                        'horizonte': horizonte,
                        'toi': toi,
                        'corte': corte,
                        'neg': neg,
                        'geodict': json.dumps(geodict),
                        'total': processos.Novos.astype(int).sum()

        })
        return context