def post(self, request, *args, **kwargs): checks = request.POST.getlist('checks') if not checks: mensaje = msg_render("<strong>Favor seleccione por lo menos un item</strong>") messages.add_message(request, messages.INFO, mensaje) url = request.META['HTTP_REFERER'] return HttpResponseRedirect(url) sort=request.POST.get('sort') ids = map(int, checks) clientes=view_cliente.objects.filter(pk__in=ids) accion=request.POST.get('accion') table = clientesTablePDF(clientes) if sort!='None': table.order_by = sort if accion=='A csv': RequestConfig(request).configure(table) return export_table_to_csv(cliente, request, table) elif accion=='A pdf': table.model=cliente RequestConfig(request).configure(table) pdf_name = 'base/generic_pdf_list.html' return PDFTemplateResponse(request, pdf_name, {'table':table})
def get(self, request, *args, **kwargs): self.object = self.get_object() if self.object.estado=='APR': mensaje = msg_render("La Rendicion esta Aprobada.... <strong>Imposible Eliminar</strong>") messages.add_message(self.request, messages.ERROR, mensaje, extra_tags='danger') url = self.request.META['HTTP_REFERER'] return HttpResponseRedirect(url) return super(RendicionDeleteView, self).get(request, *args, **kwargs)
def delete(self, request, *args, **kwargs): self.object = self.get_object() try: self.object.delete() success_message = msg_render(u"El concepto <strong>"+unicode(self.object.concepto)+u"</strong> eliminado con éxito") messages.add_message(request, messages.SUCCESS, success_message ) return HttpResponseRedirect(self.get_success_url(), ) except IntegrityError as e: e.tags='danger' dic={'messages': (e,), 'object': self.object} return render_to_response(self.template_name, dic, context_instance=RequestContext(request))
def form_invalid(self, form): try: persona = Persona.objects.get(cedula=self.request.POST['cedula']) except: persona = None alumno = Alumno.objects.filter(cedula=self.request.POST['cedula']) if persona and not alumno: alumno = Alumno(persona_ptr_id=persona.pk) alumno.__dict__.update(persona.__dict__) alumno.save() success_message = msg_render(u"El Alumno <strong>"+unicode(alumno.get_full_name)+u"</strong> agregado con éxito") messages.add_message(self.request, messages.SUCCESS, success_message ) return HttpResponseRedirect(self.get_success_url( alumno ), ) return super(AlumnoCreateView, self).form_invalid(form)
def post(self, request, *args, **kwargs): checks = request.POST.getlist("checks") if not checks: mensaje = msg_render("<strong>Favor seleccione por lo menos un item</strong>") messages.add_message(request, messages.INFO, mensaje) url = request.META["HTTP_REFERER"] return HttpResponseRedirect(url) sort = request.POST.get("sort") ids = map(int, checks) descuentos = Descuento.objects.filter(pk__in=ids) accion = request.POST.get("accion") table = DescuentoTablePDF(descuentos) if sort != "None": table.order_by = sort if accion == "A csv": RequestConfig(request).configure(table) return export_table_to_csv(Descuento, request, table) elif accion == "A pdf": table.model = self.model RequestConfig(request).configure(table) pdf_name = "base/generic_pdf_list.html" return PDFTemplateResponse( request, pdf_name, {"table": table, "request": self.get_context_data.im_self.request} ) elif accion == "Eliminar": perm = "descuentos.delete_descuento" if request.user.has_perm(perm): if request.POST.get("confirmar") == "True": return eliminar_bulk(request, descuentos) else: dic = {"object_list": descuentos} template_name = "base/generic_delete.html" return render_to_response(template_name, dic, context_instance=RequestContext(request, locals())) else: mensaje = "ACCESO RESTRINGIDO | Permiso Requerido: " + str(perm) messages.add_message(request, messages.ERROR, mensaje, extra_tags="danger") url = request.META["HTTP_REFERER"] return HttpResponseRedirect(url)
def post(self, request, *args, **kwargs): checks = request.POST.getlist('checks') if not checks: mensaje = msg_render("<strong>Favor seleccione por lo menos un item</strong>") messages.add_message(request, messages.INFO, mensaje) url = request.META['HTTP_REFERER'] return HttpResponseRedirect(url) sort=request.POST.get('sort') ids = map(int, checks) paises=pais.objects.filter(pk__in=ids) accion=request.POST.get('accion') table = paisesTablePDF(paises) if sort!='None': table.order_by = sort if accion=='A csv': RequestConfig(request).configure(table) return export_table_to_csv(pais, request, table) elif accion=='A pdf': table.model=pais RequestConfig(request).configure(table) pdf_name = 'base/generic_pdf_list.html' return PDFTemplateResponse(request, pdf_name, {'table':table}) elif accion=='Eliminar': perm = 'pais.delete_pais' if request.user.has_perm(perm): if request.POST.get("confirmar")=='True': return eliminar_bulk(request, paises) else: dic={'object_list':paises} template_name='base/generic_delete.html' return render_to_response(template_name, dic, context_instance=RequestContext(request, locals())) else: mensaje = "ACCESO RESTRINGIDO | Permiso Requerido: "+str(perm) messages.add_message(request, messages.ERROR, mensaje, extra_tags='danger') url = request.META['HTTP_REFERER'] return HttpResponseRedirect(url)
def get_success_url(self, instance): success_message = msg_render("La rendición Nro <strong>%s</strong> Aprobado con exito" % (str(instance.nro_rendicion))) messages.success(self.request, success_message) url = reverse('rendiciones:det_rendicion', kwargs={'pk': instance.id}) return redirect(url)
def recuperarPlan(request, pk): curso_alumno = CursoAlumno.objects.get(pk=int(pk)) curso_alumno.save() mensaje = msg_render("<strong>Plan Recuperado con exito</strong>") messages.add_message(request, messages.SUCCESS, mensaje) return HttpResponseRedirect(request.META['HTTP_REFERER'])
def get_success_url(self, instance): success_message = msg_render("El Alumno <strong>%s</strong> inscripto al curso <strong>%s</strong> con exito" % (str(instance.alumno), str(instance.curso) )) messages.success(self.request, success_message) url = reverse('catedras:det_curso_alumno', kwargs={'pk': instance.id}) return redirect(url)
def get_success_url(self, instance): success_message = msg_render("El Curso <strong>%s %s %s</strong> registrado con exito" % (str(instance.carrera), str(instance.dias), str(instance.turno) )) messages.success(self.request, success_message) url = reverse('catedras:det_curso', kwargs={'pk': instance.id}) return redirect(url)
def get_success_url(self, instance): success_message = msg_render("El Password de <strong>(%s)</strong> Modificado con exito" % (str(instance.username) )) messages.success(self.request, success_message) url = reverse('autorizaciones:det_usuario', kwargs={'pk': instance.id}) return redirect(url)