def update_step_order(request):
if request.method == 'GET':
from urllib import unquote
update_order_form = StepOrderManipulateForm(request.GET)
if update_order_form.is_valid():
cd = update_order_form.cleaned_data
relations = list(filter(None, cd['step_order'].split(';')))
error_tag = 0
for relation in relations:
step_id, new_order = relation.split('=')
step = Protocol.objects.get(id=int(step_id), parent=int(cd['protocol']))
if (step.check_owner(request.user.id) or request.user.is_superuser):
step.update_order(int(new_order))
step.save()
else:
return error('Your are not owner of the step.')
if not error_tag:
return success('Your step has been updated.')
else:
return error(str(update_order_form.errors))
else:
return error('Method error')
评论列表
文章目录