Example #1
0
def delete(request):
    c = Category(pk=request.REQUEST['id'])
    try:
        c.delete()
        data = '{"success":true}'
    except Exception, e1:
        data = '{"success":false, "msg": "%s"}' % (e1.args)           
Example #2
0
def update(request):
    c = Category(pk=request.REQUEST['id'],name=request.REQUEST['name'])
    try:
        c.save()
        data = '{"success":true}'
    except IntegrityError:
        data = '{"success":false, "msg": "%s"}' % (_("Category '%s' already exists.") % (request.REQUEST['name']))
    except Exception, e1:
        data = '{"success":false, "msg": "%s"}' % (e1.args)