From 0827a3749df0d1b7e282da7d97b62733f9dcddea Mon Sep 17 00:00:00 2001 From: Diana Huang Date: Wed, 12 Aug 2020 11:45:23 -0400 Subject: [PATCH] Add barebones toggles endpoint for development. --- lms/urls.py | 1 + openedx/core/djangoapps/waffle_utils/urls.py | 8 ++++++++ openedx/core/djangoapps/waffle_utils/views.py | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 openedx/core/djangoapps/waffle_utils/urls.py create mode 100644 openedx/core/djangoapps/waffle_utils/views.py diff --git a/lms/urls.py b/lms/urls.py index f737c67603..9e2c8b8567 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -144,6 +144,7 @@ urlpatterns = [ url(r'^api/commerce/', include(('commerce.api.urls', 'lms.djangoapps.commerce'), namespace='commerce_api')), url(r'^api/credit/', include('openedx.core.djangoapps.credit.urls')), + url(r'^api/toggles/', include('openedx.core.djangoapps.waffle_utils.urls')), url(r'^rss_proxy/', include('rss_proxy.urls')), url(r'^api/organizations/', include('organizations.urls', namespace='organizations')), diff --git a/openedx/core/djangoapps/waffle_utils/urls.py b/openedx/core/djangoapps/waffle_utils/urls.py new file mode 100644 index 0000000000..8d7e65cd39 --- /dev/null +++ b/openedx/core/djangoapps/waffle_utils/urls.py @@ -0,0 +1,8 @@ +""" URL definitions for waffle utils. """ + +from django.conf.urls import url +from openedx.core.djangoapps.waffle_utils.views import ToggleStateView + +urlpatterns = [ + url(r'^state/', ToggleStateView.as_view(), name="toggle_state"), +] diff --git a/openedx/core/djangoapps/waffle_utils/views.py b/openedx/core/djangoapps/waffle_utils/views.py new file mode 100644 index 0000000000..19e20a41cc --- /dev/null +++ b/openedx/core/djangoapps/waffle_utils/views.py @@ -0,0 +1,18 @@ +""" Views that we will use to view toggle state in edx-platform. """ +from edx_rest_framework_extensions.auth.jwt.authentication import JwtAuthentication +from edx_rest_framework_extensions.permissions import IsStaff + +from rest_framework.authentication import SessionAuthentication +from rest_framework import permissions, views +from rest_framework.response import Response + + +class ToggleStateView(views.APIView): + """ + An endpoint for displaying the state of toggles in edx-platform. + """ + authentication_classes = (JwtAuthentication, SessionAuthentication,) + permission_classes = (permissions.IsAuthenticated, IsStaff,) + + def get(self, request): + return Response("Hello")