Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1b06edb6
Commit
1b06edb6
authored
Sep 11, 2014
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
display banner on course info page if user is not enrolled (TNL-286)
write failing tests for info page banner
parent
e569e090
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
4 deletions
+39
-4
lms/djangoapps/courseware/tests/test_course_info.py
+8
-1
lms/djangoapps/courseware/views.py
+12
-2
lms/templates/courseware/info.html
+19
-1
No files found.
lms/djangoapps/courseware/tests/test_course_info.py
View file @
1b06edb6
...
...
@@ -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
()])
...
...
lms/djangoapps/courseware/views.py
View file @
1b06edb6
...
...
@@ -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
:
...
...
lms/templates/courseware/info.html
View file @
1b06edb6
...
...
@@ -13,6 +13,24 @@
<
%
include
file=
"/dashboard/_dashboard_prompt_midcourse_reverify.html"
/>
% if show_enroll_banner:
<div
class=
"wrapper-msg urgency-low"
id=
"failed-verification-banner"
>
<div
class=
"msg msg-reverify is-dismissable"
>
<div
class=
"msg-content"
>
<h2
class=
"title"
>
${_("You are not enrolled yet")}
</h2>
<div
class=
"copy"
>
<p
class=
'enroll-message'
>
${_(u"You are not currently enrolled in this course. Sign up for it {link_start}here{link_end}!").format(
link_start=u"
<a
href=
{}
>
".format(url_to_enroll),
link_end=u"
</a>
"
)}
</p>
</div>
</div>
</div>
</div>
% endif
<
%
include
file=
"/courseware/course_navigation.html"
args=
"active_page='info'"
/>
<
%
block
name=
"js_extra"
>
...
...
@@ -36,7 +54,7 @@ $(document).ready(function(){
</div>
% endif
% endif
<h1>
${_("Course Updates
&
News")}
</h1>
${get_course_info_section(request, course, 'updates')}
</section>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment