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
24ef6f76
Commit
24ef6f76
authored
Nov 13, 2012
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add backend for displaying news on the student dashboard
[#39472239]
parent
c01c17d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
42 deletions
+45
-42
common/djangoapps/student/views.py
+30
-15
lms/templates/dashboard.html
+14
-26
lms/templates/index.html
+1
-1
No files found.
common/djangoapps/student/views.py
View file @
24ef6f76
...
@@ -69,20 +69,6 @@ def index(request, extra_context={}, user=None):
...
@@ -69,20 +69,6 @@ def index(request, extra_context={}, user=None):
extra_context is used to allow immediate display of certain modal windows, eg signup,
extra_context is used to allow immediate display of certain modal windows, eg signup,
as used by external_auth.
as used by external_auth.
'''
'''
feed_data
=
cache
.
get
(
"students_index_rss_feed_data"
)
if
feed_data
==
None
:
if
hasattr
(
settings
,
'RSS_URL'
):
feed_data
=
urllib
.
urlopen
(
settings
.
RSS_URL
)
.
read
()
else
:
feed_data
=
render_to_string
(
"feed.rss"
,
None
)
cache
.
set
(
"students_index_rss_feed_data"
,
feed_data
,
settings
.
RSS_TIMEOUT
)
feed
=
feedparser
.
parse
(
feed_data
)
entries
=
feed
[
'entries'
][
0
:
3
]
for
entry
in
entries
:
soup
=
BeautifulSoup
(
entry
.
description
)
entry
.
image
=
soup
.
img
[
'src'
]
if
soup
.
img
else
None
entry
.
summary
=
soup
.
getText
()
# The course selection work is done in courseware.courses.
# The course selection work is done in courseware.courses.
domain
=
settings
.
MITX_FEATURES
.
get
(
'FORCE_UNIVERSITY_DOMAIN'
)
# normally False
domain
=
settings
.
MITX_FEATURES
.
get
(
'FORCE_UNIVERSITY_DOMAIN'
)
# normally False
...
@@ -90,7 +76,11 @@ def index(request, extra_context={}, user=None):
...
@@ -90,7 +76,11 @@ def index(request, extra_context={}, user=None):
domain
=
request
.
META
.
get
(
'HTTP_HOST'
)
domain
=
request
.
META
.
get
(
'HTTP_HOST'
)
universities
=
get_courses_by_university
(
None
,
universities
=
get_courses_by_university
(
None
,
domain
=
domain
)
domain
=
domain
)
context
=
{
'universities'
:
universities
,
'entries'
:
entries
}
# Get the 3 most recent news
top_news
=
_get_news
(
top
=
3
)
context
=
{
'universities'
:
universities
,
'news'
:
top_news
}
context
.
update
(
extra_context
)
context
.
update
(
extra_context
)
return
render_to_response
(
'index.html'
,
context
)
return
render_to_response
(
'index.html'
,
context
)
...
@@ -230,12 +220,16 @@ def dashboard(request):
...
@@ -230,12 +220,16 @@ def dashboard(request):
cert_statuses
=
{
course
.
id
:
cert_info
(
request
.
user
,
course
)
for
course
in
courses
}
cert_statuses
=
{
course
.
id
:
cert_info
(
request
.
user
,
course
)
for
course
in
courses
}
# Get the 3 most recent news
top_news
=
_get_news
(
top
=
3
)
context
=
{
'courses'
:
courses
,
context
=
{
'courses'
:
courses
,
'message'
:
message
,
'message'
:
message
,
'staff_access'
:
staff_access
,
'staff_access'
:
staff_access
,
'errored_courses'
:
errored_courses
,
'errored_courses'
:
errored_courses
,
'show_courseware_links_for'
:
show_courseware_links_for
,
'show_courseware_links_for'
:
show_courseware_links_for
,
'cert_statuses'
:
cert_statuses
,
'cert_statuses'
:
cert_statuses
,
'news'
:
top_news
,
}
}
return
render_to_response
(
'dashboard.html'
,
context
)
return
render_to_response
(
'dashboard.html'
,
context
)
...
@@ -883,3 +877,24 @@ def test_center_login(request):
...
@@ -883,3 +877,24 @@ def test_center_login(request):
return
redirect
(
'/courses/MITx/6.002x/2012_Fall/courseware/Final_Exam/Final_Exam_Fall_2012/'
)
return
redirect
(
'/courses/MITx/6.002x/2012_Fall/courseware/Final_Exam/Final_Exam_Fall_2012/'
)
else
:
else
:
return
HttpResponseForbidden
()
return
HttpResponseForbidden
()
def
_get_news
(
top
=
None
):
"Return the n top news items on settings.RSS_URL"
feed_data
=
cache
.
get
(
"students_index_rss_feed_data"
)
if
feed_data
==
None
:
if
hasattr
(
settings
,
'RSS_URL'
):
feed_data
=
urllib
.
urlopen
(
settings
.
RSS_URL
)
.
read
()
else
:
feed_data
=
render_to_string
(
"feed.rss"
,
None
)
cache
.
set
(
"students_index_rss_feed_data"
,
feed_data
,
settings
.
RSS_TIMEOUT
)
feed
=
feedparser
.
parse
(
feed_data
)
entries
=
feed
[
'entries'
][
0
:
top
]
# all entries if top is None
for
entry
in
entries
:
soup
=
BeautifulSoup
(
entry
.
description
)
entry
.
image
=
soup
.
img
[
'src'
]
if
soup
.
img
else
None
entry
.
summary
=
soup
.
getText
()
return
entries
lms/templates/dashboard.html
View file @
24ef6f76
...
@@ -150,6 +150,7 @@
...
@@ -150,6 +150,7 @@
</ul>
</ul>
</section>
</section>
%if news:
<article
class=
"news-carousel"
>
<article
class=
"news-carousel"
>
<header>
<header>
<h4>
edX News
</h4>
<h4>
edX News
</h4>
...
@@ -162,38 +163,25 @@
...
@@ -162,38 +163,25 @@
</nav>
</nav>
</header>
</header>
<div
class=
"pages"
>
<div
class=
"pages"
>
% for entry in news:
<section
class=
"page"
>
<section
class=
"page"
>
%if entry.image:
<div
class=
"news-image"
>
<div
class=
"news-image"
>
<a
href=
"
#"
><img
src=
"/static/content-berkeley-cs169x/images/course_image.jpg
"
/></a>
<a
href=
"
${entry.link}"
><img
src=
"${entry.image}
"
/></a>
</div>
</div>
<h5><a
href=
"#"
>
BerkeleyX to offer Computer Graphics course
</a></h5>
%endif
<h5><a
href=
"${entry.link}"
>
${entry.title}
</a></h5>
<div
class=
"excerpt"
>
<div
class=
"excerpt"
>
<p>
BerkeleyX will be offering CS184.1x: Foundations of Computer Graphics starting on November 5, 2012.
</p>
%if entry.summary:
<p><a
href=
"#"
>
Learn More ›
</a></p>
<p>
${entry.summary}
</p>
</div>
%endif
</section>
<p><a
href=
"${entry.link}"
>
Learn More ›
</a></p>
<section
class=
"page"
>
<div
class=
"news-image"
>
<a
href=
"#"
><img
src=
"/static/content-mit-6002x/images/course_image.jpg"
/></a>
</div>
<h5><a
href=
"#"
>
MIT has a new class
</a></h5>
<div
class=
"excerpt"
>
<p>
BerkeleyX will be offering CS184.1x: Foundations of Computer Graphics starting on November 5, 2012.
</p>
<p><a
href=
"#"
>
Learn More ›
</a></p>
</div>
</section>
<section
class=
"page"
>
<div
class=
"news-image"
>
<a
href=
"#"
><img
src=
"/static/6.00x/images/course_image.jpg"
/></a>
</div>
<h5><a
href=
"#"
>
Look at this class, too!
</a></h5>
<div
class=
"excerpt"
>
<p>
BerkeleyX will be offering CS184.1x: Foundations of Computer Graphics starting on November 5, 2012.
</p>
<p><a
href=
"#"
>
Learn More ›
</a></p>
</div>
</div>
</section>
</section>
%endfor
</div>
</div>
</article>
</article>
%endif
</section>
</section>
<section
class=
"my-courses"
>
<section
class=
"my-courses"
>
...
@@ -268,7 +256,7 @@
...
@@ -268,7 +256,7 @@
<p
class=
"message-copy"
>
You did not complete the necessary requirements for
<p
class=
"message-copy"
>
You did not complete the necessary requirements for
completion of this course.
</p>
completion of this course.
</p>
% endif
% endif
% if cert_status['show_disabled_download_button'] or cert_status['show_download_url'] or cert_status['show_survey_button']:
% if cert_status['show_disabled_download_button'] or cert_status['show_download_url'] or cert_status['show_survey_button']:
<ul
class=
"actions"
>
<ul
class=
"actions"
>
% if cert_status['show_disabled_download_button']:
% if cert_status['show_disabled_download_button']:
...
@@ -280,7 +268,7 @@
...
@@ -280,7 +268,7 @@
title=
"This link will open/download a PDF document"
>
title=
"This link will open/download a PDF document"
>
Download Your PDF Certificate
</a></li>
Download Your PDF Certificate
</a></li>
% endif
% endif
% if cert_status['show_survey_button']:
% if cert_status['show_survey_button']:
<li
class=
"action"
><a
class=
"cta"
href=
"${cert_status['survey_url']}"
>
<li
class=
"action"
><a
class=
"cta"
href=
"${cert_status['survey_url']}"
>
Complete our course feedback survey
</a></li>
Complete our course feedback survey
</a></li>
...
...
lms/templates/index.html
View file @
24ef6f76
...
@@ -111,7 +111,7 @@
...
@@ -111,7 +111,7 @@
</header>
</header>
<section
class=
"news"
>
<section
class=
"news"
>
<section
class=
"blog-posts"
>
<section
class=
"blog-posts"
>
%for entry in
entrie
s:
%for entry in
new
s:
<article>
<article>
%if entry.image:
%if entry.image:
<a
href=
"${entry.link}"
class=
"post-graphics"
target=
"_blank"
><img
src=
"${entry.image}"
/></a>
<a
href=
"${entry.link}"
class=
"post-graphics"
target=
"_blank"
><img
src=
"${entry.image}"
/></a>
...
...
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