Site-wide announcements for Mezzanine websites
Project description
Mezzanine Announcements
A Mezzanine app to create and display site-wide announcements.
Features
- Schedulable announcements (start and end datetimes)
- Define as many announcement types as you want in settings
- Make announcements optionally dismissable by the user
- An announcement will not bother the user after they have dismissed it
- Optionally make the announcement reappear after a set amount of days
- Add an optional time delay after page load before showing an announcement
Installation
-
Install via pip:
pip install mezzanine-announcements
-
Add to
"announcements"
toINSTALLED_APPS
. -
Run migrations.
-
Add
"announcements.context_processors.announcements"
to your context processors. -
Define the list of announcement templates that will be available for your admin users. This is a tuple of two-value tuples defined in
settings.ANNOUNCEMENTS_TEMPLATES
where the first element is the path to the Django template to be used, and the second element is the friendly name displayed in the admin for said template. For example:ANNOUNCEMENTS_TEMPLATES = ( ("announcements/modal.html", "Modal"), ("announcements/top_bar.html", "Top bar"), )
You need to create this templates yourself. An example is provided below.
-
Add some announcements in the new "Announcements" section in the admin.
Then to display the announcements in your templates:
-
Add the cookies and announcement scripts to the templates where you want to use the announcements
<script src="{% static 'js/js.cookie.js' %}"></script> <script src="{% static 'js/announcements.js' %}"></script>
-
Include the template with all announcements in a
{% nevercache %}
block:{% nevercache %} {% include "announcements/announcements.html" %} {% endnevercache %}
Templates
You can use any markup and styling you want in the announcement templates
defined in settings.ANNOUNCEMENTS_TEMPLATES
. You could use a Bootstrap modal,
or simple horizontal bar on the top of your page. The only conditions that you
need to keep in mind are the following:
- The template must contain a single element of the class
announcement
. - The announcement ID, delay, and expiration must be present as data attributes
on the
.announcement
element. - If the announcement is dismissable, you must include a clickable element with
the class
close-announcement
as a child of.announcement
.
{% load mezzanine_tags %}
<div
class="announcement"
data-appearance-delay="{{ announcement.appearance_delay }}"
data-announcement-id="{{ announcement.id }}"
data-expire-days="{{ announcement.expire_days }}"
>
{{ announcement.content|richtext_filters|safe }}
{% if announcement.can_dismiss %}
<button class="close-announcement">Close</button>
{% endif %}
</div>
Settings
Name | Default value | Description |
---|---|---|
ANNOUNCEMENTS_TEMPLATES | None | List of templates available for announcements. See Templates section above |
ANNOUNCEMENTS_EXTRA_FIELDS | None | List of additional fields to display in the announcement admin: ["extra_content", "video_link", "form"] |
Contributing
Review contribution guidelines at CONTRIBUTING.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mezzanine-announcements-3.3.0.tar.gz
.
File metadata
- Download URL: mezzanine-announcements-3.3.0.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a8d6f7f7b6d320f712584962af4cdfebf636a77da4b159be30444cac6bacd7f |
|
MD5 | fce095348a41cbefa9b49b9fe7dd951d |
|
BLAKE2b-256 | be83b4950181a3059701a05d46121f02cf343e906646df89d5408e40954b1f7f |
File details
Details for the file mezzanine_announcements-3.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: mezzanine_announcements-3.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6d467a2de841cc82db18fdcd3fd054fbb50288372325d2d923be1c12e023c18 |
|
MD5 | 205fc4b180e97f2e28f5bed542c6526a |
|
BLAKE2b-256 | f1624999069a7acd944823254a9c132928b47d9a3ff5f5af1aa5a48eacc2b996 |