Skip to main content

No project description provided

Project description

django-one-time-notices

Displays a modal with notice content if a user hasn't seen it yet.

Install

pip install django-one-time-notices

Settings

Add to INSTALLED_APPS:

django.contrib.auth
django.contrib.admin
...
notices

Add to TEMPLATES['OPTIONS']:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                ...
                'django.core.context_processors.request'
                ...
                'notices.context_processors.notices',
            ]
        }
    }
]

Static assets

Add notices/css/notices.css and notices/js/notices.js to your markup.

Usage

In templates, load the tags:

{% load notices_tags %}

and add the modal:

{% NoticesModal %} 

The modal will be shown. Once it has been dismissed it won't be shown again unless the notice version changes (see below) or the notice_seen cookie is deleted.

Setting/updating the notice

via models and django admin

Add a Notice instance in the django admin.

Notices have title, content, version and optional expires_at fields.

Version can be any positive number; it defaults to incrementing the last version number. Set the expires_at datetime to avoid showing this notice after the specified date, even if the user has never seen/dismissed it.

To show a new notice, add another Notice instance with an incremented version number.

via django settings

Override the Notice model by adding to your settings.py: NOTICES_VERSION # an integer NOTICES_TITLE # optional, default = "New!" NOTICES_CONTENT # optional, default = ""

Set NOTICES_VERSION = 0 to clear the cookie and disable showing notices at all.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_one_time_notices-0.1.0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

django_one_time_notices-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file django_one_time_notices-0.1.0.tar.gz.

File metadata

  • Download URL: django_one_time_notices-0.1.0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.9.13 Linux/5.14.0-1051-oem

File hashes

Hashes for django_one_time_notices-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0e3cf40cb29fcc6f9501fb9b7684f5ddbf6c1244d3e4c434d9faa94dc751e789
MD5 de4b0cf74d8ea195d7d9e56547080051
BLAKE2b-256 d73104c5fcac576a07887070bdde094cb2fd5b9318d65d317804fec93a125b35

See more details on using hashes here.

File details

Details for the file django_one_time_notices-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_one_time_notices-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e6555940e644c9bf9cb4a9c20e2339909c6c9d255a12502939f826fbdda525fd
MD5 6705076e28851fe8119e8908a73bf46f
BLAKE2b-256 d3d3e07e188377a922977148e5fb636ceea4f54637b2bac3a1a218b3574269dd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page