Add some extra metadata to notifications

This commit is contained in:
Trever Fischer
2012-06-08 14:54:00 -04:00
parent f99949cb7b
commit cad9da3446
3 changed files with 4 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ from django.db import models
from django.contrib.auth.models import User
import api
from notification import models as notification
from django.core.urlresolvers import reverse
from django.dispatch import dispatcher
@@ -55,7 +56,7 @@ class Award(models.Model):
def save(self, *args, **kwargs):
super(Award, self).save(*args, **kwargs)
api.badge_awarded.send_robust(sender=intern(str(self.badge.slug)), award=self)
notification.send([self.user], "badge_awarded", {"award": self})
notification.send([self.user], "badge_awarded", {"award": self, 'notice_description': self.badge, 'notice_url': reverse('user_profile')})
def __unicode__(self):
return "%s for %s"%(self.badge.__unicode__(), self.user.__unicode__())

View File

@@ -40,7 +40,7 @@ def reply(request, topicID=None):
reply.body = form.cleaned_data['body']
reply.user = request.user
reply.save()
notification.send([reply.parent.user], "forum_reply", {"reply": reply})
notification.send([reply.parent.user], "forum_reply", {"reply": reply, 'notice_url': reverse('forums.views.post', kwargs={'id':reply.id}), 'notice_description': reply.topic().title})
messages.info(request, "Reply successful")
return HttpResponseRedirect(reverse('forums.views.post', kwargs={"id":reply.id}))
return render_to_response('forums/reply.html', {"post":parentPost, "form":form}, context_instance = RequestContext(request))

View File

@@ -0,0 +1 @@
{% load i18n %}{% if notice_url %}<a href="{{notice_url}}">{%endif%}{% blocktrans %}{{ notice }}{%endblocktrans%}{% if notice_description %}: {{ notice_description }}{% endif %}{%if notice_url %}</a>{%endif %}