[16cf088] | 1 | <<<<<<< HEAD |
---|
[94b3e3f] | 2 | from django.contrib import messages |
---|
| 3 | from django.core.urlresolvers import reverse_lazy |
---|
| 4 | from django.shortcuts import ( |
---|
| 5 | render, redirect, get_object_or_404 |
---|
| 6 | ) |
---|
[16cf088] | 7 | ======= |
---|
[bf47591] | 8 | from django.shortcuts import render |
---|
[248b1b4] | 9 | from django.views.generic import ListView, FormView |
---|
[16cf088] | 10 | >>>>>>> def10d28a56c05436aa09889ff50481aaec4bc4a |
---|
[8fa24c3] | 11 | from multi_form_view import MultiModelFormView |
---|
[94b3e3f] | 12 | from django.views.generic import FormView |
---|
[bf47591] | 13 | |
---|
[8fa24c3] | 14 | from .forms import * |
---|
| 15 | from participantes.forms import ( |
---|
| 16 | FormsetParticipanteEvento |
---|
| 17 | ) |
---|
[66158c7] | 18 | from .models import Evento |
---|
[8fa24c3] | 19 | |
---|
[94b3e3f] | 20 | class RegisterEvent(FormView): |
---|
[8fa24c3] | 21 | """! |
---|
| 22 | Muestra el formulario de registro de usuarios |
---|
| 23 | |
---|
| 24 | @author Ing. Leonel P. Hernandez M. (lhernandez at cenditel.gob.ve) |
---|
[5dea5ff] | 25 | @copyright <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>GNU Public License versión 3 (GPLv3)</a> |
---|
[8fa24c3] | 26 | @date 20-11-2017 |
---|
| 27 | @version 1.0.0 |
---|
| 28 | """ |
---|
[94b3e3f] | 29 | |
---|
[8fa24c3] | 30 | template_name = "register.event.html" |
---|
[16cf088] | 31 | <<<<<<< HEAD |
---|
[94b3e3f] | 32 | form_class = EventoForm |
---|
| 33 | form_participante = FormsetParticipanteEvento |
---|
| 34 | success_url = reverse_lazy('base:inicio') |
---|
| 35 | |
---|
| 36 | def get_context_data(self, **kwargs): |
---|
| 37 | context = super(RegisterEvent, self).get_context_data(**kwargs) |
---|
| 38 | if 'form' not in context: |
---|
| 39 | context['form'] = self.form_class() |
---|
| 40 | if 'form2' not in context: |
---|
| 41 | context['form2'] = self.form_participante |
---|
| 42 | return context |
---|
| 43 | |
---|
| 44 | def post(self, request, *args, **kwargs): |
---|
| 45 | nuevo_evento = self.form_class(request.POST).save(commit=False) |
---|
| 46 | nuevo_participante = self.form_participante(request.POST) |
---|
| 47 | consulta_api = 1 |
---|
| 48 | if self.form_class(request.POST).is_valid() and nuevo_participante.is_valid(): |
---|
| 49 | nuevo_evento.serial = consulta_api |
---|
| 50 | nuevo_evento.save() |
---|
| 51 | nuevo_participante.save() |
---|
| 52 | messages.success(self.request, "El usaurio %s, ha creado con exito,\ |
---|
| 53 | un nuevo envento %s" % |
---|
| 54 | (str(self.request.user), |
---|
| 55 | str(nuevo_evento))) |
---|
| 56 | else: |
---|
| 57 | messages.error(self.request, "Existe un error en el Formualario %s" % |
---|
| 58 | (str(self.form_class.errors, self.form_participante.errors))) |
---|
| 59 | return redirect(self.success_url) |
---|
[16cf088] | 60 | ======= |
---|
[8fa24c3] | 61 | form_classes = { |
---|
| 62 | 'event': EventoForm, |
---|
| 63 | 'participante': FormsetParticipanteEvento, |
---|
| 64 | } |
---|
| 65 | #success_url = reverse_lazy('users:home') |
---|
| 66 | record_id=None |
---|
[66158c7] | 67 | |
---|
| 68 | |
---|
| 69 | class ListEvent(ListView): |
---|
| 70 | """! |
---|
| 71 | Muestra el listado de eventos |
---|
| 72 | |
---|
| 73 | @author Rodrigo Boet (rboet at cenditel.gob.ve) |
---|
[5dea5ff] | 74 | @copyright <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>GNU Public License versión 3 (GPLv3)</a> |
---|
[66158c7] | 75 | @date 20-11-2017 |
---|
| 76 | @version 1.0.0 |
---|
| 77 | """ |
---|
| 78 | model = Evento |
---|
| 79 | template_name = "evento.list.html" |
---|
[248b1b4] | 80 | paginate_by = 5 |
---|
| 81 | |
---|
| 82 | class SignEvent(FormView): |
---|
| 83 | """! |
---|
| 84 | Muestra el formulario para buscar y luego firmar documento |
---|
| 85 | |
---|
| 86 | @author Rodrigo Boet (rboet at cenditel.gob.ve) |
---|
[5dea5ff] | 87 | @copyright <a href='https://www.gnu.org/licenses/gpl-3.0.en.html'>GNU Public License versión 3 (GPLv3)</a> |
---|
[248b1b4] | 88 | @date 20-11-2017 |
---|
| 89 | @version 1.0.0 |
---|
| 90 | """ |
---|
| 91 | form_class = FirmaEventoForm |
---|
[ae65f8e] | 92 | template_name = "evento.firma.html" |
---|
| 93 | |
---|
| 94 | def get_context_data(self, **kwargs): |
---|
| 95 | """! |
---|
| 96 | Metodo que permite cargar de nuevo valores en los datos de contexto de la vista |
---|
| 97 | |
---|
| 98 | @author Rodrigo Boet (rboet at cenditel.gob.ve) |
---|
| 99 | @copyright GNU/GPLv3 |
---|
| 100 | @date 20-11-2017 |
---|
| 101 | @param self <b>{object}</b> Objeto que instancia la clase |
---|
| 102 | @param kwargs <b>{object}</b> Objeto que contiene los datos de contexto |
---|
| 103 | @return Retorna los datos de contexto |
---|
| 104 | """ |
---|
| 105 | kwargs['nombre_evento'] = Evento.objects.get(pk=int(self.kwargs['pk'])) |
---|
[16cf088] | 106 | return super(SignEvent, self).get_context_data(**kwargs) |
---|
| 107 | >>>>>>> def10d28a56c05436aa09889ff50481aaec4bc4a |
---|