Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
 def _wrapped_render(name, *args, **kwargs):
     output = render_func(name, *args, **kwargs)
     user = LoggedInUserCache().current_user
     if self.add_url and (not self.with_perms or user.has_perms(self.with_perms)):
         tokens = {"name": name, "add_url": self.add_url, "label": _("Add")}
         output += (
             '<a id="add-%(name)s-link" title="%(label)s" target="_blank" href="%(add_url)s">%(label)s</a>\n'
             % tokens
         )
     return mark_safe(
         '<span id="add-%(name)s" class="add">\n%(output)s\n<br/>\n</span>' % {"name": name, "output": output}
     )
Ejemplo n.º 4
0
def notify_comment_created(sender, instance, *args, **kwargs):
    """Generates an activity related to the creation of a new comment.
    """
    if kwargs['created']:
        obj = instance.content_object

        create_stream(obj.__class__, obj)

        try:            
            stream = obj.stream

            author = instance.user or LoggedInUserCache().current_user

            register_follower_to_stream(author, stream)

            activity = Activity.objects.create(
                title=_("%(author)s commented %(class)s %(name)s"),
                signature="comment-created",
                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(),
                    "comment": instance.comment
                }),
                backlink=obj.get_absolute_url()
            )

            register_activity_to_stream(activity, stream)

        except:
            pass
Ejemplo n.º 5
0
 def _wrapped_render(name, *args, **kwargs):
     output = render_func(name, *args, **kwargs)
     user = LoggedInUserCache().current_user
     if self.add_url and (not self.with_perms
                          or user.has_perms(self.with_perms)):
         tokens = {
             'name': name,
             'add_url': self.add_url,
             'label': _('Add'),
         }
         output += '<a id="add-%(name)s-link" title="%(label)s" target="_blank" href="%(add_url)s">%(label)s</a>\n' % tokens
     return mark_safe(
         '<span id="add-%(name)s" class="add">\n%(output)s\n<br/>\n</span>'
         % {
             'name': name,
             'output': output
         })
Ejemplo n.º 6
0
    def process_request(self, request):
        logged_in_user = LoggedInUserCache()
        logged_in_user.set_user(request)

        return None
Ejemplo n.º 7
0
    def process_request(self, request):
        logged_in_user = LoggedInUserCache()
        logged_in_user.set_user(request)

        return None