Skip to main content

Django application allow to create site warnings, make subscription, and receive notifies.

Project description

django-site-warnings

Django application allow to create site warnings, make subscription, and receive notifies.

Install

pip install django-site-warnings

Usage

pro/views.py

from django_site_warnings.models import WaringCategory
from django_site_warnings.models import Warning

def background_sync_work(request):
    try:
        pass # do your own work
    except Exception as error:
        category = WaringCategory.get("warning category code")
        Warning.make(category, f"background_sync_work failed: {error}")

pro/settings

INSTALLED_APPS = [
    '...',
    'django_site_warnings',
    '...',
]

# work together with django-admin-global-sidebar
DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS = "pro.menus.site_menu"

DJANGO_SITE_WARNING_SITE_NAME = "Site Warning"

# sendmail_notify settings
DJANGO_SITE_WARNING_NOTIFY_MAIL_FROM = "sender@example.com"
DJANGO_SITE_WARNING_NOTIFY_MAIL_TO = ["receiver@example.com"]
DJANGO_SITE_WARNING_NOTIFY_MAIL_SERVER = "smtp.example.com"
DJANGO_SITE_WARNING_NOTIFY_MAIL_PORT = 465
DJANGO_SITE_WARNING_NOTIFY_MAIL_SSL = True
DJANGO_SITE_WARNING_NOTIFY_MAIL_USER = "sender@example.com"
DJANGO_SITE_WARNING_NOTIFY_MAIL_PASSWORD = "sender-password-MlPzC9kt"

# use `DJANGO_SITE_WARNING_NOTIFY_MAIL_CONFIG` to replace the configs above.
# `DJANGO_SITE_WARNING_NOTIFY_MAIL_CONFIG` can also be a string path of a function that returns server info
DJANGO_SITE_WARNING_NOTIFY_MAIL_CONFIG = {
    "from_address": "sender@example.com",
    "to_addresses": ["receiver@example.com"],
    "server": "smtp.example.com",
    "port": 465,
    "ssl": True,
    "user": "sender@example.com",
    "password": "sender-password-MlPzC9kt",
}

DJANGO_SITE_WARNING_NOTIFY_MAIL_CONFIG callback function should define as:

def get_notify_mail_config(warning, payload, force):
    return {
        "from_address": "sender@example.com",
        "to_addresses": ["receiver@example.com"],
        "server": "smtp.example.com",
        "port": 465,
        "ssl": True,
        "user": "sender@example.com",
        "password": "sender-password-MlPzC9kt",
    }

pro/menus.py

from django_site_warnings.global_sidebar import django_site_warnings_menu_item_of_applist

def site_menu(request=None):
    return [
        {
            "title": _("Home"),
            "icon": "fa fa-home",
            "url": "/admin/",
        },
        {
            "title": _("System Settings"),
            "icon": "fas fa-cogs",
            "children": [
                {
                    "title": _("User Manage"),
                    "icon": "fas fa-user",
                    "model": "auth.user",
                    "permissions": ["auth.view_user"],
                },
                {
                    "title": _("Group Manage"),
                    "icon": "fas fa-users",
                    "model": "auth.group",
                    "permissions": ["auth.view_group"],
                },
                django_site_warnings_menu_item_of_applist,
            ]
        }
    ]

Releases

v0.1.2

  • First release.

v0.1.4

  • Make title length longer.

v0.1.6

  • Test for Django 3.2.
  • Work with django-simpletask2.

v0.2.0

  • Add django_site_warnings.global_sidebar.django_site_warnings_menu_item_of_warning, django_site_warnings.global_sidebar.django_site_warnigns_menu_item_of_category and django_site_warnings.global_sidebar.django_site_warnings_menu_item_of_applist to work with django-admin-global-sidebar.
  • WaringCategory.get will auto create category instance if it is missing.
  • Register sendmail_notify to Warning by default.

v0.2.1

  • Show notify send result.

v0.2.2

  • Doc update.

v0.3.7

  • Add DJANGO_SITE_WARNING_NOTIFY_MAIL_CONFIG support.
  • No django-site-warning-server anymore.

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-site-warnings-0.3.7.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

django_site_warnings-0.3.7-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file django-site-warnings-0.3.7.tar.gz.

File metadata

  • Download URL: django-site-warnings-0.3.7.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0rc1

File hashes

Hashes for django-site-warnings-0.3.7.tar.gz
Algorithm Hash digest
SHA256 3eb2cb3af0fd493a169d328384af24fc536e85119e5d805f8e65f3a6b0186c75
MD5 df64abf7f2b4d110a374743f4403315c
BLAKE2b-256 e891cae8222c19d18f3647bdec54c0566ed4ba9550f9b49294e32095823ca39b

See more details on using hashes here.

File details

Details for the file django_site_warnings-0.3.7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_site_warnings-0.3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 0c4e78177ea9bae6493789c0d7d1a460c298d9b0db7e9ffc8df3112e6f2873b7
MD5 280b0daef449eb0b284690c235bf971e
BLAKE2b-256 3ab8d00d6d47141cd5074d674e72354f8ed6175880d265651419a15906b90204

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