def notify_comment_deleted(sender, instance, *args, **kwargs): """Generates an activity related to the deletion of an existing comment. """ obj = instance.content_object create_stream(obj.__class__, obj) try: stream = obj.stream author = LoggedInUserCache().current_user or instance.user register_follower_to_stream(author, stream) activity = Activity.objects.create( title=_("comment deleted by %(author)s"), signature="comment-deleted", context=json.dumps({ "class": obj.__class__.__name__.lower(), "name": "%s" % obj, "link": instance.get_absolute_url(), "author": "%s" % author, "author_link": author.get_absolute_url() }) ) register_activity_to_stream(activity, stream) except: pass
def notify_object_deleted(sender, instance, *args, **kwargs): """Generates an activity related to the deletion of an existing object. """ create_stream(sender, instance) try: stream = kwargs.get('stream', instance.stream) author = LoggedInUserCache().current_user title = _("%(class)s %(name)s deleted") context = { "class": sender.__name__.lower(), "name": "%s" % instance } register_follower_to_stream(author, stream) if author: title = _("%(class)s %(name)s deleted by %(author)s") context.update({ "author": "%s" % author, "author_link": author.get_absolute_url() }) activity = Activity.objects.create( title=title, signature="%s-deleted" % sender.__name__.lower(), template="notifications/activities/object-deleted.html", context=json.dumps(context) ) register_activity_to_stream(activity, stream) except: pass