django-persistent-messages 0.3

Creator: codyrutscher

Last updated:

Add to Cart

Description:

djangopersistentmessages 0.3

# Persistent Messages-like Framework for DjangoPersisent, dismissable, targeted, messages framework for Django apps## STATUSAlpha - pls do not use. This README is six years old.## BackgroundDjango messages are great for one-off notifications to users, but notfor persistent notification banners. From the [officialdocumentation](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 viewfunction, to alert the user to something that has just happened. Thisproject is designed to extend the pattern to support configurable andpersistent messages to users. The canonical use case for this is the EUCookie warning. This appears to everyone (logged in or not) until theuser explicitly dismiss it. It is not related to any specific actionthat 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 implementation1. Print out all messages targeted at a user```python# live == enabled, not expired, not-dismissed, targeted at userfor 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>```

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.