[bf6bc0b] | 1 | # -*- coding: utf-8 -*- |
---|
| 2 | """ |
---|
| 3 | Sistema de Consulta Pública |
---|
| 4 | |
---|
| 5 | Copyleft (@) 2017 CENDITEL nodo Mérida - https://planificacion.cenditel.gob.ve/trac/wiki/ModeladoTopicos_2017 |
---|
| 6 | """ |
---|
| 7 | ## @package base.constant |
---|
| 8 | # |
---|
| 9 | # Contiene las clases, atributos y métodos para los widgets a implementar en los formularios |
---|
| 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='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 14 | # @version 1.0 |
---|
| 15 | from __future__ import unicode_literals |
---|
| 16 | |
---|
| 17 | from django.forms import MultiWidget, Select, TextInput |
---|
| 18 | from .constant import SHORT_NACIONALIDAD |
---|
| 19 | |
---|
| 20 | class CedulaWidget(MultiWidget): |
---|
| 21 | """! |
---|
| 22 | Clase que agrupa los widgets de los campos de nacionalidad y número de cédula de identidad |
---|
| 23 | |
---|
| 24 | @author Ing. Roldan Vargas (rvargas at cenditel.gob.ve) |
---|
| 25 | @copyright <a href='http://www.gnu.org/licenses/gpl-2.0.html'>GNU Public License versión 2 (GPLv2)</a> |
---|
| 26 | @date 26-04-2016 |
---|
| 27 | @version 2.0.0 |
---|
| 28 | """ |
---|
| 29 | |
---|
| 30 | def __init__(self, *args, **kwargs): |
---|
| 31 | |
---|
| 32 | widgets = ( |
---|
| 33 | Select( |
---|
| 34 | attrs={ |
---|
| 35 | 'class': 'select2 form-control', 'data-toggle': 'tooltip', |
---|
| 36 | 'title': "Seleccione la nacionalidad" |
---|
| 37 | }, choices=SHORT_NACIONALIDAD |
---|
| 38 | ), |
---|
| 39 | TextInput( |
---|
| 40 | attrs={ |
---|
| 41 | 'class': 'form-control text-center', 'placeholder': '00000000', 'data-mask': '00000000', |
---|
| 42 | 'data-toggle': 'tooltip', 'maxlength': '8', 'size':'7', 'data-rule-required': 'true', |
---|
| 43 | 'title': "Indique el número de Cédula de Identidad" |
---|
| 44 | } |
---|
| 45 | ) |
---|
| 46 | ) |
---|
| 47 | |
---|
| 48 | super(CedulaWidget, self).__init__(widgets, *args, **kwargs) |
---|
| 49 | |
---|
| 50 | def format_output(self, rendered_widgets): |
---|
| 51 | return ' - '.join(rendered_widgets) |
---|
| 52 | |
---|
| 53 | def decompress(self, value): |
---|
| 54 | if value: |
---|
| 55 | return [value[0], value[1:]] |
---|
| 56 | return [None, None] |
---|