diff --git a/lms/djangoapps/courseware/tests/test_course_info.py b/lms/djangoapps/courseware/tests/test_course_info.py index ba69b94166..d1f01b5288 100644 --- a/lms/djangoapps/courseware/tests/test_course_info.py +++ b/lms/djangoapps/courseware/tests/test_course_info.py @@ -20,12 +20,19 @@ class CourseInfoTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase): data="OOGIE BLOOGIE", display_name="updates" ) - def test_logged_in(self): + def test_logged_in_unenrolled(self): self.setup_user() url = reverse('info', args=[self.course.id.to_deprecated_string()]) resp = self.client.get(url) self.assertEqual(resp.status_code, 200) self.assertIn("OOGIE BLOOGIE", resp.content) + self.assertIn("You are not currently enrolled in this course", resp.content) + + def test_logged_in_enrolled(self): + self.enroll(self.course) + url = reverse('info', args=[self.course.id.to_deprecated_string()]) + resp = self.client.get(url) + self.assertNotIn("You are not currently enrolled in this course", resp.content) def test_anonymous_user(self): url = reverse('info', args=[self.course.id.to_deprecated_string()]) diff --git a/lms/djangoapps/courseware/views.py b/lms/djangoapps/courseware/views.py index 35adef43d6..20164db01f 100644 --- a/lms/djangoapps/courseware/views.py +++ b/lms/djangoapps/courseware/views.py @@ -19,7 +19,7 @@ from django.contrib.auth.decorators import login_required from django.views.decorators.http import require_GET from django.http import Http404, HttpResponse from django.shortcuts import redirect -from edxmako.shortcuts import render_to_response, render_to_string +from edxmako.shortcuts import render_to_response, render_to_string, marketing_link from django_future.csrf import ensure_csrf_cookie from django.views.decorators.cache import cache_control from django.db import transaction @@ -569,6 +569,14 @@ def course_info(request, course_id): reverifications = fetch_reverify_banner_info(request, course_key) studio_url = get_studio_url(course, 'course_info') + # link to where the student should go to enroll in the course: + # about page if there is not marketing site, SITE_NAME if there is + url_to_enroll = reverse(course_about, args=[course_id]) + if settings.FEATURES.get('ENABLE_MKTG_SITE'): + url_to_enroll = marketing_link('COURSES') + + show_enroll_banner = request.user.is_authenticated() and not CourseEnrollment.is_enrolled(request.user, course.id) + context = { 'request': request, 'course_id': course_key.to_deprecated_string(), @@ -578,6 +586,8 @@ def course_info(request, course_id): 'masquerade': masq, 'studio_url': studio_url, 'reverifications': reverifications, + 'show_enroll_banner': show_enroll_banner, + 'url_to_enroll': url_to_enroll, } return render_to_response('courseware/info.html', context) @@ -806,7 +816,7 @@ def _progress(request, course_key, student_id): Course staff are allowed to see the progress of students in their class. """ - course = get_course_with_access(request.user, 'load', course_key, depth=None) + course = get_course_with_access(request.user, 'load', course_key, depth=None, check_if_enrolled=True) staff_access = has_access(request.user, 'staff', course) if student_id is None or student_id == request.user.id: diff --git a/lms/templates/courseware/info.html b/lms/templates/courseware/info.html index 30470382c1..9b8b5b5e28 100644 --- a/lms/templates/courseware/info.html +++ b/lms/templates/courseware/info.html @@ -13,6 +13,24 @@ <%include file="/dashboard/_dashboard_prompt_midcourse_reverify.html" /> +% if show_enroll_banner: +
+
+
+

${_("You are not enrolled yet")}

+
+

+ ${_(u"You are not currently enrolled in this course. Sign up for it {link_start}here{link_end}!").format( + link_start=u"".format(url_to_enroll), + link_end=u"" + )} +

+
+
+
+
+% endif + <%include file="/courseware/course_navigation.html" args="active_page='info'" /> <%block name="js_extra"> @@ -36,7 +54,7 @@ $(document).ready(function(){ % endif % endif - +

${_("Course Updates & News")}

${get_course_info_section(request, course, 'updates')}