|
@@ -7,6 +7,7 @@ from django.contrib.auth.models import User
|
|
|
from django.core.paginator import Paginator
|
|
from django.core.paginator import Paginator
|
|
|
from django.http.response import HttpResponse
|
|
from django.http.response import HttpResponse
|
|
|
from django.shortcuts import render, get_object_or_404, redirect
|
|
from django.shortcuts import render, get_object_or_404, redirect
|
|
|
|
|
+from django.urls.base import reverse
|
|
|
from notifications.signals import notify
|
|
from notifications.signals import notify
|
|
|
|
|
|
|
|
from main.forms import StoryForm, EpicForm, RegisterForm, ProfileForm, \
|
|
from main.forms import StoryForm, EpicForm, RegisterForm, ProfileForm, \
|
|
@@ -303,8 +304,19 @@ def comment_post(request):
|
|
|
form = CommentForm(request.POST)
|
|
form = CommentForm(request.POST)
|
|
|
if form.is_valid():
|
|
if form.is_valid():
|
|
|
comment = form.save(commit=False)
|
|
comment = form.save(commit=False)
|
|
|
- comment.author = get_object_or_404(User, username=request.user)
|
|
|
|
|
|
|
+ comment.author = request.user
|
|
|
comment.save()
|
|
comment.save()
|
|
|
|
|
+
|
|
|
|
|
+ obj = comment.content_object
|
|
|
|
|
+ notify.send(request.user,
|
|
|
|
|
+ recipient=obj.contributors(),
|
|
|
|
|
+ action_object = obj,
|
|
|
|
|
+ verb="{} a commenté <a href='{}#a-comment-{}'>{} #{}</a>".format(request.user.username,
|
|
|
|
|
+ reverse('{}_details'.format(obj.model_name().lower()), args=(obj.id,)),
|
|
|
|
|
+ comment.id,
|
|
|
|
|
+ obj.model_name(),
|
|
|
|
|
+ obj.id))
|
|
|
|
|
+
|
|
|
return redirect(request.META['HTTP_REFERER'].split("#")[0] + "#a-comment-{}".format(comment.id))
|
|
return redirect(request.META['HTTP_REFERER'].split("#")[0] + "#a-comment-{}".format(comment.id))
|
|
|
else:
|
|
else:
|
|
|
return redirect(request.META['HTTP_REFERER'])
|
|
return redirect(request.META['HTTP_REFERER'])
|