django-actistream


Namedjango-actistream JSON
Version 3.0.2 PyPI version JSON
download
home_pagehttp://github.com/pennersr/django-actistream
SummaryActivities & notifications for Django
upload_time2023-08-16 10:11:25
maintainer
docs_urlNone
authorRaymond Penners
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            =============================
Welcome to django-actistream!
=============================

.. image:: https://badge.fury.io/py/django-actistream.png
   :target: http://badge.fury.io/py/django-actistream

.. image:: https://github.com/pennersr/django-actistream/actions/workflows/ci.yml/badge.svg
   :target: https://github.com/pennersr/django-actistream/actions

.. image:: https://img.shields.io/pypi/v/django-actistream.svg
   :target: https://pypi.python.org/pypi/django-actistream

.. image:: https://coveralls.io/repos/pennersr/django-actistream/badge.png?branch=main&_
   :alt: Coverage Status
   :target: https://coveralls.io/r/pennersr/django-actistream

.. image:: https://pennersr.github.io/img/bitcoin-badge.svg
   :target: https://blockchain.info/address/1AJXuBMPHkaDCNX2rwAy34bGgs7hmrePEr

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.

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/pennersr/django-actistream",
    "name": "django-actistream",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Raymond Penners",
    "author_email": "raymond.penners@intenct.nl",
    "download_url": "https://files.pythonhosted.org/packages/67/aa/2e5c017f678f281c4e6365d994c265c122b71b59c0e3c43b4119f1228862/django-actistream-3.0.2.tar.gz",
    "platform": "any",
    "description": "=============================\nWelcome to django-actistream!\n=============================\n\n.. image:: https://badge.fury.io/py/django-actistream.png\n   :target: http://badge.fury.io/py/django-actistream\n\n.. image:: https://github.com/pennersr/django-actistream/actions/workflows/ci.yml/badge.svg\n   :target: https://github.com/pennersr/django-actistream/actions\n\n.. image:: https://img.shields.io/pypi/v/django-actistream.svg\n   :target: https://pypi.python.org/pypi/django-actistream\n\n.. image:: https://coveralls.io/repos/pennersr/django-actistream/badge.png?branch=main&_\n   :alt: Coverage Status\n   :target: https://coveralls.io/r/pennersr/django-actistream\n\n.. image:: https://pennersr.github.io/img/bitcoin-badge.svg\n   :target: https://blockchain.info/address/1AJXuBMPHkaDCNX2rwAy34bGgs7hmrePEr\n\nSmall core for dealing with activities & notifications.\n\nSource code\n  http://github.com/pennersr/django-actistream\n\n\nRationale\n=========\n\nThere are quite some Django apps for dealing with activities & notifications,\nyet none match my expectations/requirements:\n\n- Action URLs: they do not belong in the database/models, as your database\n  records will outlive the URL routing configuration.\n\n- Texts & descriptions: these neither belong in the database/models. If you need to change\n  the wording or correct a typ-o, you should not have to go over all existing records to\n  make the change as well. But more importantly, you need to cater for internationalization,\n  so these belong in templates where e.g. ``{% blocktrans %}`` can be used. \n\n- Views: any views that are offered out of the box are not going to match your requirements,\n  and won't fit in with your single page application.\n\n- Project specific data: `actistream` allows for storing additional project\n  specific data per activity, and flagging activities in a performant manner.\n\nConcepts\n========\n\nAn activity is about an actor, involved in an action of a certain activity type, relating an action object to a target. For example:\n\n- *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).\n\nA 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.\n\nQuick Start\n===========\n\nSuppose you have a an app called ``blog`` dealing with posts and comments.\nCreate a file named ``blog/activities.py``, containing::\n\n    from actistream.types import ActivityWrapper, ActivityType\n    \n    class CommentPosted(ActivityType):\n        verbose_name = 'Comment posted'\n    \n        class Wrapper(ActivityWrapper):\n            \"\"\"\n            Wraps the generic ``Activity`` model, expose any helper methods\n            you see fit. Notice that the action URL is not stored in the \n            database.\n            \"\"\"\n\n            def get_action_url(self):\n                return self.activity.action_object.get_absolute_url()\n    \n            def is_active(self):\n                \"\"\"\n                Completely optional, but just to show that it handles\n                the case where things get deleted.\n                \"\"\"\n                comment = self.activity.action_object\n                return not comment.post.is_deleted\n\n\nGiven the above, whenever a new comment is created, do::\n\n    from blog.activities import CommentPosted\n\n    def some_view(request):\n        ...\n        activity = CommentPosted.create(\n            target=post,  # The post that gets commented\n            actor=self.request.user,\n            action_object=comment,  # The newly posted comment\n        )\n\nTo notice users about this activity, do::\n\n    from actistream.models import Notice\n\n    notice_recipients = User.objects.filter(...)\n    Notice.objects.send(\n        activity,\n        notice_recipients)\n\nNotices need to be turned into emails. For that purpose you'll need to setup a few templates::\n\n    blog/activities/commentposted_subject.txt\n    blog/activities/commentposted_message.txt\n    blog/activities/commentposted_message.html\n\nOnly one of ``.txt`` or ``.html`` is required, both are allowed for combined\ntext and HTML mails.\n\nFor turning an activity into an HTML snippet, e.g. to be displayed in a feed, do::\n\n    {% load actistream %}\n    {% render_activity activity %}\n\nThis will try to find a template named::\n\n    blog/activities/commentposted_detail.html\n\nWhich could look someting like::\n\n    {{ activity.actor }} posted a comment to\n    <a href=\"{{activity.wrapper.get_action_url}}\">{{ activity.action_object.post }}</a>.\n\n\nStatus\n======\n\nRunning in production since 2012, released as open source in september 2016.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Activities & notifications for Django",
    "version": "3.0.2",
    "project_urls": {
        "Changelog": "https://github.com/pennersr/django-actistream/blob/main/ChangeLog.rst",
        "Donate": "https://github.com/sponsors/pennersr",
        "Homepage": "http://github.com/pennersr/django-actistream",
        "Source": "http://github.com/pennersr/django-actistream",
        "Tracker": "https://github.com/pennersr/django-actistream/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67aa2e5c017f678f281c4e6365d994c265c122b71b59c0e3c43b4119f1228862",
                "md5": "803a051b9b5a5855a07f3b54c5617414",
                "sha256": "fdf4b3069e17f8d9992f28cc141764caac065ad50f1873d468d2f0eb512a121d"
            },
            "downloads": -1,
            "filename": "django-actistream-3.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "803a051b9b5a5855a07f3b54c5617414",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13951,
            "upload_time": "2023-08-16T10:11:25",
            "upload_time_iso_8601": "2023-08-16T10:11:25.040589Z",
            "url": "https://files.pythonhosted.org/packages/67/aa/2e5c017f678f281c4e6365d994c265c122b71b59c0e3c43b4119f1228862/django-actistream-3.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-16 10:11:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pennersr",
    "github_project": "django-actistream",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "django-actistream"
}
        
Elapsed time: 0.18582s