Пример #1
0
def delete(request):
    p = Card(pk=request.REQUEST['id'])
    try:
        p.delete()
        data = '{"success":true}'
    except Exception, e1:
        data = '{"success":false, "msg": "%s"}' % (e1.args)
Пример #2
0
def save(request):
    req = request.REQUEST
    t = PaymentType(pk=req['paymentType.id'])
    p = Card(name=req['name'].capwords(), paymentType=t)
    data = '{"success":true}'
    try:
        p.save()
    except IntegrityError:
        data = '{"success":false, "msg": "%s"}' % (_("Card '%s' already exists.") % (req['name']))
    except _mysql_exceptions.Warning:
        pass
    except Exception, e1:
        data = '{"success":false, "msg": "%s"}' % (e1.args)