Commit db94cc42 by Ibrahim Awwal

Allows replying to comments at any level of nesting, and removes the nesting limit.

Nested comments are displayed inline with an @reference.
parent be27907a
......@@ -39,7 +39,7 @@ GENERATE_RANDOM_USER_CREDENTIALS = False
PERFSTATS = False
DISCUSSION_SETTINGS = {
'MAX_COMMENT_DEPTH': 2,
'MAX_COMMENT_DEPTH': None, # Don't force a max comment depth
}
# Features
......@@ -128,7 +128,7 @@ NODE_PATH = ':'.join(node_paths)
############################ OpenID Provider ##################################
OPENID_PROVIDER_TRUSTED_ROOTS = ['cs50.net', '*.cs50.net']
OPENID_PROVIDER_TRUSTED_ROOTS = ['cs50.net', '*.cs50.net']
################################## MITXWEB #####################################
# This is where we stick our compiled template files. Most of the app uses Mako
......@@ -158,7 +158,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'askbot.user_messages.context_processors.user_messages',#must be before auth
'django.contrib.auth.context_processors.auth', #this is required for admin
'django.core.context_processors.csrf', #necessary for csrf protection
# Added for django-wiki
'django.core.context_processors.media',
'django.core.context_processors.tz',
......@@ -355,7 +355,7 @@ WIKI_CAN_ASSIGN = lambda article, user: user.is_staff or user.is_superuser
WIKI_USE_BOOTSTRAP_SELECT_WIDGET = False
WIKI_LINK_LIVE_LOOKUPS = False
WIKI_LINK_DEFAULT_LEVEL = 2
WIKI_LINK_DEFAULT_LEVEL = 2
################################# Jasmine ###################################
JASMINE_TEST_DIRECTORY = PROJECT_ROOT + '/static/coffee'
......@@ -372,10 +372,10 @@ STATICFILES_FINDERS = (
TEMPLATE_LOADERS = (
'mitxmako.makoloader.MakoFilesystemLoader',
'mitxmako.makoloader.MakoAppDirectoriesLoader',
# 'django.template.loaders.filesystem.Loader',
# 'django.template.loaders.app_directories.Loader',
#'askbot.skins.loaders.filesystem_load_template_source',
# 'django.template.loaders.eggs.Loader',
)
......@@ -393,7 +393,7 @@ MIDDLEWARE_CLASSES = (
'django.contrib.messages.middleware.MessageMiddleware',
'track.middleware.TrackMiddleware',
'mitxmako.middleware.MakoMiddleware',
'course_wiki.course_nav.Middleware',
'askbot.middleware.anon_user.ConnectToSessionMessagesMiddleware',
......@@ -624,7 +624,7 @@ INSTALLED_APPS = (
'certificates',
'instructor',
'psychometrics',
#For the wiki
'wiki', # The new django-wiki from benjaoming
'django_notify',
......
......@@ -5,6 +5,7 @@ if Backbone?
events:
"click .discussion-submit-comment": "submitComment"
"focus .wmd-input": "showEditorChrome"
"click .comment-reply-link": "replyToComment"
$: (selector) ->
@$el.find(selector)
......@@ -52,17 +53,17 @@ if Backbone?
})
renderComments: ->
comments = new Comments()
comments.comparator = (comment) ->
@comments = new Comments()
@comments.comparator = (comment) ->
comment.get('created_at')
collectComments = (comment) ->
comments.add(comment)
collectComments = (comment) =>
@comments.add(comment)
children = new Comments(comment.get('children'))
children.each (child) ->
child.parent = comment
collectComments(child)
@model.get('comments').each collectComments
comments.each (comment) => @renderComment(comment, false, null)
@comments.each (comment) => @renderComment(comment, false, null)
renderComment: (comment) =>
comment.set('thread', @model.get('thread'))
......@@ -73,11 +74,16 @@ if Backbone?
submitComment: (event) ->
event.preventDefault()
url = @model.urlFor('reply')
body = @getWmdContent("comment-body")
return if not body.trim().length
@setWmdContent("comment-body", "")
comment = new Comment(body: body, created_at: (new Date()).toISOString(), username: window.user.get("username"), user_id: window.user.get("id"), id:"unsaved")
if @parentComment
url = @parentComment.urlFor('reply')
comment.parent = @parentComment
delete @parentComment # Remove reference so future comments aren't incorrectly parented
else
url = @model.urlFor('reply')
view = @renderComment(comment)
@hideEditorChrome()
@trigger "comment:add", comment
......@@ -89,9 +95,10 @@ if Backbone?
dataType: 'json'
data:
body: body
success: (response, textStatus) ->
success: (response, textStatus) =>
comment.set(response.content)
view.render() # This is just to update the id for the most part, but might be useful in general
@comments.add(comment)
view.render()
delete: (event) =>
event.preventDefault()
......@@ -186,3 +193,8 @@ if Backbone?
@renderShowView()
@showCommentForm()
replyToComment: (event)=>
event.preventDefault()
elem = $(event.target)
@parentComment = @comments.get(elem.data('comment-id'))
@$('.wmd-input').focus()
......@@ -123,6 +123,7 @@
${"<% if (obj.username) { %>"}
<a href="${'<%- user_url %>'}" class="profile-link">${'<%- username %>'}</a>
${"<% } else {print('anonymous');} %>"}
<a class="comment-reply-link" href="#comment_${'<%- id %>'}" data-comment-id="${'<%- id %>'}">Reply</a>
</p>
</div>
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment