示例#1
0
        def inner(request, *args, **kwargs):
            application_status = _get_application(request, kwargs).values_list("status__status", flat=True)[0]

            if is_editable and application_status in CaseStatusEnum.read_only_statuses():
                return JsonResponse(
                    data={
                        "errors": {
                            "non_field_errors": [
                                strings.Applications.Generic.INVALID_OPERATION_FOR_READ_ONLY_CASE_ERROR
                            ]
                        }
                    },
                    status=status.HTTP_400_BAD_REQUEST,
                )

            if is_major_editable and application_status not in CaseStatusEnum.major_editable_statuses():
                return JsonResponse(
                    data={
                        "errors": {
                            "non_field_errors": [
                                strings.Applications.Generic.INVALID_OPERATION_FOR_NON_DRAFT_OR_MAJOR_EDIT_CASE_ERROR
                            ]
                        }
                    },
                    status=status.HTTP_400_BAD_REQUEST,
                )

            return func(request, *args, **kwargs)
示例#2
0
    def test_application_in_state_major_editable_success(self):
        application = self.create_standard_application_case(self.organisation)
        application.status = CaseStatus.objects.get(
            status=CaseStatusEnum.major_editable_statuses()[0])
        application.save()

        @application_in_state(is_major_editable=True)
        def a_view(request, *args, **kwargs):
            return HttpResponse()

        resp = a_view(request=None, pk=application.pk)
        self.assertEqual(resp.status_code, status.HTTP_200_OK)