{ "info": { "author": "mpasternak", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "Monitio for Django\n==================\n\nMonitio allows you to have messages (aka notifications), that:\n\n* can be persisted (stored in the database and read later),\n* which dynamically show on the web UI when added,\n* and can be optionally sent via e-mail to your end-user.\n\nMonitio is built upon:\n\n* [django-sse](https://github.com/niwibe/django-sse)\n * which uses [django-redis](https://github.com/niwibe/django-redis)\n * ... and [Redis database](https://redis.io)\n* [Yaffle's EventSource.js](https://github.com/Yaffle/EventSource) for cross-browser Server-Sent Events compatibility\n* [django-cors-headers](https://github.com/ottoyiu/django-cors-headers) for the same thing\n* [django-transaction-signals](https://github.com/davehughes/django-transaction-signals)\n* [jQuery](http://jquery.com/) and [jQueryUI](http://jqueryui.com)\n\nWith such sophisticated setup, using packages from many individuals, the demo \napplication is currently properly running on MSIE 10, Opera 12, FFox 16 and \nSafari 5.1.7 on Windows. Also, monitio has been tested in production environment\nwith nginx + gunicorn, which also has been found to work properly. \n\nDocumentation\n-------------\n\nA Django app for unified, persistent and live user messages/notifications, built on top of Django's [messages framework](http://docs.djangoproject.com/en/dev/ref/contrib/messages/) (`django.contrib.messages`).\n\nMonitio is a messages storage backend that provides support for messages that are supposed to be persistent, that is, they outlast a browser session and will be stored in the database. These messages can be displayed as you will to the user, you can let the user mark them as read, remove them or even reply them. For some of these actions there are views you can import in your project urls.py.\n\n* Support persistent and nonpersistent messages for authenticated users. Persistent messages are stored in the database. \n* For anonymous users, messages are stored using the cookie/session-based approach. There is no support for persistent messages for anonymous users.\n* There is a unified API for displaying messages to both types of users, that is, you can use the same code you'd be using with Django's messaging framework in order to add and display messages, but there is additional functionality available if the user is authenticated.\n\nInstallation\n------------\n\nThis document assumes that you are familiar with Python and Django.\n\n1. Clone this git repository (no PyPI package for this fork). master branch is the lastest stable branch: \n\n $ git clone git://github.com/mpasternak/django-monitio.git\n\n2. Make sure `monitio` is in your `PYTHONPATH`.\n3. Add `monitio` & company to your `INSTALLED_APPS` setting.\n\n INSTALLED_APPS = (\n ...\n 'django_sse',\n 'corsheaders',\n 'monitio',\n )\n\n4. Make sure Django's `MessageMiddleware` is in your `MIDDLEWARE_CLASSES` setting (which is the case by default), also enable `CorsMiddleware` there. Add `LocaleMiddleware` if you want to use translations:\n\n MIDDLEWARE_CLASSES = (\n ...\n 'django.contrib.messages.middleware.MessageMiddleware',\n \t\t'corsheaders.middleware.CorsMiddleware',\n 'django.middleware.locale.LocaleMiddleware',\n ...\n )\n\n5. Add the CONTEXT_PROCESSOR for messages and static URL:\n\n CONTEXT_PROCESSORS = (\n ...\n 'django.contrib.messages.context_processors.messages',\n 'django.core.context_processors.static',\n ...\n )\n\n \n6. Add the `monitio` URLs to your URL conf. For instance, in order to make messages available under `http://domain.com/messages/`, add the following line to `urls.py`.\n\n urlpatterns = patterns('',\n (r'^messages/', include('monitio.urls', namespace='monitio')),\n ...\n )\n\n7. In your settings, set the message [storage backend](http://docs.djangoproject.com/en/dev/ref/contrib/messages/#message-storage-backends) to `monitio.storage.PersistentMessageStorage`:\n\n MESSAGE_STORAGE = 'monitio.storage.PersistentMessageStorage'\n \n8. In your settings, add a reasonable default, which will prevent from showing read messages to the users:\n\n MONITIO_EXCLUDE_READ = True\n \n9. Setup `django-sse` and `corsheaders`:\n\n REDIS_SSEQUEUE_CONNECTION_SETTINGS = {\n 'location': '127.0.0.1:6379',\n 'db': 0,\n }\n \n CORS_ORIGIN_WHITELIST = (\n '127.0.0.1',\n '127.0.0.1:8000',\n )\n\n10. Set up the database tables using\n\n\t $ manage.py syncdb\n\n11. If you want to use the bundled templates, add the `templates` directory to your `TEMPLATE_DIRS` setting:\n\n TEMPLATE_DIRS = (\n ...\n 'path/to/monitio/templates')\n )\n \n12. Setup a production server - for [nginx](http://nginx.org/) + [gunicorn](http://gunicorn.org), please use configuration below:\n\n\t\t\n\t\tlocation ~ ^/messages {\n\t\t\tproxy_pass http://your-gunicorn-address.../\n\t\t\tproxy_buffering off;\n\t\t\tproxy_cache off;\n\t\t\tproxy_set_header Host $host;\n\t\t\t\n\t\t\tproxy_set_header Connection '';\n\t\t\tproxy_http_version 1.1;\n\t\t\tchunked_transfer_encoding off;\n\t\t}\n\n And, for [gunicorn](http://gunicorn.org), make sure you install [gevent](http://www.gevent.org/) and run [gunicorn](http://gunicorn.org) with parameter `-k gevent`\n\n\nUsing messages in views and templates\n-------------------------------------\n\n### Message levels ###\n\nDjango's messages framework provides a number of [message levels](http://docs.djangoproject.com/en/dev/ref/contrib/messages/#message-levels) for various purposes such as success messages, warnings etc. \n\n import monitio\n # persistent message levels:\n monitio.INFO\n monitio.SUCCESS\n monitio.WARNING\n monitio.ERROR\n \nThis app provides constants with the same names, the difference being that messages with these levels are going to be persistent:\n\n from django.contrib import messages\n # temporary message levels:\n messages.INFO \n messages.SUCCESS \n messages.WARNING\n messages.ERROR\n\n**Note**: Let's stress the importance of this. If you use `monitio` constants the message will be stored in the database and kept there till somebody explicitly deletes it. If you use `contrib.messages` constants, you get the same behavior as if you were using a non persistent storage, messages are stored in the database ensuring reception but they are removed right after being accessed.\n\n### Adding a message ###\n\nSince the app is implemented as a [storage backend](http://docs.djangoproject.com/en/dev/ref/contrib/messages/#message-storage-backends) for Django's [messages framework](http://docs.djangoproject.com/en/dev/ref/contrib/messages/), you can still use the regular Django API to add a message:\n\n from django.contrib import messages\n messages.add_message(request, messages.INFO, 'Hello world.')\n\nThis is compatible and equivalent to using the API provided by `monitio`:\n\n import monitio\n from django.contrib import messages\n monitio.add_message(request, messages.INFO, 'Hello world.')\n\nIn order to add a persistent message (one that is stored permanently in the Database), use `monitio` levels listed above:\n\n messages.add_message(request, monitio.WARNING, 'This message is stored in monitio table till removed.')\n\nor the equivalent:\n\n monitio.add_message(request, monitio.WARNING, 'This message is stored in monitio table till removed')\n \nNote that this is only possible for logged-in users, so you are probably going to have make sure that the current user is not anonymous using `request.user.is_authenticated()`. Adding a persistent message for anonymous users raises a `NotImplementedError`.\n\n### Extended API ###\n\nPersistent Messages has an extended API that will let you do some extra nice things. This is the prototype of `add_message` in contrib messages:\n\n def add_message(request, level, message, extra_tags='', fail_silently=False):\n\nThis is the prototype of `add_message` in Persistent Messages.\n\n def add_message(request, level, message, extra_tags='', fail_silently=False, subject='', user=None, email=False, from_user=None, expires=None, close_timeout=None):\n\n#### Subject and email notifications ####\n\nUsing `monitio.add_message`, you can also add a subject line to the message. You can also set if you want an email notification to be sent. The following message will be stored as a message in the database and also sent to the email address associated with the current user:\n\n monitio.add_message(request, monitio.INFO, 'Message body', subject='Please read me', email=True)\n\n**Note!** Email notifications at the moment are too simple, I don't recommend using them, I'm not.\n\n#### Send messages to different users ####\n\nYou can also pass this function a `User` object if the message is supposed to be sent to a user other than the one who is currently authenticated. User Sally will see this message the next time she logs in:\n\n from django.contrib.auth.models import User\n sally = User.objects.get(username='Sally')\n monitio.add_message(request, monitio.SUCCESS, 'Hi Sally, here is a message to you.', subject='Success message', user=sally)\n \nYou can also set a `from_user`, which lets you use Persistent Messages as messaging system between users.\n\n#### You can make messages expire ####\n\nYou need to pass a date and time to `expires` argument. Once the message has expired, it will not be included in the returned QuerySet. At the moment there is no view or method to clear expired messages from database.\n\n### Displaying messages ###\n\nTo add monitio to your template:\n\n* add to `
` section:\n ```\n {% include \"monitio/header.html\" %}\n ```\n \n This will include `yaffle.js`, `monitio.js` monitio translations and themes.\n \n* in the `` section, place the message placeholder anywhere you like:\n\n ```\n \n ```\n \n* ... and initialize monitio, optionally passing theme parameter:\n ```\n $(document).ready(function () {\n $(\"#monitioMessages\").MessagesPlaceholder({\n \"url\": '{% url \"monitio:persistent-messages-sse\" user.username %}',\n \"theme\": \"foundation\" // remove for jqueryui theme \n });\n });\n ```\n* don't forget to add links to `jquery`, `jqueryui` and optionally to `foundation 5`\n\n* if any problems, check `foundation_index.html` in the `test_app/templates` directory, as it is much simpler than original one. \n\n### Creating notifications from background tasks (eg. Celery) ###\n\nTo create a notofication from a long-running, background process, use\napi.create_message:\n\n def create_message(to_user, level, message, from_user=None, extra_tags='',\n subject='', expires=None, close_timeout=None, sse=True,\n email=False):\n\nThis function will call PersistentStorage.add method for you.\n\n### Storage extra methods ###\n\nIn Django `request._messages` is set to the default storage you configured in your settings. Persistent Messages storage has some extra methods that Django built-in storages don't have that can be very useful:\n\n* **get_persistent**: Get read and unread persistent messages\n* **get_persistent_unread**: Get unread persistent messages\n* **get_nonpersistent**: Gets nonpersistent messages\n* **count_unread**: Counts persistent and nonpersistent unread messages\n* **count_persistent_unread**: Counts persistent unread messages\n* **count_nonpersistent**: Counts nonpersistent messages\n\nLet's see some examples of what this means.\n\n#### Display number of unread messages ####\n\nImagine you've created an inbox for your users using Persistent Messages and you want to show them in the menu how many unread messages they have, if they have them:\n\n \n\n### AUTHORS ###\n\ndjango-monitio is (C) 2013 [mpasternak](https://github.com/mpasternak). \n\n[philomat](https://github.com/philomat) is the author of original code for\n[django-persistent-messages](https://github.com/philomat/django-persistent-messages),\nwhich was then forked by [maurojp](https://github.com/maurojp).", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/mpasternak/django-monitio", "keywords": "messages,django,persistent,sse", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-monitio", "package_url": "https://pypi.org/project/django-monitio/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-monitio/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/mpasternak/django-monitio" }, "release_url": "https://pypi.org/project/django-monitio/0.3.1/", "requires_dist": null, "requires_python": null, "summary": "Unified, persistent and dynamic user messages/notifications for Django", "version": "0.3.1" }, "last_serial": 944606, "releases": { "0.1": [], "0.3": [ { "comment_text": "", "digests": { "md5": "c423401505483bd7c7207170302d5dd8", "sha256": "1dc05e356f9db38de244eb027ff3236598349c0fa058011bfc51a78e27e88d9f" }, "downloads": -1, "filename": "django-monitio-0.3.zip", "has_sig": false, "md5_digest": "c423401505483bd7c7207170302d5dd8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 41942, "upload_time": "2013-12-13T21:56:57", "url": "https://files.pythonhosted.org/packages/18/a6/44bc96c2256bc11c05f827ce0bca2d0c9109d44aa5de6a3a8ee0fea500a7/django-monitio-0.3.zip" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "206e03692376459bd97cc20acfbf06e0", "sha256": "2cdd4d4a6fa875dcb51abc0686f56c98b6d13867167be86a7bf67f9e33a06e85" }, "downloads": -1, "filename": "django-monitio-0.3.1.zip", "has_sig": false, "md5_digest": "206e03692376459bd97cc20acfbf06e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 42048, "upload_time": "2013-12-14T17:54:59", "url": "https://files.pythonhosted.org/packages/8d/31/c1f71957a0925923e4bbd60b0afb1192ba4d8e9ba7507fa6119b0a671554/django-monitio-0.3.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "206e03692376459bd97cc20acfbf06e0", "sha256": "2cdd4d4a6fa875dcb51abc0686f56c98b6d13867167be86a7bf67f9e33a06e85" }, "downloads": -1, "filename": "django-monitio-0.3.1.zip", "has_sig": false, "md5_digest": "206e03692376459bd97cc20acfbf06e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 42048, "upload_time": "2013-12-14T17:54:59", "url": "https://files.pythonhosted.org/packages/8d/31/c1f71957a0925923e4bbd60b0afb1192ba4d8e9ba7507fa6119b0a671554/django-monitio-0.3.1.zip" } ] }