AA-164: Performance fixes for course home

This commit is contained in:
Jeff LaJoie
2020-05-19 08:23:43 -04:00
parent 1703a88d46
commit efa7b3b816
5 changed files with 19 additions and 5 deletions

View File

@@ -65,7 +65,7 @@ def adjust_start_date(user, days_early_for_beta, start, course_key):
return start
def check_start_date(user, days_early_for_beta, start, course_key, display_error_to_user=True):
def check_start_date(user, days_early_for_beta, start, course_key, display_error_to_user=True, now=None):
"""
Verifies whether the given user is allowed access given the
start date and the Beta offset for the given course.
@@ -82,10 +82,11 @@ def check_start_date(user, days_early_for_beta, start, course_key, display_error
if start_dates_disabled and not masquerading_as_student:
return ACCESS_GRANTED
else:
now = datetime.now(UTC)
if start is None or in_preview_mode() or get_course_masquerade(user, course_key):
return ACCESS_GRANTED
if now is None:
now = datetime.now(UTC)
effective_start = adjust_start_date(user, days_early_for_beta, start, course_key)
if now > effective_start:
return ACCESS_GRANTED

View File

@@ -22,6 +22,8 @@ from opaque_keys.edx.keys import UsageKey
from path import Path as path
from six import text_type
from openedx.core.lib.cache_utils import request_cached
import branding
from course_modes.models import CourseMode
from lms.djangoapps.courseware.access import has_access
@@ -511,6 +513,7 @@ def get_course_assignment_date_blocks(course, user, request, num_return=None,
return date_blocks
@request_cached()
def get_course_assignments(course_key, user, request, include_access=False):
"""
Returns a list of assignment (at the subsection/sequential level) due dates for the given course.