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
1ac41787
Commit
1ac41787
authored
Dec 21, 2012
by
Carlos Andrés Rocha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken display of courses in university profile
parent
bcb5eda2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
25 deletions
+21
-25
common/djangoapps/student/views.py
+6
-2
lms/djangoapps/courseware/courses.py
+2
-18
lms/djangoapps/courseware/views.py
+12
-4
lms/templates/course.html
+1
-1
No files found.
common/djangoapps/student/views.py
View file @
1ac41787
...
...
@@ -40,7 +40,7 @@ from xmodule.modulestore.exceptions import ItemNotFoundError
from
datetime
import
date
from
collections
import
namedtuple
from
courseware.courses
import
get_courses
_by_start_date
from
courseware.courses
import
get_courses
from
courseware.access
import
has_access
from
statsd
import
statsd
...
...
@@ -75,7 +75,11 @@ def index(request, extra_context={}, user=None):
if
domain
==
False
:
# do explicit check, because domain=None is valid
domain
=
request
.
META
.
get
(
'HTTP_HOST'
)
courses
=
get_courses_by_start_date
(
None
,
domain
=
domain
)
courses
=
get_courses
(
None
,
domain
=
domain
)
# Sort courses by how far are they from they start day
key
=
lambda
course
:
course
.
metadata
[
'days_to_start'
]
courses
=
sorted
(
courses
,
key
=
key
,
reverse
=
True
)
# Get the 3 most recent news
top_news
=
_get_news
(
top
=
3
)
...
...
lms/djangoapps/courseware/courses.py
View file @
1ac41787
...
...
@@ -233,21 +233,7 @@ def get_courses(user, domain=None):
courses
=
branding
.
get_visible_courses
(
domain
)
courses
=
[
c
for
c
in
courses
if
has_access
(
user
,
c
,
'see_exists'
)]
return
courses
def
get_courses_by_start_date
(
user
,
domain
=
None
):
"""
Returns a list of courses available, sorted by start date
"""
visible_courses
=
get_courses
(
user
,
domain
)
courses
=
_sort_courses_and_mark_new
(
visible_courses
)
return
courses
def
_sort_courses_and_mark_new
(
courses
):
"""Sort by course start date and mark which have not started yet"""
# Add metadata about the start day and if the course is new
for
course
in
courses
:
days_to_start
=
_get_course_days_to_start
(
course
)
...
...
@@ -255,9 +241,7 @@ def _sort_courses_and_mark_new(courses):
metadata
[
'days_to_start'
]
=
days_to_start
metadata
[
'is_new'
]
=
course
.
metadata
.
get
(
'is_new'
,
days_to_start
>
1
)
key
=
lambda
c
:
c
.
metadata
[
'days_to_start'
]
courses
=
sorted
(
courses
,
key
=
key
,
reverse
=
True
)
courses
=
sorted
(
courses
,
key
=
lambda
course
:
course
.
number
)
return
courses
...
...
lms/djangoapps/courseware/views.py
View file @
1ac41787
...
...
@@ -17,7 +17,7 @@ from django.views.decorators.cache import cache_control
from
courseware
import
grades
from
courseware.access
import
has_access
from
courseware.courses
import
(
get_course
_with_access
,
get_courses_by_start_date
)
from
courseware.courses
import
(
get_course
s
,
get_course_with_access
,
get_courses_by_university
)
import
courseware.tabs
as
tabs
from
courseware.models
import
StudentModuleCache
from
module_render
import
toc_for_course
,
get_module
,
get_instance_module
...
...
@@ -61,15 +61,18 @@ def user_groups(user):
return
group_names
@ensure_csrf_cookie
@cache_if_anonymous
def
courses
(
request
):
'''
Render "find courses" page. The course selection work is done in courseware.courses.
'''
courses
=
get_courses_by_start_date
(
request
.
user
,
domain
=
request
.
META
.
get
(
'HTTP_HOST'
))
courses
=
get_courses
(
request
.
user
,
domain
=
request
.
META
.
get
(
'HTTP_HOST'
))
# Sort courses by how far are they from they start day
key
=
lambda
course
:
course
.
metadata
[
'days_to_start'
]
courses
=
sorted
(
courses
,
key
=
key
,
reverse
=
True
)
return
render_to_response
(
"courseware/courses.html"
,
{
'courses'
:
courses
})
...
...
@@ -435,6 +438,11 @@ def university_profile(request, org_id):
# Only grab courses for this org...
courses
=
get_courses_by_university
(
request
.
user
,
domain
=
request
.
META
.
get
(
'HTTP_HOST'
))[
org_id
]
# Sort courses by how far are they from they start day
key
=
lambda
course
:
course
.
metadata
[
'days_to_start'
]
courses
=
sorted
(
courses
,
key
=
key
,
reverse
=
True
)
context
=
dict
(
courses
=
courses
,
org_id
=
org_id
)
template_file
=
"university_profile/{0}.html"
.
format
(
org_id
)
.
lower
()
...
...
lms/templates/course.html
View file @
1ac41787
...
...
@@ -5,7 +5,7 @@
%
>
<
%
page
args=
"course"
/>
<article
id=
"${course.id}"
class=
"course"
>
%if course.metadata
['is_new']
:
%if course.metadata
.get('is_new')
:
<span
class=
"status"
>
New
</span>
%endif
<a
href=
"${reverse('about_course', args=[course.id])}"
>
...
...
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