def get(self, request, *args, **kwargs):
""" Makes a clone within the current mission of a specified test case """
# Verify the test case passed is an int and within the path's mission
id_to_clone = int(self.kwargs['pk'])
passed_mission_id = int(self.kwargs['mission'])
try:
test_case = TestDetail.objects.get(pk=id_to_clone)
except TestDetail.DoesNotExist:
return HttpResponse("Test case not found.", status=404)
if test_case.mission.id != passed_mission_id:
return HttpResponse("Test case not linked to specified mission.", status=400)
test_case.pk = None
test_case.test_case_status = 'NEW'
test_case.save()
return HttpResponse(reverse_lazy('mission-test-edit',
kwargs={'mission': test_case.mission.id, 'pk': test_case.pk}))
评论列表
文章目录