def delete(request): p = Debits(pk=request.REQUEST["id"]) try: p.delete() data = '{"success":true}' except Exception, e1: data = '{"success":false, "msg": "%s"}' % (e1.args)
def req_to_obj(request): req = request.REQUEST if req.has_key("id"): obj = Debits.objects.get(pk=req["id"]) else: obj = Debits() obj.day = req["day"] obj.subCategory = SubCategory.objects.get(pk=req["subCategory.id"]) obj.paymentType = PaymentType.objects.get(pk=req["paymentType.id"]) obj.text = req["text"] obj.amount = req["amount"] obj.since = DateService.invert(req["since"]) return obj