[f85582e] | 1 | """ |
---|
| 2 | Sistema Estadístico Integral de Venezuela - (SEIVEN) |
---|
| 3 | |
---|
| 4 | Copyleft (@) 2015 CENDITEL nodo Mérida - https://mpv.cenditel.gob.ve/seiven |
---|
| 5 | """ |
---|
| 6 | ## @namespace base.models |
---|
| 7 | # |
---|
| 8 | # Contiene las clases, atributos y métodos para el modelo de datos de usuario |
---|
| 9 | # @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 10 | # @author <a href='http://www.cenditel.gob.ve'>Centro Nacional de Desarrollo e Investigación en Tecnologías Libres |
---|
| 11 | # (CENDITEL) nodo Mérida - Venezuela</a> |
---|
| 12 | # @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 13 | from __future__ import unicode_literals |
---|
| 14 | from django.contrib.auth.models import User |
---|
| 15 | from django.core import validators |
---|
[3e336b1] | 16 | from django.db import models |
---|
[f85582e] | 17 | from django.utils import six |
---|
| 18 | from django.utils.encoding import python_2_unicode_compatible |
---|
| 19 | from django.utils.translation import ugettext_lazy as _ |
---|
| 20 | |
---|
| 21 | |
---|
[0ce0b64] | 22 | class ModelManagerReadOnly(models.Manager): |
---|
| 23 | """! |
---|
| 24 | Clase que gestiona el método de actualización de datos |
---|
| 25 | |
---|
| 26 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 27 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 28 | @date 18-09-2017 |
---|
| 29 | @version 1.0.0 |
---|
| 30 | """ |
---|
| 31 | |
---|
| 32 | def update(self, *args, **kwargs): |
---|
| 33 | """! |
---|
| 34 | Método que impide actualizar datos en los registros consultados que extiendan de este modelo |
---|
| 35 | |
---|
| 36 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 37 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 38 | @date 18-09-2017 |
---|
| 39 | """ |
---|
| 40 | pass |
---|
| 41 | |
---|
| 42 | class ModelReadOnly(models.Model): |
---|
| 43 | """! |
---|
| 44 | Clase que gestiona los objetos y atributos de los modelos, para la simulación de escenarios a partir de datos de fuentes diversas, |
---|
| 45 | como de solo lectura |
---|
| 46 | |
---|
| 47 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 48 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 49 | @date 18-09-2017 |
---|
| 50 | @version 1.0.0 |
---|
| 51 | """ |
---|
| 52 | |
---|
| 53 | ## Gestiona el ModelManager para solo lectura de datos |
---|
| 54 | objects = ModelManagerReadOnly() |
---|
| 55 | |
---|
| 56 | def save(self, *args, **kwargs): |
---|
| 57 | """! |
---|
| 58 | Método que impide registrar datos en los registros consultados que extiendan de este modelo |
---|
| 59 | |
---|
| 60 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 61 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 62 | @date 18-09-2017 |
---|
| 63 | """ |
---|
| 64 | pass |
---|
| 65 | |
---|
| 66 | def delete(self, *args, **kwargs): |
---|
| 67 | """! |
---|
| 68 | Método que impide eliminar datos en los registros consultados que extiendan de este modelo |
---|
| 69 | |
---|
| 70 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 71 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 72 | @date 18-09-2017 |
---|
| 73 | """ |
---|
| 74 | pass |
---|
| 75 | |
---|
| 76 | class Meta: |
---|
| 77 | """! |
---|
| 78 | Metaclase de la clase ModelReadOnly |
---|
| 79 | |
---|
| 80 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 81 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 82 | @date 18-09-2017 |
---|
| 83 | @version 1.0.0 |
---|
| 84 | """ |
---|
| 85 | |
---|
| 86 | ## Permite especificar los campos del modelo que son requeridos para interactuar con los datos, |
---|
| 87 | # sin necesidad de especificar todos los atributos de un modelo |
---|
| 88 | managed = False |
---|
| 89 | |
---|
| 90 | ## Establece el modelo de la clase como abstracto, lo cual no genera tablas en la base de datos |
---|
| 91 | abstract = True |
---|
| 92 | |
---|
[f85582e] | 93 | @python_2_unicode_compatible |
---|
| 94 | class Institucion(models.Model): |
---|
| 95 | """! |
---|
| 96 | Clase que gestiona los datos de las instituciones |
---|
| 97 | |
---|
| 98 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 99 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 100 | @date 19-08-2016 |
---|
| 101 | @version 1.0.0 |
---|
| 102 | """ |
---|
| 103 | |
---|
| 104 | ## Contiene el nombre de la institución |
---|
| 105 | nombre = models.CharField(max_length=75) |
---|
| 106 | |
---|
| 107 | ## Contiene una descripción sobre la institución |
---|
| 108 | descripcion = models.CharField(max_length=255) |
---|
| 109 | |
---|
| 110 | class Meta: |
---|
| 111 | """! |
---|
| 112 | Metaclase que permite establecer las propiedades de la clase Institucion |
---|
| 113 | |
---|
| 114 | @author Ing. Roldan Vargas rvargas at cenditel.gob.ve |
---|
| 115 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 116 | @date 19-08-2016 |
---|
| 117 | @version 1.0.0 |
---|
| 118 | """ |
---|
| 119 | verbose_name = _("Institución") |
---|
| 120 | verbose_name_plural = _("Instituciones") |
---|
| 121 | ordering = ("nombre",) |
---|
| 122 | |
---|
| 123 | def __str__(self): |
---|
| 124 | """! |
---|
| 125 | Método que muestra la información sobre la institución |
---|
| 126 | |
---|
| 127 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 128 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 129 | @date 19-08-2016 |
---|
| 130 | @param self <b>{object}</b> Objeto que instancia la clase |
---|
| 131 | @return Devuelve los datos de la institución |
---|
| 132 | """ |
---|
| 133 | return "%s" % six.text_type(self.nombre) |
---|
[02683ad] | 134 | |
---|
| 135 | |
---|
| 136 | @python_2_unicode_compatible |
---|
| 137 | class Estado(models.Model): |
---|
| 138 | """! |
---|
| 139 | Clase que contiene los Estados de un Pais |
---|
| 140 | |
---|
| 141 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 142 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 143 | @date 10-05-2016 |
---|
| 144 | @version 2.0.0 |
---|
| 145 | """ |
---|
| 146 | |
---|
| 147 | ## Nombre del Estado |
---|
| 148 | nombre = models.CharField(max_length=50) |
---|
| 149 | |
---|
| 150 | def __str__(self): |
---|
| 151 | """! |
---|
| 152 | Método que muestra la información sobre el Estado |
---|
| 153 | |
---|
| 154 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 155 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 156 | @date 29-06-2016 |
---|
| 157 | @param self <b>{object}</b> Objeto que instancia la clase |
---|
| 158 | @return Devuelve los datos del Estado |
---|
| 159 | """ |
---|
[40567da] | 160 | return self.nombre |
---|
| 161 | |
---|
| 162 | @python_2_unicode_compatible |
---|
| 163 | class AnhoBase(models.Model): |
---|
| 164 | """! |
---|
| 165 | Clase que contiene los años base del sistema |
---|
| 166 | |
---|
| 167 | @author William Páez (wpaez at cenditel.gob.ve) |
---|
| 168 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 169 | @date 14-07-2017 |
---|
| 170 | @version 1.0.0 |
---|
| 171 | """ |
---|
| 172 | |
---|
| 173 | anho = models.CharField(max_length=4, unique=True) |
---|
| 174 | |
---|
| 175 | class Meta: |
---|
| 176 | """! |
---|
| 177 | Metaclase que permite establecer las propiedades de la clase Anho |
---|
| 178 | |
---|
| 179 | @author William Páez (wpaez at cenditel.gob.ve) |
---|
| 180 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 181 | @date 14-07-2017 |
---|
| 182 | @version 1.0.0 |
---|
| 183 | """ |
---|
| 184 | verbose_name = _("Año Base") |
---|
| 185 | verbose_name_plural = _("Años Base") |
---|
| 186 | ordering = ("anho",) |
---|
| 187 | |
---|
| 188 | def __str__(self): |
---|
| 189 | """! |
---|
| 190 | Método que muestra la información sobre el año base |
---|
| 191 | |
---|
| 192 | @author William Páez (wpaez at cenditel.gob.ve) |
---|
| 193 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 194 | @date 14-07-2017 |
---|
| 195 | @version 1.0.0 |
---|
| 196 | """ |
---|
| 197 | return self.anho |
---|