From d9262d171999ab03879917ea072e425a2c618ccd Mon Sep 17 00:00:00 2001 From: Sebastien Mirolo Date: Mon, 17 Jun 2024 23:34:23 -0700 Subject: [PATCH] passes tests against testsite --- pages/urls/api/__init__.py | 5 +---- pages/urls/api/noauth2.py | 37 +++++++++++++++++++++++++++++++++++++ testsite/urls/__init__.py | 6 +----- testsite/wsgi.py | 4 ++-- 4 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 pages/urls/api/noauth2.py diff --git a/pages/urls/api/__init__.py b/pages/urls/api/__init__.py index 9229dd2..084dfd1 100644 --- a/pages/urls/api/__init__.py +++ b/pages/urls/api/__init__.py @@ -34,10 +34,7 @@ path('attendance/', include('pages.urls.api.sequences')), path('content/', include('pages.urls.api.readers')), path('content/', include('pages.urls.api.noauth')), - path('', PageElementAPIView.as_view(), - name="api_content"), - path('content', PageElementIndexAPIView.as_view(), - name="api_content_index"), + path('', include('pages.urls.api.noauth2')), # 'api/content' index path('progress/', include('pages.urls.api.progress')), path('', include('pages.urls.api.assets')) ] diff --git a/pages/urls/api/noauth2.py b/pages/urls/api/noauth2.py new file mode 100644 index 0000000..e9e9eb1 --- /dev/null +++ b/pages/urls/api/noauth2.py @@ -0,0 +1,37 @@ +# Copyright (c) 2024, DjaoDjin inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" +API URLs for readers who could be unauthenticated +""" +from ...compat import path +from ...api.elements import PageElementAPIView, PageElementIndexAPIView + + +urlpatterns = [ + path('content/', PageElementAPIView.as_view(), + name="api_content"), + path('content', PageElementIndexAPIView.as_view(), + name="api_content_index"), +] diff --git a/testsite/urls/__init__.py b/testsite/urls/__init__.py index 078b197..177e1d5 100644 --- a/testsite/urls/__init__.py +++ b/testsite/urls/__init__.py @@ -28,7 +28,6 @@ from pages.compat import include, path from pages.api.elements import PageElementIndexAPIView -from pages.api.sequences import SequencesIndexAPIView from ..views.app import IndexView @@ -47,10 +46,7 @@ path('api/progress/', include('pages.urls.api.progress')), path('api/content/', include('pages.urls.api.readers')), path('api/content/', include('pages.urls.api.noauth')), - path('api/content', PageElementIndexAPIView.as_view(), - name="api_content_index"), - path('api/sequences', SequencesIndexAPIView.as_view(), - name='api_sequences_index'), + path('api/', include('pages.urls.api.noauth2')), path('api/', include('pages.urls.api.assets')), path('', IndexView.as_view()), path('', include('pages.urls.views')), diff --git a/testsite/wsgi.py b/testsite/wsgi.py index fc8123e..1b83ee7 100644 --- a/testsite/wsgi.py +++ b/testsite/wsgi.py @@ -8,7 +8,8 @@ """ import os, signal -#pylint: disable=invalid-name +from django.core.wsgi import get_wsgi_application + def save_coverage(): sys.stderr.write("saving coverage\n") @@ -35,6 +36,5 @@ def save_coverage(): # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. -from django.core.wsgi import get_wsgi_application #pylint: disable=invalid-name application = get_wsgi_application()