Skip to content

Commit

Permalink
Added logic for new microsite themes (openedx#417)
Browse files Browse the repository at this point in the history
Added courses access to sign in and register pages.
Added logic to create sets of 4 courses for home page carousel.
  • Loading branch information
bronsondunbar authored and nicovanniekerk committed Feb 12, 2018
1 parent 61c190b commit a8235a4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
37 changes: 32 additions & 5 deletions common/djangoapps/student/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@
from openedx.core.djangoapps.theming import helpers as theming_helpers
from openedx.core.djangoapps.user_api import accounts as accounts_settings
from openedx.core.djangoapps.user_api.preferences import api as preferences_api
<<<<<<< HEAD
from openedx.core.djangoapps.waffle_utils import WaffleFlagNamespace, WaffleFlag
=======
<<<<<<< HEAD
>>>>>>> Added logic for new microsite themes (#417)
from openedx.core.djangolib.markup import HTML
from openedx.features.course_experience import course_home_url_name
from openedx.features.enterprise_support.api import get_dashboard_consent_notification
Expand Down Expand Up @@ -141,6 +145,8 @@
from util.milestones_helpers import get_pre_requisite_courses_not_completed
from util.password_policy_validators import validate_password_length, validate_password_strength
from xmodule.modulestore.django import modulestore
=======
>>>>>>> Added logic for new microsite themes (#417)

log = logging.getLogger("edx.student")
AUDIT_LOG = logging.getLogger("audit")
Expand Down Expand Up @@ -236,6 +242,21 @@ def index(request, extra_context=None, user=AnonymousUser()):
# Add marketable programs to the context.
context['programs_list'] = get_programs_with_type(request.site, include_hidden=False)

carousel_courses = []
carousel_courses.append([])
current_index = 0
limit = 4

for course in courses:
if len(carousel_courses[current_index]) < limit:
carousel_courses[current_index].append(course)
else:
carousel_courses.append([])
current_index += 1
carousel_courses[current_index].append(course)

context["carousel_courses"] = carousel_courses

return render_to_response('index.html', context)


Expand Down Expand Up @@ -480,9 +501,8 @@ def _cert_info(user, course_overview, cert_status, course_mode): # pylint: disa

return status_dict


@ensure_csrf_cookie
def signin_user(request):
def signin_user(request, user=AnonymousUser()):
"""Deprecated. To be replaced by :class:`student_account.views.login_and_registration_form`."""
external_auth_response = external_auth_login(request)
if external_auth_response is not None:
Expand All @@ -499,6 +519,9 @@ def signin_user(request):
third_party_auth_error = _(unicode(msg)) # pylint: disable=translation-of-non-string
break

courses = get_courses(user)
context = {'courses': courses}

context = {
'login_redirect_url': redirect_to, # This gets added to the query string of the "Sign In" button in the header
# Bool injected into JS to submit form if we're inside a running third-
Expand All @@ -510,14 +533,14 @@ def signin_user(request):
'platform_name',
settings.PLATFORM_NAME
),
'third_party_auth_error': third_party_auth_error
'third_party_auth_error': third_party_auth_error,
'courses': courses
}

return render_to_response('login.html', context)


@ensure_csrf_cookie
def register_user(request, extra_context=None):
def register_user(request, extra_context=None, user=AnonymousUser()):
"""Deprecated. To be replaced by :class:`student_account.views.login_and_registration_form`."""
# Determine the URL to redirect to following login:
redirect_to = get_next_url_for_login_page(request)
Expand All @@ -528,6 +551,9 @@ def register_user(request, extra_context=None):
if external_auth_response is not None:
return external_auth_response

courses = get_courses(user)
context = {'courses': courses}

context = {
'login_redirect_url': redirect_to, # This gets added to the query string of the "Sign In" button in the header
'email': '',
Expand All @@ -540,6 +566,7 @@ def register_user(request, extra_context=None):
),
'selected_provider': '',
'username': '',
'courses': courses
}

if extra_context is not None:
Expand Down
1 change: 0 additions & 1 deletion lms/djangoapps/branding/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

log = logging.getLogger(__name__)


@ensure_csrf_cookie
@cache_if_anonymous()
def index(request):
Expand Down

0 comments on commit a8235a4

Please sign in to comment.