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
033ce7ef
Commit
033ce7ef
authored
Sep 14, 2012
by
Arjun Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Discussioninfo needs to be multicourse-friendly..
parent
6d753ae3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
lms/djangoapps/django_comment_client/utils.py
+10
-12
No files found.
lms/djangoapps/django_comment_client/utils.py
View file @
033ce7ef
...
...
@@ -26,7 +26,7 @@ import pystache_custom as pystache
# TODO these should be cached via django's caching rather than in-memory globals
_FULLMODULES
=
None
_DISCUSSIONINFO
=
None
_DISCUSSIONINFO
=
defaultdict
(
dict
)
def
extract
(
dic
,
keys
):
return
{
k
:
dic
.
get
(
k
)
for
k
in
keys
}
...
...
@@ -61,23 +61,23 @@ def get_discussion_id_map(course):
return a dict of the form {category: modules}
"""
global
_DISCUSSIONINFO
if
not
_DISCUSSIONINFO
:
if
not
_DISCUSSIONINFO
[
course
.
id
]
:
initialize_discussion_info
(
course
)
return
_DISCUSSIONINFO
[
'id_map'
]
return
_DISCUSSIONINFO
[
course
.
id
][
'id_map'
]
def
get_discussion_title
(
course
,
discussion_id
):
global
_DISCUSSIONINFO
if
not
_DISCUSSIONINFO
:
if
not
_DISCUSSIONINFO
[
course
.
id
]
:
initialize_discussion_info
(
course
)
title
=
_DISCUSSIONINFO
[
'id_map'
]
.
get
(
discussion_id
,
{})
.
get
(
'title'
,
'(no title)'
)
title
=
_DISCUSSIONINFO
[
course
.
id
][
'id_map'
]
.
get
(
discussion_id
,
{})
.
get
(
'title'
,
'(no title)'
)
return
title
def
get_discussion_category_map
(
course
):
global
_DISCUSSIONINFO
if
not
_DISCUSSIONINFO
:
if
not
_DISCUSSIONINFO
[
course
.
id
]
:
initialize_discussion_info
(
course
)
return
filter_unstarted_categories
(
_DISCUSSIONINFO
[
'category_map'
])
return
filter_unstarted_categories
(
_DISCUSSIONINFO
[
course
.
id
][
'category_map'
])
def
filter_unstarted_categories
(
category_map
):
...
...
@@ -128,7 +128,7 @@ def sort_map_entries(category_map):
def
initialize_discussion_info
(
course
):
global
_DISCUSSIONINFO
if
_DISCUSSIONINFO
:
if
_DISCUSSIONINFO
[
course
.
id
]
:
return
course_id
=
course
.
id
...
...
@@ -197,10 +197,8 @@ def initialize_discussion_info(course):
"start_date"
:
time
.
gmtime
()}
sort_map_entries
(
category_map
)
_DISCUSSIONINFO
=
{}
_DISCUSSIONINFO
[
'id_map'
]
=
discussion_id_map
_DISCUSSIONINFO
[
'category_map'
]
=
category_map
_DISCUSSIONINFO
[
course
.
id
][
'id_map'
]
=
discussion_id_map
_DISCUSSIONINFO
[
course
.
id
][
'category_map'
]
=
category_map
class
JsonResponse
(
HttpResponse
):
def
__init__
(
self
,
data
=
None
):
...
...
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