django-persistent-messages


Namedjango-persistent-messages JSON
Version 0.3 PyPI version JSON
download
home_pagehttps://github.com/yunojuno/django-persistent-messages
SummaryWrapper around django.contrib.messages adding persistence.
upload_time2023-11-15 09:21:48
maintainerYunoJuno
docs_urlNone
authorYunoJuno
requires_python>=3.10,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Persistent Messages-like Framework for Django

Persisent, dismissable, targeted, messages framework for Django apps

## STATUS

Alpha - pls do not use. This README is six years old.

## Background

Django messages are great for one-off notifications to users, but not
for persistent notification banners. From the [official
documentation](https://docs.djangoproject.com/en/1.11/ref/contrib/messages/)
on the Django messages framework:

> Quite commonly in web applications, you need to display a one-time
> notification message to the user after processing a form or some other
> types of user input. [...] The messages framework allows you to
> temporarily store messages in one request and retrieve them for
> display in a subsequent request (usually the next one).

These one-time messages are usually dynamic, created within a view
function, to alert the user to something that has just happened. This
project is designed to extend the pattern to support configurable and
persistent messages to users. The canonical use case for this is the EU
Cookie warning. This appears to everyone (logged in or not) until the
user explicitly dismiss it. It is not related to any specific action
that the user has taken (beyond visiting the site for the first time),
and it persists across all requests.

## Requirements

-   Messages can be managed via the admin site
-   The message can contain HTML (specifically href links)
-   The message can be categorised (e.g. INFO | WARNING)
-   The message can be targeted to appear to the following groups:
    -   All users (inc. anonymous)
    -   Authenticated users only
    -   Specific user groups only
-   The message can be marked as dismissable
-   The message can be enabled / disabled
-   The message can expire (do not show after {{datetime}})
-   Track message dismissals

## Use cases

-   As the marketing team I would like to notify users of an event / activity
-   As the tech team I would like to alert users to platform maintenance
-   As the EU I would like to annoy people with a message about cookies

## Technical implementation

1. Print out all messages targeted at a user

```python
# live == enabled, not expired, not-dismissed, targeted at user
for m in PersistentMessage.objects.for_user(user).active():
    print(m.message)
```

2. Display messages in a template using template context

```html
<body>
    {% for m in persistent_messages %}
    <div class="{{m.extra_tags}}">{{ m.message }}</div>
    {% endfor %} ...
</body>
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yunojuno/django-persistent-messages",
    "name": "django-persistent-messages",
    "maintainer": "YunoJuno",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "code@yunojuno.com",
    "keywords": "",
    "author": "YunoJuno",
    "author_email": "code@yunojuno.com",
    "download_url": "https://files.pythonhosted.org/packages/aa/55/0b02396e2ced8ac9a52d31c30e01b9fb3f5e8fcf569cc69dd5f8bf6be789/django_persistent_messages-0.3.tar.gz",
    "platform": null,
    "description": "# Persistent Messages-like Framework for Django\n\nPersisent, dismissable, targeted, messages framework for Django apps\n\n## STATUS\n\nAlpha - pls do not use. This README is six years old.\n\n## Background\n\nDjango messages are great for one-off notifications to users, but not\nfor persistent notification banners. From the [official\ndocumentation](https://docs.djangoproject.com/en/1.11/ref/contrib/messages/)\non the Django messages framework:\n\n> Quite commonly in web applications, you need to display a one-time\n> notification message to the user after processing a form or some other\n> types of user input. [...] The messages framework allows you to\n> temporarily store messages in one request and retrieve them for\n> display in a subsequent request (usually the next one).\n\nThese one-time messages are usually dynamic, created within a view\nfunction, to alert the user to something that has just happened. This\nproject is designed to extend the pattern to support configurable and\npersistent messages to users. The canonical use case for this is the EU\nCookie warning. This appears to everyone (logged in or not) until the\nuser explicitly dismiss it. It is not related to any specific action\nthat the user has taken (beyond visiting the site for the first time),\nand it persists across all requests.\n\n## Requirements\n\n-   Messages can be managed via the admin site\n-   The message can contain HTML (specifically href links)\n-   The message can be categorised (e.g. INFO | WARNING)\n-   The message can be targeted to appear to the following groups:\n    -   All users (inc. anonymous)\n    -   Authenticated users only\n    -   Specific user groups only\n-   The message can be marked as dismissable\n-   The message can be enabled / disabled\n-   The message can expire (do not show after {{datetime}})\n-   Track message dismissals\n\n## Use cases\n\n-   As the marketing team I would like to notify users of an event / activity\n-   As the tech team I would like to alert users to platform maintenance\n-   As the EU I would like to annoy people with a message about cookies\n\n## Technical implementation\n\n1. Print out all messages targeted at a user\n\n```python\n# live == enabled, not expired, not-dismissed, targeted at user\nfor m in PersistentMessage.objects.for_user(user).active():\n    print(m.message)\n```\n\n2. Display messages in a template using template context\n\n```html\n<body>\n    {% for m in persistent_messages %}\n    <div class=\"{{m.extra_tags}}\">{{ m.message }}</div>\n    {% endfor %} ...\n</body>\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Wrapper around django.contrib.messages adding persistence.",
    "version": "0.3",
    "project_urls": {
        "Documentation": "https://github.com/yunojuno/django-persistent-messages",
        "Homepage": "https://github.com/yunojuno/django-persistent-messages",
        "Repository": "https://github.com/yunojuno/django-persistent-messages"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1fcfb0f04c15bcfdcc75371444f16c1240c20f6f6472c9578f717d5cdc6814cb",
                "md5": "d6476ebf68166748152e0acad5cbc23a",
                "sha256": "65f7fa9afd0ce11d8841c12f43a355144d5d66a9a905892e2d8b52bb4a96f7df"
            },
            "downloads": -1,
            "filename": "django_persistent_messages-0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d6476ebf68166748152e0acad5cbc23a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 14295,
            "upload_time": "2023-11-15T09:21:47",
            "upload_time_iso_8601": "2023-11-15T09:21:47.337047Z",
            "url": "https://files.pythonhosted.org/packages/1f/cf/b0f04c15bcfdcc75371444f16c1240c20f6f6472c9578f717d5cdc6814cb/django_persistent_messages-0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa550b02396e2ced8ac9a52d31c30e01b9fb3f5e8fcf569cc69dd5f8bf6be789",
                "md5": "561e7013b914fe7777871cc4be1eabeb",
                "sha256": "36bb654f8d7868a5217e571c71299ab92de41751a3a7abff36f1b091e8d6fa58"
            },
            "downloads": -1,
            "filename": "django_persistent_messages-0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "561e7013b914fe7777871cc4be1eabeb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 11204,
            "upload_time": "2023-11-15T09:21:48",
            "upload_time_iso_8601": "2023-11-15T09:21:48.950002Z",
            "url": "https://files.pythonhosted.org/packages/aa/55/0b02396e2ced8ac9a52d31c30e01b9fb3f5e8fcf569cc69dd5f8bf6be789/django_persistent_messages-0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-15 09:21:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yunojuno",
    "github_project": "django-persistent-messages",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "django-persistent-messages"
}
        
Elapsed time: 0.14815s