From 0ddf409b8e929dd211b41b8c88996daae222c4a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andre=CC=81s=20Gonza=CC=81lez?= Date: Fri, 19 Apr 2024 15:26:56 -0300 Subject: [PATCH] Add urls and view to process REST api requests --- panorama_openedx_backend/api/__init__.py | 0 panorama_openedx_backend/api/views.py | 19 +++++++++++++++++++ panorama_openedx_backend/apps.py | 8 ++++++++ panorama_openedx_backend/urls.py | 6 ++++-- 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 panorama_openedx_backend/api/__init__.py create mode 100644 panorama_openedx_backend/api/views.py diff --git a/panorama_openedx_backend/api/__init__.py b/panorama_openedx_backend/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/panorama_openedx_backend/api/views.py b/panorama_openedx_backend/api/views.py new file mode 100644 index 0000000..8383fd3 --- /dev/null +++ b/panorama_openedx_backend/api/views.py @@ -0,0 +1,19 @@ +from rest_framework.views import APIView +from rest_framework.permissions import IsAuthenticated +from rest_framework.response import Response + + +class GetDashboardEmbedUrl(APIView): + + permission_classes = (IsAuthenticated,) + + def get(self, request): + + user = request.user + + data = { + 'embed_url': 'Hola Panorama!!', + 'email': user.email, + } + + return Response(data) diff --git a/panorama_openedx_backend/apps.py b/panorama_openedx_backend/apps.py index ed56515..34e3a09 100644 --- a/panorama_openedx_backend/apps.py +++ b/panorama_openedx_backend/apps.py @@ -16,6 +16,14 @@ class PanoramaOpenedxBackendConfig(AppConfig): name = 'panorama_openedx_backend' plugin_app = { + 'url_config': { + 'lms.djangoapp': { + # 'namespace': 'panorama', + 'regex': 'panorama/api/get-embed-url', + 'relative_path': 'urls', + } + }, + "settings_config": { "lms.djangoapp": { "common": {"relative_path": "settings.common"}, diff --git a/panorama_openedx_backend/urls.py b/panorama_openedx_backend/urls.py index b92d37d..96d5b79 100644 --- a/panorama_openedx_backend/urls.py +++ b/panorama_openedx_backend/urls.py @@ -2,9 +2,11 @@ URLs for panorama_openedx_backend. """ from django.urls import re_path # pylint: disable=unused-import -from django.views.generic import TemplateView # pylint: disable=unused-import + +from panorama_openedx_backend.api.views import GetDashboardEmbedUrl + urlpatterns = [ # TODO: Fill in URL patterns and views here. - # re_path(r'', TemplateView.as_view(template_name="panorama_openedx_backend/base.html")), + re_path(r'', GetDashboardEmbedUrl.as_view(), name='get dashboard embed url'), ]