1 | # -*- coding: utf-8 -*- |
---|
2 | """ |
---|
3 | Sistema de Participación en Consultas |
---|
4 | |
---|
5 | Copyleft (@) 2017 CENDITEL nodo Mérida - https://planificacion.cenditel.gob.ve/trac/wiki/ModeladoTopicos_2017 |
---|
6 | """ |
---|
7 | ## @package base.views |
---|
8 | # |
---|
9 | # Vistas correspondientes a la aplicación base |
---|
10 | # @author Rodrigo Boet (rboet at cenditel.gob.ve) |
---|
11 | # @author <a href='http://www.cenditel.gob.ve'>Centro Nacional de Desarrollo e Investigación en TecnologÃas Libres |
---|
12 | # (CENDITEL) nodo Mérida - Venezuela</a> |
---|
13 | # @copyright <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>GNU Public License versión 3 (GPLv3)</a> |
---|
14 | # @version 1.0 |
---|
15 | from django.shortcuts import render |
---|
16 | from django.http import JsonResponse |
---|
17 | from django.apps import apps |
---|
18 | from django.views.generic import TemplateView |
---|
19 | from django.contrib.auth.mixins import LoginRequiredMixin |
---|
20 | from base.functions import cargar_municipios, cargar_parroquias |
---|
21 | |
---|
22 | import json |
---|
23 | |
---|
24 | class Inicio(TemplateView): |
---|
25 | """! |
---|
26 | Clase para mostrar el inicio del sistema |
---|
27 | |
---|
28 | @author Rodrigo Boet (rboet at cenditel.gob.ve) |
---|
29 | @copyright <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>GNU Public License versión 3 (GPLv3)</a> |
---|
30 | @date 24-04-2017 |
---|
31 | @version 1.0.0 |
---|
32 | """ |
---|
33 | template_name = "inicio.html" |
---|
34 | |
---|
35 | |
---|
36 | def buscar_municipio(request): |
---|
37 | """! |
---|
38 | Función buscar municipios (se puede filtrar por la entidad) |
---|
39 | |
---|
40 | @author Rodrigo Boet (robet at cenditel.gob.ve) |
---|
41 | @copyright <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>GNU Public License versión 3 (GPLv3)</a> |
---|
42 | @date 03-10-2017 |
---|
43 | @param request <b>{object}</b> Objeto que contiene la petición |
---|
44 | @return Devuelve un JsonResponse con los datos |
---|
45 | """ |
---|
46 | entidad = request.GET.get('entidad',None) |
---|
47 | if(entidad): |
---|
48 | data = cargar_municipios(entidad) |
---|
49 | else: |
---|
50 | data = cargar_municipios() |
---|
51 | return JsonResponse(data,safe=False) |
---|
52 | |
---|
53 | def buscar_parroquia(request): |
---|
54 | """! |
---|
55 | Función buscar parroquias (se puede filtrar por el municipio) |
---|
56 | |
---|
57 | @author Rodrigo Boet (robet at cenditel.gob.ve) |
---|
58 | @copyright <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>GNU Public License versión 3 (GPLv3)</a> |
---|
59 | @date 03-10-2017 |
---|
60 | @param request <b>{object}</b> Objeto que contiene la petición |
---|
61 | @return Devuelve un JsonResponse con los datos |
---|
62 | """ |
---|
63 | municipio = request.GET.get('municipio',None) |
---|
64 | if(municipio): |
---|
65 | data = cargar_parroquias(municipio) |
---|
66 | else: |
---|
67 | data = cargar_parroquias() |
---|
68 | return JsonResponse(data,safe=False) |
---|