Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

djnotty

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djnotty

Create popup notifications.

  • 0.0.5
  • PyPI
  • Socket score

Maintainers
1

Demo https://djnotty.herokuapp.com/

Demo admin https://djnotty.herokuapp.com/admin Cred: guest password

Installation

Put ``djnotty`` to ``settings.py`` Put
``url(r'^djnotty/', include('djnotty.urls', namespace='djnotty')),``
to ``urls.py``

Override default admin/base_site.html or copy this code to custom admin template {% load static %} {% block extrahead %}

.. raw:: html

       <script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
       <script src="{% static 'djnotty/js/packaged/jquery.noty.packaged.min.js' %}"></script>
       <script src="{% static 'djnotty/js/notty.js' %}"></script>
       

{{ block.super }} {% endblock %}

If you want use djnotty on non admin pages:

::

<script>
    var djnotty_url = '{% url 'djnotty:messages' %}';
    var csrf_token = '{{ csrf_token }}'; // for unauthorized users
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="{% static 'djnotty/js/packaged/jquery.noty.packaged.min.js' %}"></script>
<script src="{% static 'djnotty/js/notty.js' %}"></script>

How to create messages

Create notification for user


::

    from djnotty import noty_builder
    from djnotty.models import Message
    from django.contrib.auth.models import Group

    Message.objects.create_for_object(%TARGET_OBJECT%, users=[%USER_OBJECT%], builders=[noty_builder.Text('Specific for user'),noty_builder.Close()])

Create notification for group and user

::

from djnotty import noty_builder
from djnotty.models import Message

Message.objects.create_for_object(%TARGET_OBJECT%, groups=[Group.objects.get(name='superadmin')],users=[%USER_OBJECT%], builders=[noty_builder.Text('Specific for user and group'),noty_builder.Close()])

Create globally message:


::

    from djnotty import noty_builder
    from djnotty.models import Message
    Message.objects.create_globally(builders=[noty_builder.Text('Specific for user and group'),noty_builder.Close()])

Mark as read
============

::

    from djnotty.models import Message
    Message.objects.create_globally(builders=[noty_builder.Text('Specific for user and group'),noty_builder.Close()])
    Message.objects.mark_as_viewed_for_object(%TARGET_OBJECT%,%USER_MODEL%)

noty\_builder
~~~~~~~~~~~~~

Text:
~~~~~

::

    Put text to popup window

Close:
~~~~~~

::

    Notification mark as read for user after click.

    Close(url='redect me after click')

Linked:
~~~~~~~

::

    Redirect to url after click on notification

What is %TARGET\_OBJECT%

Djnotty using django_content_types framework for identify records.

FAQs


Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc