This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Small core for dealing with activities & notifications.

Source code
http://github.com/pennersr/django-actistream

Rationale

There are quite some Django apps for dealing with activities & notifications, yet none match my expectations/requirements:

  • Action URLs: they do not belong in the database/models, as your database records will outlive the URL routing configuration.
  • Texts & descriptions: these neither belong in the database/models. If you need to change the wording or correct a typ-o, you should not have to go over all existing records to make the change as well. But more importantly, you need to cater for internationalization, so these belong in templates where e.g. {% blocktrans %} can be used.
  • Views: any views that are offered out of the box are not going to match your requirements, and won’t fit in with your single page application.
  • Project specific data: actistream allows for storing additional project specific data per activity, and flagging activities in a performant manner.

Concepts

An activity is about an actor, involved in an action of a certain activity type, relating an action object to a target. For example:

  • John (=the actor) has posted a comment (=the activity type) stating “I don’t get it!” (=the action object) on the blog post titled “actistream for dummies” (the target).

A notice is an action addressed to a user. So, in Jane’s inbox you may want to display that John posted that comment. For that purpose, create a Notice relating the above activity to Jane.

Quick Start

Suppose you have a an app called blog dealing with posts and comments. Create a file named blog/activities.py, containing:

from actistream.types import ActivityWrapper, ActivityType

class CommentPosted(ActivityType):
    verbose_name = 'Comment posted'

    class Wrapper(ActivityWrapper):
        """
        Wraps the generic ``Activity`` model, expose any helper methods
        you see fit. Notice that the action URL is not stored in the
        database.
        """

        def get_action_url(self):
            return self.activity.action_object.get_absolute_url()

        def is_active(self):
            """
            Completely optional, but just to show that it handles
            the case where things get deleted.
            """
            comment = self.activity.action_object
            return not comment.post.is_deleted

Given the above, whenever a new comment is created, do:

from blog.activities import CommentPosted

def some_view(request):
    ...
    activity = CommentPosted.create(
        target=post,  # The post that gets commented
        actor=self.request.user,
        action_object=comment,  # The newly posted comment
    )

To notice users about this activity, do:

from actistream.models import Notice

notice_recipients = User.objects.filter(...)
Notice.objects.send(
    activity,
    notice_recipients)

Notices need to be turned into emails. For that purpose you’ll need to setup a few templates:

blog/activities/commentposted_subject.txt
blog/activities/commentposted_message.txt
blog/activities/commentposted_message.html

Only one of .txt or .html is required, both are allowed for combined text and HTML mails.

For turning an activity into an HTML snippet, e.g. to be displayed in a feed, do:

{% load actistream %}
{% render_activity activity %}

This will try to find a template named:

blog/activities/commentposted_detail.html

Which could look someting like:

{{ activity.actor }} posted a comment to
<a href="{{activity.wrapper.get_action_url}}">{{ activity.action_object.post }}</a>.

Status

Running in production since 2012, released as open source in september 2016.

Release History

Release History

1.0.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

1.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-actistream-1.0.4.tar.gz (10.9 kB) Copy SHA256 Checksum SHA256 Source Nov 25, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting