jd = json.dumps({'status': 1, 'message': form.errors.as_text()}) return HttpJSONResponseBadRequest(content=jd) @user_passes_test(lambda u: u.has_perm('testruns.change_testcaserun')) @require_GET def remove(request, link_id): ''' Remove a specific link with ID ``link_id`` ''' from django.forms import IntegerField from django.forms import ValidationError field = IntegerField(min_value=1) try: value = field.clean(link_id) except ValidationError, err: jd = json.dumps({'status': 1, 'messages': '\n'.join(err.messages)}) return HttpJSONResponseBadRequest(content=jd) try: LinkReference.unlink(link_id) except Exception, err: jd = json.dumps({'status': 1, 'messages': str(err)}) return HttpJSONResponseBadRequest(content=jd) return HttpJSONResponse( content=json.dumps({ 'status': 0, 'messages': 'Link has been removed successfully.' }))
jd = json.dumps({'rc': 1, 'response': form.errors.as_text()}) return HttpJSONResponseBadRequest(content=jd) @user_passes_test(lambda u: u.has_perm('testruns.change_testcaserun')) @require_GET def remove(request, link_id): ''' Remove a specific link with ID ``link_id`` ''' from django.forms import IntegerField from django.forms import ValidationError field = IntegerField(min_value=1) try: value = field.clean(link_id) except ValidationError, err: jd = json.dumps({'rc': 1, 'response': '\n'.join(err.messages)}) return HttpJSONResponseBadRequest(content=jd) try: LinkReference.unlink(value) except Exception, err: jd = json.dumps({'rc': 1, 'response': str(err)}) return HttpJSONResponseBadRequest(content=jd) return HttpJSONResponse( content=json.dumps({ 'rc': 0, 'response': 'Link has been removed successfully.' }))
jd = json.dumps( {'rc': 1, 'response': form.errors.as_text()}) return HttpJSONResponseBadRequest(content=jd) @user_passes_test(lambda u: u.has_perm('testruns.change_testcaserun')) @require_GET def remove(request, link_id): ''' Remove a specific link with ID ``link_id`` ''' from django.forms import IntegerField from django.forms import ValidationError field = IntegerField(min_value=1) try: value = field.clean(link_id) except ValidationError, err: jd = json.dumps({'rc': 1, 'response': '\n'.join(err.messages)}) return HttpJSONResponseBadRequest(content=jd) try: LinkReference.unlink(value) except Exception, err: jd = json.dumps({'rc': 1, 'response': str(err)}) return HttpJSONResponseBadRequest(content=jd) return HttpJSONResponse( content=json.dumps( {'rc': 0, 'response': 'Link has been removed successfully.'}))
else: jd = json.dumps( { 'status': 1, 'message': form.errors.as_text() }) return HttpJSONResponseBadRequest(content=jd) @user_passes_test(lambda u: u.has_perm('testruns.change_testcaserun')) @require_GET def remove(request, link_id): ''' Remove a specific link with ID ``link_id`` ''' from django.forms import IntegerField from django.forms import ValidationError field = IntegerField(min_value=1) try: value = field.clean(link_id) except ValidationError, err: jd = json.dumps({ 'status': 1, 'messages': '\n'.join(err.messages) }) return HttpJSONResponseBadRequest(content=jd) try: LinkReference.unlink(link_id) except Exception, err: jd = json.dumps({ 'status': 1, 'messages': str(err) }) return HttpJSONResponseBadRequest(content=jd) return HttpJSONResponse( content=json.dumps( { 'status': 0, 'messages': 'Link has been removed successfully.' }))