def delete(request): try: deleteParams = viewutil.request_params(request) deltype = deleteParams['type'] if not request.user.has_perm('tracker.delete_' + permmap.get(deltype, deltype)): return HttpResponse('Access denied', status=403, content_type='text/plain;charset=utf-8') obj = modelmap[deltype].objects.get(pk=deleteParams['id']) logutil.deletion(request, obj) obj.delete() return HttpResponse(json.dumps( { 'result': u'Object %s of type %s deleted' % (deleteParams['id'], deleteParams['type']) }, ensure_ascii=False), content_type='application/json;charset=utf-8') except IntegrityError, e: return HttpResponse(json.dumps({'error': u'Integrity error: %s' % e}, ensure_ascii=False), status=400, content_type='application/json;charset=utf-8')
def delete(request): try: deleteParams = viewutil.request_params(request) deltype = deleteParams['type'] if not request.user.has_perm('tracker.delete_' + permmap.get(deltype,deltype)): return HttpResponse('Access denied',status=403,content_type='text/plain;charset=utf-8') obj = modelmap[deltype].objects.get(pk=deleteParams['id']) logutil.deletion(request, obj) obj.delete() return HttpResponse(json.dumps({'result': u'Object %s of type %s deleted' % (deleteParams['id'], deleteParams['type'])}, ensure_ascii=False), content_type='application/json;charset=utf-8') except IntegrityError, e: return HttpResponse(json.dumps({'error': u'Integrity error: %s' % e}, ensure_ascii=False), status=400, content_type='application/json;charset=utf-8')
def delete(request): delete_params = request.POST delete_type = delete_params['type'] Model = modelmap.get(delete_type, None) if Model is None: raise KeyError('%s is not a recognized model type' % delete_type) obj = Model.objects.get(pk=delete_params['id']) model_admin = get_admin(Model) if not model_admin.has_delete_permission(request, obj): raise PermissionDenied('You do not have permission to delete that model') logutil.deletion(request, obj) obj.delete() return HttpResponse( json.dumps( { 'result': 'Object %s of type %s deleted' % (delete_params['id'], delete_params['type']) }, ensure_ascii=False, ), content_type='application/json;charset=utf-8', )