diff --git a/docs/conf.py b/docs/conf.py index 3814abdc7..017e0112a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -80,4 +80,6 @@ from django.core import management -management.call_command("generateschema", ["--file", "api/ephios-open-api-schema.yml"]) +management.call_command( + "spectacular", ["--color", "--file", "api/ephios-open-api-schema.yml", "--api-version", "api"] +) diff --git a/ephios/api/urls.py b/ephios/api/urls.py index ab589ddae..adb3b997f 100644 --- a/ephios/api/urls.py +++ b/ephios/api/urls.py @@ -1,8 +1,7 @@ -from django.conf import settings from django.urls import include, path +from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerSplitView from oauth2_provider import views as oauth2_views from rest_framework import routers -from rest_framework.schemas import get_schema_view from ephios.api.access.views import ( AccessTokenCreateView, @@ -91,13 +90,13 @@ ), path( "schema/", - get_schema_view( - title="ephios", - description="ephios API", - version=settings.EPHIOS_VERSION, - url=settings.GET_SITE_URL(), - ), + SpectacularAPIView.as_view(), name="openapi-schema", ), + path( + "schema/swagger-ui/", + SpectacularSwaggerSplitView.as_view(url_name="openapi-schema"), + name="swagger-ui", + ), path("", include(router.urls)), ] diff --git a/ephios/api/views/users.py b/ephios/api/views/users.py index 9e92d0eed..42337629e 100644 --- a/ephios/api/views/users.py +++ b/ephios/api/views/users.py @@ -9,7 +9,6 @@ from rest_framework.generics import RetrieveAPIView from rest_framework.mixins import RetrieveModelMixin from rest_framework.relations import SlugRelatedField -from rest_framework.schemas.openapi import AutoSchema from rest_framework.serializers import ModelSerializer from rest_framework.viewsets import GenericViewSet @@ -66,7 +65,6 @@ class UserProfileMeView(RetrieveAPIView): queryset = UserProfile.objects.all() permission_classes = [IsAuthenticatedOrTokenHasScope] required_scopes = ["ME_READ"] - schema = AutoSchema(operation_id_base="OwnUserProfile") def get_object(self): if self.request.user is None: @@ -95,7 +93,6 @@ class UserByMailView(RetrieveModelMixin, GenericViewSet): lookup_url_kwarg = "email" lookup_field = "email" lookup_value_regex = "[^/]+" # customize to allow dots (".") in the lookup value - schema = AutoSchema(operation_id_base="UserProfileByMail") class UserParticipationView(viewsets.ReadOnlyModelViewSet): diff --git a/ephios/plugins/federation/models.py b/ephios/plugins/federation/models.py index 2ecc262d0..95c105ee2 100644 --- a/ephios/plugins/federation/models.py +++ b/ephios/plugins/federation/models.py @@ -183,10 +183,16 @@ def all_participations(self): return FederatedParticipation.objects.filter(federated_user=self.federated_user) def reverse_signup_action(self, shift): - return reverse("federation:shift_signup", kwargs={"pk": shift.pk}) + return reverse( + "federation:shift_signup", + kwargs={"pk": shift.pk, "guest": self.federated_user.federated_instance.pk}, + ) def reverse_event_detail(self, event): - return reverse("federation:event_detail", kwargs={"pk": event.pk}) + return reverse( + "federation:event_detail", + kwargs={"pk": event.pk, "guest": self.federated_user.federated_instance_id}, + ) @property def icon(self): diff --git a/ephios/plugins/federation/serializers.py b/ephios/plugins/federation/serializers.py index 482acfb3b..b91319e61 100644 --- a/ephios/plugins/federation/serializers.py +++ b/ephios/plugins/federation/serializers.py @@ -71,5 +71,9 @@ class Meta: def get_signup_url(self, obj): return urljoin( - settings.GET_SITE_URL(), reverse("federation:event_detail", kwargs={"pk": obj.pk}) + settings.GET_SITE_URL(), + reverse( + "federation:event_detail", + kwargs={"pk": obj.pk, "guest": self.context["federated_guest"].pk}, + ), ) diff --git a/ephios/plugins/federation/templates/federation/external_event_list.html b/ephios/plugins/federation/templates/federation/external_event_list.html index 98b27fad7..d8b87d8c8 100644 --- a/ephios/plugins/federation/templates/federation/external_event_list.html +++ b/ephios/plugins/federation/templates/federation/external_event_list.html @@ -6,6 +6,20 @@ {% translate "External events" %} {% endblock %} +{% block messages %} + {% if "error" in request.GET %} + + {% endif %} +{% endblock %} + {% block content %}

{% translate "External events" %}