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
00a6526f
Commit
00a6526f
authored
Sep 05, 2012
by
Ibrahim Awwal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make voting render properly in inline discussions. Also might have fixed
following if it wasn't working before.
parent
79fedc0b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
35 additions
and
26 deletions
+35
-26
lms/djangoapps/django_comment_client/base/views.py
+7
-8
lms/djangoapps/django_comment_client/forum/views.py
+6
-0
lms/djangoapps/django_comment_client/utils.py
+11
-11
lms/static/coffee/src/discussion/discussion_module.coffee
+1
-1
lms/static/coffee/src/discussion/views/discussion_thread_inline_view.coffee
+0
-4
lms/templates/discussion/mustache/_inline_thread.mustache
+10
-2
No files found.
lms/djangoapps/django_comment_client/base/views.py
View file @
00a6526f
...
...
@@ -38,11 +38,10 @@ def permitted(fn):
else
:
content
=
None
return
content
if
check_permissions_by_view
(
request
.
user
,
kwargs
[
'course_id'
],
fetch_content
(),
request
.
view_name
):
return
fn
(
request
,
*
args
,
**
kwargs
)
else
:
return
JsonError
(
"unauthorized"
)
return
JsonError
(
"unauthorized"
,
status
=
401
)
return
wrapper
def
ajax_content_response
(
request
,
course_id
,
content
,
template_name
):
...
...
@@ -214,7 +213,7 @@ def undo_vote_for_thread(request, course_id, thread_id):
thread
=
cc
.
Thread
.
find
(
thread_id
)
user
.
unvote
(
thread
)
return
JsonResponse
(
utils
.
safe_content
(
thread
.
to_dict
()))
@require_POST
@login_required
...
...
@@ -288,7 +287,7 @@ def update_moderator_status(request, course_id, user_id):
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
discussion_user
=
cc
.
User
(
id
=
user_id
,
course_id
=
course_id
)
context
=
{
'course'
:
course
,
'course'
:
course
,
'course_id'
:
course_id
,
'user'
:
request
.
user
,
'django_user'
:
user
,
...
...
@@ -327,7 +326,7 @@ def tags_autocomplete(request, course_id):
@require_POST
@login_required
@csrf.csrf_exempt
def
upload
(
request
,
course_id
):
#ajax upload file to a question or answer
def
upload
(
request
,
course_id
):
#ajax upload file to a question or answer
"""view that handles file upload via Ajax
"""
...
...
@@ -337,7 +336,7 @@ def upload(request, course_id):#ajax upload file to a question or answer
new_file_name
=
''
try
:
# TODO authorization
#may raise exceptions.PermissionDenied
#may raise exceptions.PermissionDenied
#if request.user.is_anonymous():
# msg = _('Sorry, anonymous users cannot upload files')
# raise exceptions.PermissionDenied(msg)
...
...
@@ -357,7 +356,7 @@ def upload(request, course_id):#ajax upload file to a question or answer
new_file_name
=
str
(
time
.
time
()
)
.
replace
(
'.'
,
'.'
,
str
(
random
.
randint
(
0
,
100000
))
)
+
file_extension
...
...
@@ -386,7 +385,7 @@ def upload(request, course_id):#ajax upload file to a question or answer
parsed_url
=
urlparse
.
urlparse
(
file_url
)
file_url
=
urlparse
.
urlunparse
(
urlparse
.
ParseResult
(
parsed_url
.
scheme
,
parsed_url
.
scheme
,
parsed_url
.
netloc
,
parsed_url
.
path
,
''
,
''
,
''
...
...
lms/djangoapps/django_comment_client/forum/views.py
View file @
00a6526f
...
...
@@ -136,10 +136,16 @@ def inline_discussion(request, course_id, discussion_id):
# html = render_inline_discussion(request, course_id, threads, discussion_id=discussion_id, \
# query_params=query_params)
user_info
=
cc
.
User
.
from_django_user
(
request
.
user
)
.
to_dict
()
def
infogetter
(
thread
):
return
utils
.
get_annotated_content_infos
(
course_id
,
thread
,
request
.
user
,
user_info
)
annotated_content_info
=
reduce
(
merge_dict
,
map
(
infogetter
,
threads
),
{})
return
utils
.
JsonResponse
({
# 'html': html,
'discussion_data'
:
map
(
utils
.
safe_content
,
threads
),
'user_info'
:
user_info
,
'annotated_content_info'
:
annotated_content_info
})
def
render_search_bar
(
request
,
course_id
,
discussion_id
=
None
,
text
=
''
):
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
00a6526f
...
...
@@ -100,24 +100,24 @@ def initialize_discussion_info(course):
unexpanded_category_map
[
category
]
.
append
({
"title"
:
title
,
"id"
:
id
,
"sort_key"
:
sort_key
})
category_map
=
{
"entries"
:
defaultdict
(
dict
),
"subcategories"
:
defaultdict
(
dict
)}
category_map
=
{
"entries"
:
defaultdict
(
dict
),
"subcategories"
:
defaultdict
(
dict
)}
for
category_path
,
entries
in
unexpanded_category_map
.
items
():
node
=
category_map
[
"subcategories"
]
path
=
[
x
.
strip
()
for
x
in
category_path
.
split
(
"/"
)]
for
level
in
path
[:
-
1
]:
if
level
not
in
node
:
node
[
level
]
=
{
"subcategories"
:
defaultdict
(
dict
),
node
[
level
]
=
{
"subcategories"
:
defaultdict
(
dict
),
"entries"
:
defaultdict
(
dict
),
"sort_key"
:
level
}
"sort_key"
:
level
}
node
=
node
[
level
][
"subcategories"
]
level
=
path
[
-
1
]
if
level
not
in
node
:
node
[
level
]
=
{
"subcategories"
:
defaultdict
(
dict
),
"entries"
:
defaultdict
(
dict
),
node
[
level
]
=
{
"subcategories"
:
defaultdict
(
dict
),
"entries"
:
defaultdict
(
dict
),
"sort_key"
:
level
}
for
entry
in
entries
:
node
[
level
][
"entries"
][
entry
[
"title"
]]
=
{
"id"
:
entry
[
"id"
],
node
[
level
][
"entries"
][
entry
[
"title"
]]
=
{
"id"
:
entry
[
"id"
],
"sort_key"
:
entry
[
"sort_key"
]}
for
topic
,
entry
in
course
.
metadata
.
get
(
'discussion_topics'
,
{})
.
items
():
...
...
@@ -134,7 +134,7 @@ def initialize_discussion_info(course):
def
get_courseware_context
(
content
,
course
):
id_map
=
get_discussion_id_map
(
course
)
id
=
content
[
'commentable_id'
]
id
=
content
[
'commentable_id'
]
content_info
=
None
if
id
in
id_map
:
location
=
id_map
[
id
][
"location"
]
.
url
()
...
...
@@ -149,21 +149,21 @@ class JsonResponse(HttpResponse):
mimetype
=
'application/json; charset=utf8'
)
class
JsonError
(
HttpResponse
):
def
__init__
(
self
,
error_messages
=
[]):
def
__init__
(
self
,
error_messages
=
[]
,
status
=
400
):
if
isinstance
(
error_messages
,
str
):
error_messages
=
[
error_messages
]
content
=
simplejson
.
dumps
({
'errors'
:
error_messages
},
indent
=
2
,
ensure_ascii
=
False
)
super
(
JsonError
,
self
)
.
__init__
(
content
,
mimetype
=
'application/json; charset=utf8'
,
status
=
400
)
mimetype
=
'application/json; charset=utf8'
,
status
=
status
)
class
HtmlResponse
(
HttpResponse
):
def
__init__
(
self
,
html
=
''
):
super
(
HtmlResponse
,
self
)
.
__init__
(
html
,
content_type
=
'text/plain'
)
class
ViewNameMiddleware
(
object
):
def
process_view
(
self
,
request
,
view_func
,
view_args
,
view_kwargs
):
class
ViewNameMiddleware
(
object
):
def
process_view
(
self
,
request
,
view_func
,
view_args
,
view_kwargs
):
request
.
view_name
=
view_func
.
__name__
class
QueryCountDebugMiddleware
(
object
):
...
...
lms/static/coffee/src/discussion/discussion_module.coffee
View file @
00a6526f
...
...
@@ -23,8 +23,8 @@ if Backbone?
type
:
"GET"
dataType
:
'json'
success
:
(
response
,
textStatus
)
=>
#@$el.append(response.html)
window
.
user
=
new
DiscussionUser
(
response
.
user_info
)
Content
.
loadContentInfos
(
response
.
annotated_content_info
)
$
(
event
.
target
).
html
(
"Hide Discussion"
)
discussion
=
new
Discussion
()
discussion
.
reset
(
response
.
discussion_data
,
{
silent
:
false
})
...
...
lms/static/coffee/src/discussion/views/discussion_thread_inline_view.coffee
View file @
00a6526f
...
...
@@ -21,10 +21,6 @@ class @DiscussionThreadInlineView extends DiscussionContentView
@
model
.
on
"change"
,
@
updateModelDetails
render
:
->
#TODO: Debugging, remove when done
if
not
window
.
$disc
window
.
$disc
=
[]
window
.
$disc
.
push
(
@
)
if
not
@
model
.
has
(
'abbreviatedBody'
)
@
abbreviateBody
()
@
$el
.
html
(
Mustache
.
render
(
@
template
(),
$
.
extend
(
@
model
.
toJSON
(),{
expanded
:
@
expanded
})
))
...
...
lms/templates/discussion/mustache/_inline_thread.mustache
View file @
00a6526f
...
...
@@ -2,11 +2,14 @@
<div
class=
"local"
><a
href=
"#"
class=
"dogear action-follow"
></a></div>
<div
class=
"discussion-post local"
>
<header>
<a
href=
"#"
class=
"vote-btn discussion-vote discussion-vote-up"
><span
class=
"plus-icon"
>
+
</span>
<span
class=
'votes-count-number'
>
{{
votes
.
up_count
}}
</span></a>
<a
href=
"#"
class=
"vote-btn discussion-vote discussion-vote-up"
data-role=
"discussion-vote"
><span
class=
"plus-icon"
>
+
</span>
<span
class=
'votes-count-number'
>
{{
votes
.
up_count
}}
</span></a>
<h1>
{{
title
}}
</h1>
<p
class=
"posted-details"
>
<span
class=
"timeago"
title=
"
{{
created_at
}}
"
>
sometime
</span>
by
<span
class=
"timeago"
title=
"
{{
created_at
}}
"
>
{{
created_at
}}
</span>
by
<a
href=
"
{{
user_url
}}
"
>
{{
username
}}
</a>
<span
class=
"post-status-closed top-post-status"
style=
"display: none"
>
•
This thread is closed.
</span>
</p>
<div
class=
"local post-tools"
>
<a
href=
"javascript:void(0)"
class=
"expand-post"
>
Expand...
</a>
...
...
@@ -16,6 +19,11 @@
<div
class=
"post-body"
>
{{
abbreviatedBody
}}
</div>
<ul
class=
"moderator-actions"
>
<li
style=
"display: none"
><a
class=
"action-edit"
href=
"javascript:void(0)"
><span
class=
"edit-icon"
></span>
Edit
</a></li>
<li
style=
"display: none"
><a
class=
"action-delete"
href=
"javascript:void(0)"
><span
class=
"delete-icon"
></span>
Delete
</a></li>
<li
style=
"display: none"
><a
class=
"action-openclose"
href=
"javascript:void(0)"
><span
class=
"edit-icon"
></span>
Close
</a></li>
</ul>
</div>
<ol
class=
"responses post-extended-content"
>
<li
class=
"loading"
><div
class=
"loading-animation"
></div></li>
...
...
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