Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make XBlock views/handlers non-atomic requests. #23559

Merged
merged 1 commit into from Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lms/djangoapps/courseware/module_render.py
Expand Up @@ -16,6 +16,7 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.core.cache import cache
from django.db import transaction
from django.http import Http404, HttpResponse, HttpResponseForbidden
from django.middleware.csrf import CsrfViewMiddleware
from django.template.context_processors import csrf
Expand Down Expand Up @@ -994,6 +995,7 @@ def xqueue_callback(request, course_id, userid, mod_id, dispatch):

@csrf_exempt
@xframe_options_exempt
@transaction.non_atomic_requests
def handle_xblock_callback_noauth(request, course_id, usage_id, handler, suffix=None):
"""
Entry point for unauthenticated XBlock handlers.
Expand All @@ -1008,6 +1010,7 @@ def handle_xblock_callback_noauth(request, course_id, usage_id, handler, suffix=

@csrf_exempt
@xframe_options_exempt
@transaction.non_atomic_requests
def handle_xblock_callback(request, course_id, usage_id, handler, suffix=None):
"""
Generic view for extensions. This is where AJAX calls go.
Expand Down
4 changes: 2 additions & 2 deletions lms/djangoapps/courseware/tests/test_views.py
Expand Up @@ -273,8 +273,8 @@ class IndexQueryTestCase(ModuleStoreTestCase):
NUM_PROBLEMS = 20

@ddt.data(
(ModuleStoreEnum.Type.mongo, 10, 172),
(ModuleStoreEnum.Type.split, 4, 170),
(ModuleStoreEnum.Type.mongo, 10, 170),
(ModuleStoreEnum.Type.split, 4, 168),
)
@ddt.unpack
def test_index_query_counts(self, store_type, expected_mongo_query_count, expected_mysql_query_count):
Expand Down
2 changes: 2 additions & 0 deletions lms/djangoapps/courseware/views/index.py
Expand Up @@ -16,6 +16,7 @@
from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.views import redirect_to_login
from django.db import transaction
from django.http import Http404
from django.template.context_processors import csrf
from django.urls import reverse
Expand Down Expand Up @@ -95,6 +96,7 @@
CONTENT_DEPTH = 2


@method_decorator(transaction.non_atomic_requests, name='dispatch')
class CoursewareIndex(View):
"""
View class for the Courseware page.
Expand Down
1 change: 1 addition & 0 deletions lms/djangoapps/courseware/views/views.py
Expand Up @@ -1613,6 +1613,7 @@ def _track_successful_certificate_generation(user_id, course_id):
@require_http_methods(["GET", "POST"])
@ensure_valid_usage_key
@xframe_options_exempt
@transaction.non_atomic_requests
def render_xblock(request, usage_key_string, check_if_enrolled=True):
"""
Returns an HttpResponse with HTML content for the xBlock with the given usage_key.
Expand Down