Created
May 8, 2013 21:21
-
-
Save george-silva/5543762 to your computer and use it in GitHub Desktop.
view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@login_required | |
def dashboard(request): | |
usuario = request.user | |
perfil_analista = None | |
try: | |
perfil_analista = PerfilAnalistaFundiario.objects.get(user_id=usuario.id) | |
except: | |
raise PermissionDenied | |
orgao = perfil_analista.orgao_publico | |
municipios = orgao.municipios.all() | |
ufs = [uf.uf for uf in orgao.estados.all()] | |
municipios = municipios | Municipio.objects.filter(uf_sigla__in=ufs) | |
ids = municipios.values_list("id_ibge", flat=True) | |
content_type_id = ContentType.objects.get_for_model(Parcela) | |
object_ids = RequerimentoParcela.objects.filter(content_type_id=content_type_id).values_list("object_id", flat=True) | |
parcelas = Parcela.objects.filter(pk__in=object_ids) | |
parcelas_analise = RequerimentoParcela.objects.filter(parcela__municipios__id_ibge__in=ids).values_list("requerimento_id", flat=True) | |
requerimentos_analise = Requerimento.objects.filter(parcelas__in=parcelas_analise, | |
status=STATUS_REQUERIMENTO_PROTOCOLADO) | |
requerimentos_pendentes = Requerimento.objects.filter(analisado_por_id=request.user.pk, | |
status=STATUS_REQUERIMENTO_EM_ANALISE) | |
return render(request, "requerimentos/dashboard.html", {"cancelamentos_analise": requerimentos_analise, | |
"cancelamentos": requerimentos_pendentes}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment