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
43ef4f64
Commit
43ef4f64
authored
Aug 22, 2012
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed recent threads & tags links
parent
99614ea3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
12 deletions
+25
-12
lms/djangoapps/django_comment_client/helpers.py
+9
-8
lms/djangoapps/django_comment_client/mustache_helpers.py
+3
-1
lms/djangoapps/django_comment_client/utils.py
+6
-0
lms/templates/discussion/_recent_active_posts.html
+4
-2
lms/templates/discussion/_trending_tags.html
+3
-1
No files found.
lms/djangoapps/django_comment_client/helpers.py
View file @
43ef4f64
...
@@ -33,21 +33,22 @@ def include_mustache_templates():
...
@@ -33,21 +33,22 @@ def include_mustache_templates():
file_contents
=
map
(
read_file
,
filter
(
valid_file_name
,
os
.
listdir
(
mustache_dir
)))
file_contents
=
map
(
read_file
,
filter
(
valid_file_name
,
os
.
listdir
(
mustache_dir
)))
return
'
\n
'
.
join
(
map
(
wrap_in_tag
,
map
(
strip_file_name
,
file_contents
)))
return
'
\n
'
.
join
(
map
(
wrap_in_tag
,
map
(
strip_file_name
,
file_contents
)))
def
permalink
(
content
):
if
content
[
'type'
]
==
'thread'
:
return
reverse
(
'django_comment_client.forum.views.single_thread'
,
args
=
[
content
[
'course_id'
],
content
[
'commentable_id'
],
content
[
'id'
]])
else
:
return
reverse
(
'django_comment_client.forum.views.single_thread'
,
args
=
[
content
[
'course_id'
],
content
[
'commentable_id'
],
content
[
'thread_id'
]])
+
'#'
+
content
[
'id'
]
def
render_content
(
content
,
additional_context
=
{}):
def
render_content
(
content
,
additional_context
=
{}):
content_info
=
{
content_info
=
{
'displayed_title'
:
content
.
get
(
'highlighted_title'
)
or
content
.
get
(
'title'
,
''
),
'displayed_title'
:
content
.
get
(
'highlighted_title'
)
or
content
.
get
(
'title'
,
''
),
'displayed_body'
:
content
.
get
(
'highlighted_body'
)
or
content
.
get
(
'body'
,
''
),
'displayed_body'
:
content
.
get
(
'highlighted_body'
)
or
content
.
get
(
'body'
,
''
),
'raw_tags'
:
','
.
join
(
content
.
get
(
'tags'
,
[])),
'raw_tags'
:
','
.
join
(
content
.
get
(
'tags'
,
[])),
'permalink'
:
permalink
(
content
),
}
}
print
content_info
if
content
[
'type'
]
==
'thread'
:
content_info
[
'permalink'
]
=
reverse
(
'django_comment_client.forum.views.single_thread'
,
args
=
[
content
[
'course_id'
],
content
[
'commentable_id'
],
content
[
'id'
]])
else
:
content_info
[
'permalink'
]
=
reverse
(
'django_comment_client.forum.views.single_thread'
,
args
=
[
content
[
'course_id'
],
content
[
'commentable_id'
],
content
[
'thread_id'
]])
+
'#'
+
content
[
'id'
]
context
=
{
context
=
{
'content'
:
merge_dict
(
content
,
content_info
),
'content'
:
merge_dict
(
content
,
content_info
),
content
[
'type'
]:
True
,
content
[
'type'
]:
True
,
...
...
lms/djangoapps/django_comment_client/mustache_helpers.py
View file @
43ef4f64
from
.utils
import
url_for_tags
as
_url_for_tags
import
django.core.urlresolvers
as
urlresolvers
import
django.core.urlresolvers
as
urlresolvers
import
urllib
import
urllib
import
sys
import
sys
...
@@ -14,7 +16,7 @@ def url_for_user(content, user_id):
...
@@ -14,7 +16,7 @@ def url_for_user(content, user_id):
return
urlresolvers
.
reverse
(
'django_comment_client.forum.views.user_profile'
,
args
=
[
content
[
'course_id'
],
user_id
])
return
urlresolvers
.
reverse
(
'django_comment_client.forum.views.user_profile'
,
args
=
[
content
[
'course_id'
],
user_id
])
def
url_for_tags
(
content
,
tags
):
# assume that attribute 'tags' is in the format u'a, b, c'
def
url_for_tags
(
content
,
tags
):
# assume that attribute 'tags' is in the format u'a, b, c'
return
urlresolvers
.
reverse
(
'django_comment_client.forum.views.forum_form_discussion'
,
args
=
[
content
[
'course_id'
]])
+
'?'
+
urllib
.
urlencode
({
'tags'
:
tags
}
)
return
_url_for_tags
(
content
[
'course_id'
],
tags
)
def
close_thread_text
(
content
):
def
close_thread_text
(
content
):
if
content
.
get
(
'closed'
):
if
content
.
get
(
'closed'
):
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
43ef4f64
...
@@ -7,12 +7,14 @@ from django.http import HttpResponse
...
@@ -7,12 +7,14 @@ from django.http import HttpResponse
from
django.utils
import
simplejson
from
django.utils
import
simplejson
from
django.db
import
connection
from
django.db
import
connection
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django_comment_client.permissions
import
check_permissions_by_view
from
django_comment_client.permissions
import
check_permissions_by_view
from
mitxmako
import
middleware
from
mitxmako
import
middleware
import
logging
import
logging
import
operator
import
operator
import
itertools
import
itertools
import
urllib
import
pystache_custom
as
pystache
import
pystache_custom
as
pystache
...
@@ -188,6 +190,10 @@ def get_annotated_content_infos(course_id, thread, user, user_info):
...
@@ -188,6 +190,10 @@ def get_annotated_content_infos(course_id, thread, user, user_info):
annotate
(
thread
)
annotate
(
thread
)
return
infos
return
infos
# put this method in utils.py to avoid circular import dependency between helpers and mustache_helpers
def
url_for_tags
(
course_id
,
tags
):
return
reverse
(
'django_comment_client.forum.views.forum_form_discussion'
,
args
=
[
course_id
])
+
'?'
+
urllib
.
urlencode
({
'tags'
:
tags
})
def
render_mustache
(
template_name
,
dictionary
,
*
args
,
**
kwargs
):
def
render_mustache
(
template_name
,
dictionary
,
*
args
,
**
kwargs
):
template
=
middleware
.
lookup
[
'main'
]
.
get_template
(
template_name
)
.
source
template
=
middleware
.
lookup
[
'main'
]
.
get_template
(
template_name
)
.
source
return
pystache
.
render
(
template
,
dictionary
)
return
pystache
.
render
(
template
,
dictionary
)
lms/templates/discussion/_recent_active_posts.html
View file @
43ef4f64
<
%!
import
django_comment_client
.
helpers
as
helpers
%
>
% if recent_active_threads:
% if recent_active_threads:
<article
class=
"discussion-sidebar-following sidebar-module"
>
<article
class=
"discussion-sidebar-following sidebar-module"
>
<header>
<header>
<h4>
Following
</h4>
<h4>
Following
</h4>
<
a
href=
"#"
class=
"sidebar-view-all"
>
view all
›
</a
>
<
!--<a href="#" class="sidebar-view-all">view all ›</a>--
>
</header>
</header>
<ol
class=
"discussion-sidebar-following-list"
>
<ol
class=
"discussion-sidebar-following-list"
>
% for thread in recent_active_threads:
% for thread in recent_active_threads:
<li><a
href=
"
#
"
><span
class=
"sidebar-following-name"
>
${thread['title']}
</span>
<span
class=
"sidebar-vote-count"
>
${thread['votes']['point']}
</span></a></li>
<li><a
href=
"
${helpers.permalink(thread)}
"
><span
class=
"sidebar-following-name"
>
${thread['title']}
</span>
<span
class=
"sidebar-vote-count"
>
${thread['votes']['point']}
</span></a></li>
% endfor
% endfor
<ol>
<ol>
</article>
</article>
...
...
lms/templates/discussion/_trending_tags.html
View file @
43ef4f64
<
%!
import
django_comment_client
.
helpers
as
helpers
%
>
% if trending_tags:
% if trending_tags:
<article
class=
"discussion-sidebar-tags sidebar-module"
>
<article
class=
"discussion-sidebar-tags sidebar-module"
>
<header>
<header>
...
@@ -5,7 +7,7 @@
...
@@ -5,7 +7,7 @@
</header>
</header>
<ol
class=
"discussion-sidebar-tags-list"
>
<ol
class=
"discussion-sidebar-tags-list"
>
% for tag, count in trending_tags:
% for tag, count in trending_tags:
<li><a
href=
"
#
"
class=
"thread-tag"
>
${tag}
</a><span
class=
"sidebar-tag-count"
>
×
${count}
</span></li>
<li><a
href=
"
${helpers.url_for_tags(course.id, tag)}
"
class=
"thread-tag"
>
${tag}
</a><span
class=
"sidebar-tag-count"
>
×
${count}
</span></li>
% endfor
% endfor
<ol>
<ol>
</article>
</article>
...
...
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