def resubmit_job(request, test_job_id, method='resubmit'): testjob = get_object_or_404(TestJob.objects, pk=test_job_id) user = auth_user_from_request(request, request.user) project = testjob.target if not project.can_submit(user): return HttpResponse(status=401) call = getattr(testjob, method) ret_value = call() if ret_value: return HttpResponse(status=201) # return 403 when resubmit call is unsuccessful return HttpResponse(status=403)
def _log_entry(request, object, message, flag): from django.contrib.auth.models import AnonymousUser from django.contrib.contenttypes.models import ContentType from squad.http import auth_user_from_request user = request.user if isinstance(user, AnonymousUser): user = auth_user_from_request(request, request.user) if not isinstance(user, AnonymousUser): from django.contrib.admin.models import LogEntry LogEntry.objects.log_action( user_id=user.pk, content_type_id=ContentType.objects.get_for_model(object).pk, object_id=object.pk, object_repr=force_text(object), action_flag=flag, change_message=message, )
def resubmit_job(request, test_job_id, method='resubmit'): testjob = get_object_or_404(TestJob.objects, pk=test_job_id) user = auth_user_from_request(request, request.user) project = testjob.target if not project.can_submit_testjobs(user): return HttpResponse(status=401) call = getattr(testjob, method) try: ret_value = call() new_testjob = testjob.resubmitted_jobs.last() if new_testjob is not None: log_addition(request, new_testjob, "Create testjob as resubmission") except SubmissionIssue as e: return HttpResponse(str(e), status=500) if ret_value: return HttpResponse(status=201) # return 403 when resubmit call is unsuccessful return HttpResponse(status=403)
def health_check_view(request): user = auth_user_from_request(request, request.user) if user and user.is_staff: return MainHealthCheckView.as_view()(request) return HttpResponseForbidden()