Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/dev-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,12 @@ jobs:
exit 1
fi &&

if ! python3 scripts/check_dev_routes.py https://dev.procollab.ru; then
solution_templates_status="$(
docker compose -f docker-compose.dev-ci.yml exec -T web python -c \
'from procollab.settings import PROGRAM_SOLUTIONS_ENABLED; print(401 if PROGRAM_SOLUTIONS_ENABLED else 404)'
)"
if ! python3 scripts/check_dev_routes.py https://dev.procollab.ru \
--solution-templates-status "$solution_templates_status"; then
echo "Frontend/API routing smoke check failed" >&2
exit 1
fi &&
Expand Down
17 changes: 10 additions & 7 deletions partner_programs/solution_invitation_api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
"""HTTP-контракт C00 для принадлежащих решению приглашений."""

from django.conf import settings
from django.http import Http404
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response

from partner_programs import solution_invitations, solution_team
Expand Down Expand Up @@ -208,15 +210,16 @@ def post(self, request, pk, solution_id):


class MySolutionInvitationsView(SolutionAPIView):
# The global inbox keeps its pagination contract when V2 is archived.
permission_classes = [IsAuthenticated]

def get(self, request):
return Response(
invitation_page(
solution_invitations.visible_invitations(request.user).filter(
recipient=request.user
),
request,
)
invites = solution_invitations.visible_invitations(request.user).filter(
recipient=request.user
)
if not settings.PROGRAM_SOLUTIONS_ENABLED:
invites = invites.none()
return Response(invitation_page(invites, request))


class SolutionInvitationDetailView(SolutionAPIView):
Expand Down
5 changes: 5 additions & 0 deletions partner_programs/tests/test_program_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def test_v1_switch_selects_project_templates_and_archives_v2_routes(self):
)
archived.refresh_from_db()
self.assertEqual(archived.solution_storage_mode, "solution")
inbox = self.client.get("/solution-invitations/")
self.assertEqual(inbox.status_code, 200)
self.assertEqual(inbox.data, {"count": 0, "next": None, "previous": None, "results": []})
self.client.force_authenticate(None)
self.assertEqual(self.client.get("/solution-invitations/").status_code, 401)

def test_all_formats_start_private_without_fake_dates_and_enrollment(self):
for kind in ("case_championship", "hackathon", "noncompetitive"):
Expand Down
7 changes: 4 additions & 3 deletions scripts/check_dev_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def request(base_url, path, method="GET", context=None):
return response.status, response.headers.get_content_type(), response.read()


def check_routes(base_url, context=None):
def check_routes(base_url, context=None, *, solution_templates_status=401):
status, content_type, index = request(base_url, "/", context=context)
assert status == 200 and content_type == "text/html" and b"<app-root" in index, "SPA index unavailable"
for path in (*AUTH_PAGES, "/office/program/all", "/expert-password-reset/"):
Expand All @@ -46,7 +46,7 @@ def check_routes(base_url, context=None):
for path, method, expected in (
("/auth/users/current/", "GET", 401),
("/solution-invitations/?status=pending&limit=100&offset=0", "GET", 401),
("/solution-form-templates/", "GET", 401),
("/solution-form-templates/", "GET", solution_templates_status),
("/auth/reset_password/", "POST", 400),
("/auth/reset_password/confirm/", "POST", 400),
("/auth/reset_password/validate_token/", "POST", 400),
Expand All @@ -61,5 +61,6 @@ def check_routes(base_url, context=None):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("base_url")
parser.add_argument("--solution-templates-status", type=int, choices=(401, 404), default=401)
args = parser.parse_args()
check_routes(args.base_url.rstrip("/"))
check_routes(args.base_url.rstrip("/"), solution_templates_status=args.solution_templates_status)
Loading