I'm using django-badges in my project which can emit a signal when a user 
is awarded a badge. I was able to implemented a receiver function, however 
the output is the following:

signals.py (from badges):
import django.dispatch

badge_awarded = django.dispatch.Signal(providing_args=['user', 'badge'])



my receiver function test:

from badges.signals import badge_awarded
@receiver(badge_awarded)
def do_something_after_badge_awarded(sender, user, badge, **kwargs):
    print "Badge Signal received"
    print sender # <play.meta_badges.neueBadge object at 0x109733d90>
    print user # user object
    print badge # badge object
    print kwargs



and the output was:
Badge Signal received
<play.meta_badges.neueBadge object at 0x109733d90>
player1
Test Badge 2
{'signal': <django.dispatch.dispatcher.Signal object at 0x1096da4d0>}


I want to add a message to the request, to notify or show the user that he 
earned a badge. Is it possible someone get hold of the request? I can 
freely modify the original source code from django-badges. Currently it's 
invoked by post_save() on a model instance. So I doubt I can get the 
request from there. 

I found a solution to add another 3rd party app which is called 
django-notification, but I don't want to add too many apps to my project. 
Another solution might be to just set some variable in the database and in 
my view to query this variable - however that will also cost performance 
and two database hits.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5e8f655c-8385-46aa-94ae-2c5baef2034a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to