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
8280c559
Commit
8280c559
authored
Mar 12, 2013
by
Your Name
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pinning .1
parent
a2be6dd4
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
106 additions
and
6 deletions
+106
-6
common/static/coffee/src/discussion/content.coffee
+13
-0
common/static/coffee/src/discussion/utils.coffee
+2
-0
common/static/coffee/src/discussion/views/discussion_thread_show_view.coffee
+45
-0
lms/djangoapps/django_comment_client/base/urls.py
+2
-0
lms/djangoapps/django_comment_client/base/views.py
+15
-0
lms/djangoapps/django_comment_client/permissions.py
+2
-0
lms/djangoapps/django_comment_client/utils.py
+1
-1
lms/lib/comment_client/thread.py
+23
-2
lms/static/sass/_discussion.scss
+2
-2
lms/templates/discussion/_underscore_templates.html
+1
-1
No files found.
common/static/coffee/src/discussion/content.coffee
View file @
8280c559
...
...
@@ -79,6 +79,17 @@ if Backbone?
@
getContent
(
id
).
updateInfo
(
info
)
$
.
extend
@
contentInfos
,
infos
pinThread
:
->
pinned
=
@
get
(
"pinned"
)
@
set
(
"pinned"
,
pinned
)
@
trigger
"change"
,
@
unPinThread
:
->
pinned
=
@
get
(
"pinned"
)
@
set
(
"pinned"
,
pinned
)
@
trigger
"change"
,
@
class
@
Thread
extends
@
Content
urlMappers
:
'retrieve'
:
->
DiscussionUtil
.
urlFor
(
'retrieve_single_thread'
,
@
discussion
.
id
,
@
id
)
...
...
@@ -91,6 +102,8 @@ if Backbone?
'delete'
:
->
DiscussionUtil
.
urlFor
(
'delete_thread'
,
@
id
)
'follow'
:
->
DiscussionUtil
.
urlFor
(
'follow_thread'
,
@
id
)
'unfollow'
:
->
DiscussionUtil
.
urlFor
(
'unfollow_thread'
,
@
id
)
'pinThread'
:
->
DiscussionUtil
.
urlFor
(
"pin_thread"
,
@
id
)
'unPinThread'
:
->
DiscussionUtil
.
urlFor
(
"un_pin_thread"
,
@
id
)
initialize
:
->
@
set
(
'thread'
,
@
)
...
...
common/static/coffee/src/discussion/utils.coffee
View file @
8280c559
...
...
@@ -50,6 +50,8 @@ class @DiscussionUtil
delete_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/delete"
upvote_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/upvote"
downvote_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/downvote"
pin_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/pin"
un_pin_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/unpin"
undo_vote_for_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/unvote"
follow_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/follow"
unfollow_thread
:
"/courses/
#{
$$course_id
}
/discussion/threads/
#{
param
}
/unfollow"
...
...
common/static/coffee/src/discussion/views/discussion_thread_show_view.coffee
View file @
8280c559
...
...
@@ -3,6 +3,7 @@ if Backbone?
events
:
"click .discussion-vote"
:
"toggleVote"
"click .discussion-pin"
:
"togglePin"
"click .action-follow"
:
"toggleFollowing"
"click .action-edit"
:
"edit"
"click .action-delete"
:
"delete"
...
...
@@ -24,6 +25,7 @@ if Backbone?
@
delegateEvents
()
@
renderDogear
()
@
renderVoted
()
@
renderPinned
()
@
renderAttrs
()
@
$
(
"span.timeago"
).
timeago
()
@
convertMath
()
...
...
@@ -41,8 +43,20 @@ if Backbone?
else
@
$
(
"[data-role=discussion-vote]"
).
removeClass
(
"is-cast"
)
renderPinned
:
=>
if
@
model
.
get
(
"pinned"
)
@
$
(
"[data-role=thread-pin]"
).
addClass
(
"pinned"
)
@
$
(
"[data-role=thread-pin]"
).
removeClass
(
"notpinned"
)
@
$
(
".discussion-pin .pin-label"
).
html
(
"Pinned"
)
else
@
$
(
"[data-role=thread-pin]"
).
removeClass
(
"pinned"
)
@
$
(
"[data-role=thread-pin]"
).
addClass
(
"notpinned"
)
@
$
(
".discussion-pin .pin-label"
).
html
(
"Pin Thread"
)
updateModelDetails
:
=>
@
renderVoted
()
@
renderPinned
()
@
$
(
"[data-role=discussion-vote] .votes-count-number"
).
html
(
@
model
.
get
(
"votes"
)[
"up_count"
])
convertMath
:
->
...
...
@@ -99,6 +113,34 @@ if Backbone?
delete
:
(
event
)
->
@
trigger
"thread:delete"
,
event
togglePin
:
(
event
)
->
event
.
preventDefault
()
if
@
model
.
get
(
'pinned'
)
@
unPin
()
else
@
pin
()
pin
:
->
url
=
@
model
.
urlFor
(
"pinThread"
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-pin"
)
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
'pinned'
,
true
)
unPin
:
->
url
=
@
model
.
urlFor
(
"unPinThread"
)
DiscussionUtil
.
safeAjax
$elem
:
@
$
(
".discussion-pin"
)
url
:
url
type
:
"POST"
success
:
(
response
,
textStatus
)
=>
if
textStatus
==
'success'
@
model
.
set
(
'pinned'
,
false
)
toggleClosed
:
(
event
)
->
$elem
=
$
(
event
.
target
)
url
=
@
model
.
urlFor
(
'close'
)
...
...
@@ -137,3 +179,5 @@ if Backbone?
if
@
model
.
get
(
'username'
)
?
params
=
$
.
extend
(
params
,
user
:
{
username
:
@
model
.
username
,
user_url
:
@
model
.
user_url
})
Mustache
.
render
(
@
template
,
params
)
\ No newline at end of file
lms/djangoapps/django_comment_client/base/urls.py
View file @
8280c559
...
...
@@ -12,6 +12,8 @@ urlpatterns = patterns('django_comment_client.base.views',
url
(
r'threads/(?P<thread_id>[\w\-]+)/upvote$'
,
'vote_for_thread'
,
{
'value'
:
'up'
},
name
=
'upvote_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/downvote$'
,
'vote_for_thread'
,
{
'value'
:
'down'
},
name
=
'downvote_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/unvote$'
,
'undo_vote_for_thread'
,
name
=
'undo_vote_for_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/pin$'
,
'pin_thread'
,
name
=
'pin_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/unpin$'
,
'un_pin_thread'
,
name
=
'un_pin_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/follow$'
,
'follow_thread'
,
name
=
'follow_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/unfollow$'
,
'unfollow_thread'
,
name
=
'unfollow_thread'
),
url
(
r'threads/(?P<thread_id>[\w\-]+)/close$'
,
'openclose_thread'
,
name
=
'openclose_thread'
),
...
...
lms/djangoapps/django_comment_client/base/views.py
View file @
8280c559
...
...
@@ -289,6 +289,21 @@ def undo_vote_for_thread(request, course_id, thread_id):
user
.
unvote
(
thread
)
return
JsonResponse
(
utils
.
safe_content
(
thread
.
to_dict
()))
@require_POST
@login_required
@permitted
def
pin_thread
(
request
,
course_id
,
thread_id
):
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
thread
=
cc
.
Thread
.
find
(
thread_id
)
thread
.
pin
(
user
,
thread
)
return
JsonResponse
(
utils
.
safe_content
(
thread
.
to_dict
()))
def
un_pin_thread
(
request
,
course_id
,
thread_id
):
user
=
cc
.
User
.
from_django_user
(
request
.
user
)
thread
=
cc
.
Thread
.
find
(
thread_id
)
thread
.
un_pin
(
user
,
thread
)
return
JsonResponse
(
utils
.
safe_content
(
thread
.
to_dict
()))
@require_POST
@login_required
...
...
lms/djangoapps/django_comment_client/permissions.py
View file @
8280c559
...
...
@@ -90,6 +90,8 @@ VIEW_PERMISSIONS = {
'undo_vote_for_comment'
:
[[
'unvote'
,
'is_open'
]],
'vote_for_thread'
:
[[
'vote'
,
'is_open'
]],
'undo_vote_for_thread'
:
[[
'unvote'
,
'is_open'
]],
'pin_thread'
:
[
'create_comment'
],
'un_pin_thread'
:
[
'create_comment'
],
'follow_thread'
:
[
'follow_thread'
],
'follow_commentable'
:
[
'follow_commentable'
],
'follow_user'
:
[
'follow_user'
],
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
8280c559
...
...
@@ -430,7 +430,7 @@ def safe_content(content):
'updated_at'
,
'depth'
,
'type'
,
'commentable_id'
,
'comments_count'
,
'at_position_list'
,
'children'
,
'highlighted_title'
,
'highlighted_body'
,
'courseware_title'
,
'courseware_url'
,
'tags'
,
'unread_comments_count'
,
'read'
,
'group_id'
,
'group_name'
,
'group_string'
'read'
,
'group_id'
,
'group_name'
,
'group_string'
,
'pinned'
]
if
(
content
.
get
(
'anonymous'
)
is
False
)
and
(
content
.
get
(
'anonymous_to_peers'
)
is
False
):
...
...
lms/lib/comment_client/thread.py
View file @
8280c559
...
...
@@ -11,12 +11,12 @@ class Thread(models.Model):
'closed'
,
'tags'
,
'votes'
,
'commentable_id'
,
'username'
,
'user_id'
,
'created_at'
,
'updated_at'
,
'comments_count'
,
'unread_comments_count'
,
'at_position_list'
,
'children'
,
'type'
,
'highlighted_title'
,
'highlighted_body'
,
'endorsed'
,
'read'
,
'group_id'
,
'group_name'
'highlighted_body'
,
'endorsed'
,
'read'
,
'group_id'
,
'group_name'
,
'pinned'
]
updatable_fields
=
[
'title'
,
'body'
,
'anonymous'
,
'anonymous_to_peers'
,
'course_id'
,
'closed'
,
'tags'
,
'user_id'
,
'commentable_id'
,
'group_id'
,
'group_name'
'closed'
,
'tags'
,
'user_id'
,
'commentable_id'
,
'group_id'
,
'group_name'
,
'pinned'
]
initializable_fields
=
updatable_fields
...
...
@@ -79,3 +79,23 @@ class Thread(models.Model):
response
=
perform_request
(
'get'
,
url
,
request_params
)
self
.
update_attributes
(
**
response
)
def
pin
(
self
,
user
,
thread_id
):
url
=
_url_for_pin_thread
(
thread_id
)
params
=
{
'user_id'
:
user
.
id
}
request
=
perform_request
(
'put'
,
url
,
params
)
self
.
update_attributes
(
request
)
def
un_pin
(
self
,
user
,
thread_id
):
url
=
_url_for_un_pin_thread
(
thread_id
)
params
=
{
'user_id'
:
user
.
id
}
request
=
perform_request
(
'put'
,
url
,
params
)
self
.
update_attributes
(
request
)
def
_url_for_pin_thread
(
thread_id
):
return
"{prefix}/threads/{thread_id}/pin"
.
format
(
prefix
=
settings
.
PREFIX
,
thread_id
=
thread_id
)
def
_url_for_un_pin_thread
(
thread_id
):
return
"{prefix}/threads/{thread_id}/unpin"
.
format
(
prefix
=
settings
.
PREFIX
,
thread_id
=
thread_id
)
\ No newline at end of file
lms/static/sass/_discussion.scss
View file @
8280c559
...
...
@@ -2444,7 +2444,7 @@ body.discussion {
background-color
:
#fff
;
}
.discussion-
flag-abuse
{
.discussion-
pin
{
font-size
:
12px
;
float
:right
;
padding-right
:
5px
;
...
...
@@ -2457,7 +2457,7 @@ body.discussion {
width
:
10px
;
height
:
14px
;
padding-right
:
3px
;
background
:
transparent
url('../images/
not
pinned.png')
no-repeat
0
0
;
background
:
transparent
url('../images/
un
pinned.png')
no-repeat
0
0
;
}
.pinned
.icon
...
...
lms/templates/discussion/_underscore_templates.html
View file @
8280c559
...
...
@@ -47,7 +47,7 @@
<
div
class
=
"post-body"
>
$
{
'<%- body %>'
}
<
/div
>
%
if
has_permission
(
user
,
'create_comment'
,
course
.
id
):
<
div
class
=
"discussion-
flag-
pin notpinned"
data
-
role
=
"thread-pin"
data
-
tooltip
=
"pin this thread"
>
<
div
class
=
"discussion-pin notpinned"
data
-
role
=
"thread-pin"
data
-
tooltip
=
"pin this thread"
>
<
i
class
=
"icon"
><
/i><span class="pin-label">Pin Thread</
span
><
/div>
%
endif
$
{
'<% if (obj.courseware_url) { %>'
}
...
...
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