Skip to content

Instantly share code, notes, and snippets.

@george-silva
Created May 8, 2013 21:21
Show Gist options
  • Save george-silva/5543762 to your computer and use it in GitHub Desktop.
Save george-silva/5543762 to your computer and use it in GitHub Desktop.
view
@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