Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a post_viewed signal

  • Loading branch information...
commit f0751090446187c6de445882cb340b4261a40bc3 1 parent 58becaa
@paltman paltman authored
Showing with 7 additions and 3 deletions.
  1. +1 −0  biblion/signals.py
  2. +6 −3 biblion/views.py
View
1  biblion/signals.py
@@ -4,3 +4,4 @@
post_created = django.dispatch.Signal(providing_args=["post", "request"])
post_updated = django.dispatch.Signal(providing_args=["post", "request"])
post_deleted = django.dispatch.Signal(providing_args=["post", "request"])
+post_viewed = django.dispatch.Signal(providing_args=["post", "request"])
View
9 biblion/views.py
@@ -6,15 +6,13 @@
from django.template import RequestContext
from django.template.loader import render_to_string
from django.utils import simplejson as json
-from django.utils.translation import ugettext
from django.views.generic import ListView, CreateView
-from django.contrib import messages
from django.contrib.sites.models import Site
from biblion.forms import BlogForm, ImageForm, PostForm
from biblion.models import Blog, FeedHit, Section
-from biblion.signals import post_created, post_updated, post_deleted
+from biblion.signals import post_created, post_updated, post_deleted, post_viewed
def blog_index(request, blog_slug):
@@ -184,6 +182,11 @@ def blog_post_detail(request, **kwargs):
)
post = get_object_or_404(queryset, slug=kwargs["slug"])
post.inc_views()
+ post_viewed.send(
+ sender=post,
+ post=post,
+ request=request
+ )
return render_to_response("biblion/blog_post.html", {
"blog": blog,
Please sign in to comment.
Something went wrong with that request. Please try again.