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_TEMPLATESwhere 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
.announcementelement. - If the announcement is dismissable, you must include a clickable element with
the class
close-announcementas 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.
Metadata
Release files for mezzanine-announcements 3.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mezzanine-announcements-3.3.0.tar.gz | 16.1 kB | Without provenance | Details for mezzanine-announcements-3.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mezzanine_announcements-3.3.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for mezzanine_announcements-3.3.0-py2.py3-none-any.whl |
Total release size: 34.2 kB
Release files / mezzanine-announcements-3.3.0.tar.gz
| Download URL | mezzanine-announcements-3.3.0.tar.gz |
|---|---|
| Size | 16.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a8d6f7f7b6d320f712584962af4cdfebf636a77da4b159be30444cac6bacd7f
|
|
BLAKE2b-256 checksum How to use checksums |
be83b4950181a3059701a05d46121f02cf343e906646df89d5408e40954b1f7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / mezzanine_announcements-3.3.0-py2.py3-none-any.whl
| Download URL | mezzanine_announcements-3.3.0-py2.py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c6d467a2de841cc82db18fdcd3fd054fbb50288372325d2d923be1c12e023c18
|
|
BLAKE2b-256 checksum How to use checksums |
f1624999069a7acd944823254a9c132928b47d9a3ff5f5af1aa5a48eacc2b996
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for mezzanine-announcements 3.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.