{ "info": { "author": "James Tauber", "author_email": "jtauber@jtauber.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3" ], "description": ".. _usage:\n\nUsage\n=====\n\nIntegrating notification support into your app is a simple three-step process.\n\n * create your notice types\n * create your notice templates\n * send notifications\n\nCreating Notice Types\n---------------------\n\nYou need to call ``create_notice_type(label, display, description)`` once to\ncreate the notice types for your application in the database. ``label`` is just\nthe internal shortname that will be used for the type, ``display`` is what the\nuser will see as the name of the notification type and `description` is a\nshort description.\n\nFor example::\n\n notification.create_notice_type(\"friends_invite\", \"Invitation Received\", \"you have received an invitation\")\n\nOne good way to automatically do this notice type creation is in a\n``management.py`` file for your app, attached to the syncdb signal.\nHere is an example::\n\n from django.conf import settings\n from django.db.models import signals\n from django.utils.translation import ugettext_noop as _\n \n if \"notification\" in settings.INSTALLED_APPS:\n from notification import models as notification\n \n def create_notice_types(app, created_models, verbosity, **kwargs):\n notification.create_notice_type(\"friends_invite\", _(\"Invitation Received\"), _(\"you have received an invitation\"))\n notification.create_notice_type(\"friends_accept\", _(\"Acceptance Received\"), _(\"an invitation you sent has been accepted\"))\n \n signals.post_syncdb.connect(create_notice_types, sender=notification)\n else:\n print \"Skipping creation of NoticeTypes as notification app not found\"\n\nNotice that the code is wrapped in a conditional clause so if\ndjango-notification is not installed, your app will proceed anyway.\n\nNote that the display and description arguments are marked for translation by\nusing ugettext_noop. That will enable you to use Django's makemessages\nmanagement command and use django-notification's i18n capabilities.\n\nNotification templates\n----------------------\n\nThere are four different templates that can be written to for the actual content of the notices:\n\n * ``short.txt`` is a very short, text-only version of the notice (suitable for things like email subjects)\n * ``full.txt`` is a longer, text-only version of the notice (suitable for things like email bodies)\n * ``notice.html`` is a short, html version of the notice, displayed in a user's notice list on the website\n * ``full.html`` is a long, html version of the notice (not currently used for anything)\n\nEach of these should be put in a directory on the template path called ``notification//``.\nIf any of these are missing, a default would be used. In practice, ``notice.html`` and ``full.txt`` should be provided at a minimum.\n\nFor example, ``notification/friends_invite/notice.html`` might contain::\n \n {% load i18n %}{% url invitations as invitation_page %}{% url profile_detail username=invitation.from_user.username as user_url %}\n {% blocktrans with invitation.from_user as invitation_from_user %}{{ invitation_from_user }} has requested to add you as a friend (see invitations){% endblocktrans %}\n\nand ``notification/friends/full.txt`` might contain::\n \n {% load i18n %}{% url invitations as invitation_page %}{% blocktrans with invitation.from_user as invitation_from_user %}{{ invitation_from_user }} has requested to add you as a friend. You can accept their invitation at:\n \n http://{{ current_site }}{{ invitation_page }}\n {% endblocktrans %}\n\nThe context variables are provided when sending the notification.\n\n\nSending Notification\n====================\n\nThere are two different ways of sending out notifications. We have support\nfor blocking and non-blocking methods of sending notifications. The most\nsimple way to send out a notification, for example::\n\n notification.send([to_user], \"friends_invite\", {\"from_user\": from_user})\n\nOne thing to note is that ``send`` is a proxy around either ``send_now`` or\n``queue``. They all have the same signature::\n\n send(users, label, extra_context)\n\nThe parameters are:\n\n * ``users`` is an iterable of ``User`` objects to send the notification to.\n * ``label`` is the label you used in the previous step to identify the notice\n type.\n * ``extra_content`` is a dictionary to add custom context entries to the\n template used to render to notification. This is optional.\n\n``send_now`` vs. ``queue`` vs. ``send``\n---------------------------------------\n\nLets first break down what each does.\n\n``send_now``\n~~~~~~~~~~~~\n\nThis is a blocking call that will check each user for elgibility of the\nnotice and actually peform the send.\n\n``queue``\n~~~~~~~~~\n\nThis is a non-blocking call that will queue the call to ``send_now`` to\nbe executed at a later time. To later execute the call you need to use\nthe ``emit_notices`` management command.\n\n``send``\n~~~~~~~~\n\nA proxy around ``send_now`` and ``queue``. It gets its behavior from a global\nsetting named ``NOTIFICATION_QUEUE_ALL``. By default it is ``False``. This\nsetting is meant to help control whether you want to queue any call to\n``send``.\n\n``send`` also accepts ``now`` and ``queue`` keyword arguments. By default\neach option is set to ``False`` to honor the global setting which is ``False``.\nThis enables you to override on a per call basis whether it should call\n``send_now`` or ``queue``.\n\nOptional notification support\n-----------------------------\n\nIn case you want to use django-notification in your reusable app, you can\nwrap the import of django-notification in a conditional clause that tests\nif it's installed before sending a notice. As a result your app or\nproject still functions without notification.\n\nFor example::\n\n from django.conf import settings\n\n if \"notification\" in settings.INSTALLED_APPS:\n from notification import models as notification\n else:\n notification = None\n\nand then, later::\n\n if notification:\n notification.send([to_user], \"friends_invite\", {\"from_user\": from_user})", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pinax/django-notification", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-anonymous-notification", "package_url": "https://pypi.org/project/django-anonymous-notification/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-anonymous-notification/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/pinax/django-notification" }, "release_url": "https://pypi.org/project/django-anonymous-notification/1.2.1/", "requires_dist": null, "requires_python": null, "summary": "User notification management for the Django web framework", "version": "1.2.1" }, "last_serial": 1358427, "releases": { "1.2.1": [ { "comment_text": "", "digests": { "md5": "04bbdb1a27c8949d7145fee2885c8a92", "sha256": "bec442abafdc9ca141aa466152acdd2127ad5b38e29e388c3061a233872eb31d" }, "downloads": -1, "filename": "django-anonymous-notification-1.2.1.tar.gz", "has_sig": true, "md5_digest": "04bbdb1a27c8949d7145fee2885c8a92", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27642, "upload_time": "2014-10-23T10:47:43", "url": "https://files.pythonhosted.org/packages/d3/5a/b3b826a7bffbdfd261752496575bbc409929996c8da0c3127ddfb6eaf7ef/django-anonymous-notification-1.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "04bbdb1a27c8949d7145fee2885c8a92", "sha256": "bec442abafdc9ca141aa466152acdd2127ad5b38e29e388c3061a233872eb31d" }, "downloads": -1, "filename": "django-anonymous-notification-1.2.1.tar.gz", "has_sig": true, "md5_digest": "04bbdb1a27c8949d7145fee2885c8a92", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27642, "upload_time": "2014-10-23T10:47:43", "url": "https://files.pythonhosted.org/packages/d3/5a/b3b826a7bffbdfd261752496575bbc409929996c8da0c3127ddfb6eaf7ef/django-anonymous-notification-1.2.1.tar.gz" } ] }