Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion spirit/comment/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ def pre_comment_update(comment):
CommentHistory.create_maybe(comment)


def post_comment_update(comment):
def post_comment_update(comment, mentions=None):
comment.increase_modified_count()

comment.comment_html = post_render_static_polls(comment)
CommentHistory.create(comment)

TopicNotification.notify_new_mentions(
comment=comment, mentions=mentions)
2 changes: 1 addition & 1 deletion spirit/comment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def update(request, pk):
if form.is_valid():
pre_comment_update(comment=Comment.objects.get(pk=comment.pk))
comment = form.save()
post_comment_update(comment=comment)
post_comment_update(comment=comment, mentions=form.mentions)
return redirect(request.POST.get('next', comment.get_absolute_url()))
else:
form = CommentForm(instance=comment)
Expand Down
17 changes: 12 additions & 5 deletions spirit/topic/notification/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,21 @@ def notify_new_mentions(cls, comment, mentions):
topic=comment.topic,
comment=comment,
action=MENTION,
is_active=True
)
is_active=True)
except IntegrityError:
pass

cls.objects\
.filter(user__in=mentions.values(), topic=comment.topic, is_read=True)\
.update(comment=comment, is_read=False, action=MENTION, date=timezone.now())
(cls.objects
.filter(
user__in=mentions.values(),
topic=comment.topic,
is_read=True,
date__lte=comment.date)
.update(
comment=comment,
is_read=False,
action=MENTION,
date=timezone.now()))

@classmethod
def bulk_create(cls, users, comment):
Expand Down