Ejemplo n.º 1
0
    def wrapper(request, *args, **kwargs):
        from review import logic as reviewer_logic

        access_code = reviewer_logic.get_access_code(request)
        assignment_id = kwargs['assignment_id']

        if not access_code:
            check = base_check(request, login_redirect=True)
            if check is False:
                deny_access(request)
            elif check is not True:
                return check

        if access_code is not None:
            try:
                assignment = review_models.ReviewAssignment.objects.get(
                    pk=assignment_id, access_code=access_code)

                if assignment:
                    return func(request, *args, **kwargs)
                else:
                    deny_access(request)

            except review_models.ReviewAssignment.DoesNotExist:
                deny_access(request)

        if request.user.is_anonymous() or not request.user.is_active:
            deny_access(request)

        if not request.user.is_reviewer(request):
            deny_access(request)

        try:
            if request.user.is_staff:
                assignment = review_models.ReviewAssignment.objects.get(
                    pk=assignment_id)

                if assignment:
                    return func(request, *args, **kwargs)
                else:
                    deny_access(request)

            assignment = review_models.ReviewAssignment.objects.get(
                pk=assignment_id, reviewer=request.user)

            if assignment:

                if assignment.article.stage != models.STAGE_ASSIGNED \
                        and assignment.article.stage != models.STAGE_UNDER_REVIEW:
                    deny_access(request)
                else:
                    return func(request, *args, **kwargs)
            else:
                deny_access(request)
        except review_models.ReviewAssignment.DoesNotExist:
            deny_access(request)
Ejemplo n.º 2
0
    def wrapper(request, *args, **kwargs):
        from review import logic as reviewer_logic

        access_code = reviewer_logic.get_access_code(request)
        assignment_id = kwargs['assignment_id']

        if not access_code and not base_check(request):
            return redirect('{0}?next={1}'.format(reverse('core_login'),
                                                  request.path))

        if access_code is not None:
            try:
                assignment = review_models.ReviewAssignment.objects.get(
                    pk=assignment_id, access_code=access_code)

                if assignment:
                    return func(request, *args, **kwargs)
                else:
                    raise PermissionDenied

            except review_models.ReviewAssignment.DoesNotExist:
                raise PermissionDenied

        if request.user.is_anonymous() or not request.user.is_active:
            raise PermissionDenied

        if not request.user.is_reviewer(request):
            raise PermissionDenied

        try:
            if request.user.is_staff:
                assignment = review_models.ReviewAssignment.objects.get(
                    pk=assignment_id)

                if assignment:
                    return func(request, *args, **kwargs)
                else:
                    raise PermissionDenied

            assignment = review_models.ReviewAssignment.objects.get(
                pk=assignment_id, reviewer=request.user)

            if assignment:

                if assignment.article.stage != models.STAGE_ASSIGNED \
                        and assignment.article.stage != models.STAGE_UNDER_REVIEW:
                    raise PermissionDenied
                else:
                    return func(request, *args, **kwargs)
            else:
                raise PermissionDenied
        except review_models.ReviewAssignment.DoesNotExist:
            raise PermissionDenied