def borrar(request): response = {} form = TarjetaForm() if request.method == 'GET': pk = request.GET.get('id', None) tarjeta = get_object_or_404(Tarjeta, pk=pk, user=request.user) return render_to_response( 'Tarjeta/tarjeta/modal/_borrar_tarjeta_modal_contenido.html', RequestContext( request, { 'tarjeta': tarjeta, 'form': form, } ) ) pk = request.POST.get('id', None) tarjeta = get_object_or_404(Tarjeta, pk=pk, user=request.user) try: tarjeta.delete() response['result'] = 'OK' except: response['result'] = 'ERROR' return json_response(response)
def cargar_tarjeta_modal(request): from apps.funciones.views import json_response form = TarjetaForm() response = {} if request.method == 'POST': form = TarjetaForm(request.POST) if form.is_valid(): try: t = form.save(commit=False) t.user = request.user t.save() response['result'] = 'OK' response['tarjeta_id'] = t.id response['tarjeta_name'] = t.nombre except: response['result'] = 'ERROR' response['error_type'] = 'OTHER' else: errors = dict([(k, str(v[0])) for k, v in form.errors.items()]) response['result'] = 'ERROR' response['error_type'] = 'INVALID' response['errors'] = errors return json_response(response) else: raise Http404
def borrar(request): response = {} form = SueldoForm() if request.method == 'GET': pk = request.GET.get('id', None) sueldo = get_object_or_404(Sueldo, pk=pk, user=request.user) return render_to_response( 'Dinero/sueldos/modal/_borrar_sueldo_modal_contenido.html', RequestContext( request, { 'sueldo': sueldo, 'form': form, } ) ) pk = request.POST.get('id', None) sueldo = get_object_or_404(Sueldo, pk=pk, user=request.user) try: sueldo.delete() response['result'] = 'OK' except: response['result'] = 'ERROR' return json_response(response)
def modificar(request): response = {} if request.method == 'GET': pk = request.GET.get('id', None) sueldo = get_object_or_404(Sueldo, pk=pk, user=request.user) form = SueldoForm(instance=sueldo) return render_to_response( 'Dinero/sueldos/modal/_modificar_sueldo_modal_contenido.html', RequestContext( request, { 'sueldo': sueldo, 'form': form, } ) ) pk = request.POST.get('id', None) sueldo = get_object_or_404(Sueldo, pk=pk, user=request.user) form = SueldoForm(data=request.POST, instance=sueldo) if form.is_valid(): form.save() response['result'] = 'OK' else: response['result'] = 'ERROR' errors = dict([(k, str(v[0])) for k, v in form.errors.items()]) response['errors'] = errors return json_response(response)
def modificar(request): response = {} if request.method == 'GET': pk = request.GET.get('id', None) gasto = get_object_or_404(Gasto, pk=pk, user=request.user) form = GastoForm(instance=gasto) return render_to_response( 'Dinero/gastos/modal/_modificar_gasto_modal_contenido.html', RequestContext( request, { 'gasto': gasto, 'form': form, } ) ) pk = request.POST.get('id', None) gasto = get_object_or_404(Gasto, pk=pk, user=request.user) form = GastoForm(data=request.POST, instance=gasto) if form.is_valid(): form.save() response['result'] = 'OK' else: response['result'] = 'ERROR' errors = dict([(k, str(v[0])) for k, v in form.errors.items()]) response['errors'] = errors return json_response(response)
def borrar(request): response = {} form = GastoForm() if request.method == 'GET': pk = request.GET.get('id', None) gasto = get_object_or_404(Gasto, pk=pk, user=request.user) return render_to_response( 'Dinero/gastos/modal/_borrar_gasto_modal_contenido.html', RequestContext( request, { 'gasto': gasto, 'form': form, } ) ) pk = request.POST.get('id', None) gasto = get_object_or_404(Gasto, pk=pk, user=request.user) try: gasto.delete() response['result'] = 'OK' except: response['result'] = 'ERROR' return json_response(response)
def borrar(request): response = {} form = ProductoForm() if request.method == 'GET': pk = request.GET.get('id', None) producto = get_object_or_404(Producto, pk=pk, user=request.user) return render_to_response( 'Producto/modal/_borrar_producto_modal_contenido.html', RequestContext( request, { 'producto': producto, 'form': form, } ) ) pk = request.POST.get('id', None) producto = get_object_or_404(Producto, pk=pk, user=request.user) try: producto.delete() response['result'] = 'OK' except: response['result'] = 'ERROR' return json_response(response)
def modificar(request): response = {} if request.method == 'GET': pk = request.GET.get('id', None) beneficio = get_object_or_404(Beneficio, pk=pk) form = BeneficioForm(instance=beneficio) return render_to_response( 'Tarjeta/beneficio/modal/_modificar_beneficio_modal_contenido.html', RequestContext( request, { 'beneficio': beneficio, 'form': form, } ) ) pk = request.POST.get('id', None) beneficio = get_object_or_404(Beneficio, pk=pk) form = BeneficioForm(data=request.POST, instance=beneficio) if form.is_valid(): form.save() response['result'] = 'OK' else: response['result'] = 'ERROR' errors = dict([(k, str(v[0])) for k, v in form.errors.items()]) response['errors'] = errors return json_response(response)
def borrar(request): response = {} form = BeneficioForm() if request.method == 'GET': pk = request.GET.get('id', None) beneficio = get_object_or_404(Beneficio, pk=pk) return render_to_response( 'Tarjeta/beneficio/modal/_borrar_beneficio_modal_contenido.html', RequestContext( request, { 'beneficio': beneficio, 'form': form, } ) ) pk = request.POST.get('id', None) beneficio = get_object_or_404(Beneficio, pk=pk) try: beneficio.delete() response['result'] = 'OK' except: response['result'] = 'ERROR' return json_response(response)
def borrar(request): response = {} form = TarjetaForm() if request.method == 'GET': pk = request.GET.get('id', None) tarjeta = get_object_or_404(Tarjeta, pk=pk, user=request.user) return render_to_response( 'Tarjeta/tarjeta/modal/_borrar_tarjeta_modal_contenido.html', RequestContext(request, { 'tarjeta': tarjeta, 'form': form, })) pk = request.POST.get('id', None) tarjeta = get_object_or_404(Tarjeta, pk=pk, user=request.user) try: tarjeta.delete() response['result'] = 'OK' except: response['result'] = 'ERROR' return json_response(response)