Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a commented signal

  • Loading branch information...
commit 2aaeabf06bd179373223cae603f757923c2d1b3b 1 parent 71e1a5a
@paltman paltman authored
Showing with 7 additions and 1 deletion.
  1. +4 −0 dialogos/signals.py
  2. +3 −1 dialogos/views.py
View
4 dialogos/signals.py
@@ -0,0 +1,4 @@
+import django.dispatch
+
+
+commented = django.dispatch.Signal(providing_args=["comment", "request"])
View
4 dialogos/views.py
@@ -6,6 +6,7 @@
from dialogos.forms import CommentForm
from dialogos.models import Comment
+from dialogos.signals import commented
@require_POST
@@ -14,7 +15,8 @@ def post_comment(request, content_type_id, object_id):
obj = get_object_or_404(content_type.model_class(), pk=object_id)
form = CommentForm(request.POST, request=request, obj=obj, user=request.user)
if form.is_valid():
- form.save()
+ comment = form.save()
+ commented.send(sender=post_comment, comment=comment, request=request)
redirect_to = request.POST.get("next")
# light security check -- make sure redirect_to isn't garbage.
if not redirect_to or " " in redirect_to or redirect_to.startswith("http"):
Please sign in to comment.
Something went wrong with that request. Please try again.