Skip to content

Commit

Permalink
feat: upgrading simple api to drf compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
awais786 committed Aug 16, 2024
1 parent c33eab2 commit 7358ae2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lms/djangoapps/instructor/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from opaque_keys.edx.keys import CourseKey, UsageKey
from openedx.core.djangoapps.course_groups.cohorts import get_cohort_by_name
from rest_framework.exceptions import MethodNotAllowed
from rest_framework.permissions import SAFE_METHODS
from rest_framework import serializers, status # lint-amnesty, pylint: disable=wrong-import-order
from rest_framework.permissions import IsAdminUser, IsAuthenticated # lint-amnesty, pylint: disable=wrong-import-order
from rest_framework.response import Response # lint-amnesty, pylint: disable=wrong-import-order
Expand Down Expand Up @@ -1501,7 +1502,6 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red

return JsonResponse({"status": success_status})

from rest_framework.permissions import SAFE_METHODS

@method_decorator(cache_control(no_cache=True, no_store=True, must_revalidate=True), name='dispatch')
@method_decorator(transaction.non_atomic_requests, name='dispatch')
Expand Down
1 change: 0 additions & 1 deletion openedx/core/djangoapps/theming/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ def get_theme_base_dir(theme_dir_name, suppress_error=False):
Returns:
(str): Base directory that contains the given theme
"""
return
for themes_dir in get_theme_base_dirs():
if theme_dir_name in get_theme_dirs(themes_dir):
return themes_dir
Expand Down
16 changes: 15 additions & 1 deletion openedx/core/djangoapps/theming/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,18 @@ def process_request(self, request):
Set the request's 'site_theme' attribute based upon the current user.
"""
# Specifying a "site_theme" querystring param takes precedence
pass
qs_theme = request.GET.get('site_theme')

# Determine if the user has specified a preview site
preview_site_theme = get_user_preview_site_theme(request)

if qs_theme:
site_theme = SiteTheme(site=request.site, theme_dir_name=qs_theme)
elif preview_site_theme:
site_theme = preview_site_theme
else:
default_theme = None
if settings.DEFAULT_SITE_THEME:
default_theme = SiteTheme(site=request.site, theme_dir_name=settings.DEFAULT_SITE_THEME)
site_theme = SiteTheme.get_theme(request.site, default=default_theme)
request.site_theme = site_theme

0 comments on commit 7358ae2

Please sign in to comment.