Commit 3cbaba19 by Rocky Duan

fixed autosubscribe

parent 3b76fe16
from utils import * from utils import *
from thread import Thread
import models import models
import settings import settings
...@@ -23,6 +24,10 @@ class Comment(models.Model): ...@@ -23,6 +24,10 @@ class Comment(models.Model):
base_url = "{prefix}/comments".format(prefix=settings.PREFIX) base_url = "{prefix}/comments".format(prefix=settings.PREFIX)
type = 'comment' type = 'comment'
@property
def thread(self):
return Thread(id=self.thread_id, type='thread')
@classmethod @classmethod
def url_for_comments(cls, params={}): def url_for_comments(cls, params={}):
if params.get('thread_id'): if params.get('thread_id'):
......
...@@ -87,7 +87,6 @@ class @ContentView extends Backbone.View ...@@ -87,7 +87,6 @@ class @ContentView extends Backbone.View
@$(".discussion-follow-thread").removeClass("discussion-unfollow-thread").html("Follow") @$(".discussion-follow-thread").removeClass("discussion-unfollow-thread").html("Follow")
ability: (ability) -> ability: (ability) ->
console.log "triggered"
for action, elemSelector of @model.actions for action, elemSelector of @model.actions
if not ability[action] if not ability[action]
@$(elemSelector).parent().remove() @$(elemSelector).parent().remove()
......
...@@ -37,10 +37,8 @@ class @DiscussionView extends Backbone.View ...@@ -37,10 +37,8 @@ class @DiscussionView extends Backbone.View
@newPost() @newPost()
reload: ($elem, url) -> reload: ($elem, url) ->
console.log "here"
if not url then return if not url then return
DiscussionUtil.get $elem, url, {}, (response, textStatus) => DiscussionUtil.get $elem, url, {}, (response, textStatus) =>
console.log response
$parent = @$el.parent() $parent = @$el.parent()
@$el.replaceWith(response.html) @$el.replaceWith(response.html)
$discussion = $parent.find("section.discussion") $discussion = $parent.find("section.discussion")
...@@ -49,7 +47,6 @@ class @DiscussionView extends Backbone.View ...@@ -49,7 +47,6 @@ class @DiscussionView extends Backbone.View
DiscussionUtil.bulkUpdateContentInfo(window.$$annotated_content_info) DiscussionUtil.bulkUpdateContentInfo(window.$$annotated_content_info)
loadSimilarPost: (event) -> loadSimilarPost: (event) ->
console.log "loading"
$title = @$(".new-post-title") $title = @$(".new-post-title")
$wrapper = @$(".new-post-similar-posts-wrapper") $wrapper = @$(".new-post-similar-posts-wrapper")
$similarPosts = @$(".new-post-similar-posts") $similarPosts = @$(".new-post-similar-posts")
...@@ -63,7 +60,6 @@ class @DiscussionView extends Backbone.View ...@@ -63,7 +60,6 @@ class @DiscussionView extends Backbone.View
url = DiscussionUtil.urlFor 'search_similar_threads', @model.id url = DiscussionUtil.urlFor 'search_similar_threads', @model.id
data = { text: @$(".new-post-title").val() } data = { text: @$(".new-post-title").val() }
DiscussionUtil.get $elem, url, data, (response, textStatus) => DiscussionUtil.get $elem, url, data, (response, textStatus) =>
console.log response
$similarPosts.empty() $similarPosts.empty()
if $.type(response) == "array" and response.length if $.type(response) == "array" and response.length
$wrapper.show() $wrapper.show()
......
...@@ -2,7 +2,6 @@ class @DiscussionModuleView extends Backbone.View ...@@ -2,7 +2,6 @@ class @DiscussionModuleView extends Backbone.View
events: events:
"click .discussion-show": "toggleDiscussion" "click .discussion-show": "toggleDiscussion"
toggleDiscussion: (event) -> toggleDiscussion: (event) ->
console.log "toggle"
if @showed if @showed
@$("section.discussion").hide() @$("section.discussion").hide()
$(event.target).html("Show Discussion") $(event.target).html("Show Discussion")
......
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