Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
mezzanine-announcements
Advanced tools
A Mezzanine app to create and display site-wide announcements.
Install via pip: pip install mezzanine-announcements
Add to "announcements"
to INSTALLED_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 %}
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:
announcement
..announcement
element.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>
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"] |
Review contribution guidelines at CONTRIBUTING.md.
FAQs
Site-wide announcements for Mezzanine websites
We found that mezzanine-announcements demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.