diff --git a/README.rst b/README.rst
index 756b67e..7922c16 100644
--- a/README.rst
+++ b/README.rst
@@ -250,11 +250,11 @@ for updating specific fields within a django template.
There are two possible API calls that can be made:
- 1. ``api/unread_count/`` that returns a javascript object with 1 key: ``unread_count`` eg::
+ 1. ``api/unread_count/`` that returns a javascript object with 1 key: ``unread_count`` eg::
{"unread_count":1}
- #. ``api/unread_list/`` that returns a javascript object with 2 keys: `unread_count` and `unread_list` eg::
+ #. ``api/unread_list/`` that returns a javascript object with 2 keys: `unread_count` and `unread_list` eg::
{
"unread_count":1,
@@ -267,8 +267,8 @@ There are two possible API calls that can be made:
How to use:
-----------
- 1. Put ``{% load notifications_tags %}`` in the template before you actually use notification tags.
- 2. In the area where you are loading javascript resources add the following tags in the order below::
+ 1. Put ``{% load notifications_tags %}`` in the template before you actually use notification tags.
+ 2. In the area where you are loading javascript resources add the following tags in the order below::
{% register_notify_callbacks callbacks='fill_notification_list,fill_notification_badge' %}
@@ -278,26 +278,27 @@ How to use:
1. ``badge_id`` (default ``live_notify_badge``) - The `id` attribute of the element to show the unread count, that will be periodically updated.
#. ``menu_id`` (default ``live_notify_list``) - The `id` attribute of the element to insert a list of unread items, that will be periodically updated.
#. ``refresh_period`` (default ``15``) - How often to fetch unread items from the server (integer in seconds).
+ #. ``to_fetch`` (default ``5``) - How many notifications to fetch each time.
#. ``callbacks`` (default ````) - A comma-separated list of javascript functions to call each period.
#. ``api_url_name`` (default ``list``) - The name of the API to call (this can be either ``list`` or ``count``).
- 3. To insert a live-updating unread count, use the following template::
+ 3. To insert a live-updating unread count, use the following template::
{% live_notify_badge %}
``live_notify_badge`` takes the following arguments:
- 1. ``badge_id`` (default ``live_notify_badge``) - The ``id`` attribute for the ```` element that will be created to show the unread count.
- #. ``classes`` (default ````) - A string used to populate the ``class`` attribute of the above element.
+ 1. ``badge_id`` (default ``live_notify_badge``) - The ``id`` attribute for the ```` element that will be created to show the unread count.
+ #. ``classes`` (default ````) - A string used to populate the ``class`` attribute of the above element.
- 4. To insert a live-updating unread count, use the following template::
+ 4. To insert a live-updating unread count, use the following template::
{% live_notify_list %}
-
+
``live_notify_list`` takes the following arguments:
- 1. ``list_id`` (default ``live_notify_list``) - The ``id`` attribute for the ``
`` element that will be created to insert the list of notifications into.
- #. ``classes`` (default ````) - A string used to populate the ``class`` attribute of the above element.
+ 1. ``list_id`` (default ``live_notify_list``) - The ``id`` attribute for the ``
`` element that will be created to insert the list of notifications into.
+ #. ``classes`` (default ````) - A string used to populate the ``class`` attribute of the above element.
Using the live-updater with bootstrap
-------------------------------------
@@ -319,7 +320,7 @@ While the live notifier for unread counts should suit most use cases, users may
unread notifications are shown.
The ``callbacks`` argument of the ``register_notify_callbacks`` dictates which javascript functions are called when
-the unread api call is made.
+the unread api call is made.
To add a custom javascript callback, simply add this to the list, like so::
@@ -337,6 +338,15 @@ For example, the below function would get the recent list of unread messages and
}
}
+Testing the live-updater
+------------------------
+
+1. Clone the repo
+2. Set the 'NOTIFICATION_TEST' environemnt variable. E.g. `export NOTIFICATION_TEST=1`
+3. Run `./manage.py runserver`
+4. Browse to `yourserverip/test/`
+5. Click 'Make a notification' and a new notification should appear in the list in 5-10 seconds.
+
``django-notifications`` Team
==============================
diff --git a/manage.py b/manage.py
index 367aa92..af81138 100755
--- a/manage.py
+++ b/manage.py
@@ -3,7 +3,7 @@ import os
import sys
if __name__ == "__main__":
- if 'test' in sys.argv:
+ if 'test' in sys.argv or 'NOTIFICATION_TEST' in os.environ.keys():
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "notifications.tests.settings")
from django.core.management import execute_from_command_line
diff --git a/notifications/__init__.py b/notifications/__init__.py
index c73842c..0631da7 100644
--- a/notifications/__init__.py
+++ b/notifications/__init__.py
@@ -8,3 +8,25 @@ try:
urls = (urlpatterns, 'notifications', 'notifications')
except ImportError:
pass
+
+__version_info__ = {
+ 'major': 0,
+ 'minor': 8,
+ 'micro': 0,
+ 'releaselevel': 'final',
+ 'serial': 0
+}
+
+
+def get_version(release_level=True):
+ """
+ Return the formatted version information
+ """
+ vers = ["%(major)i.%(minor)i.%(micro)i" % __version_info__]
+ if release_level and __version_info__['releaselevel'] != 'final':
+ vers.append('%(releaselevel)s%(serial)i' % __version_info__)
+ return ''.join(vers)
+
+
+__version__ = get_version()
+
diff --git a/notifications/static/notifications/notify.js b/notifications/static/notifications/notify.js
index 6ec2796..a660f01 100644
--- a/notifications/static/notifications/notify.js
+++ b/notifications/static/notifications/notify.js
@@ -1,6 +1,7 @@
var notify_badge_id;
var notify_menu_id;
var notify_api_url;
+var notify_fetch_count;
var notify_unread_url;
var notify_mark_all_unread_url;
var notify_refresh_period = 15000;
@@ -20,21 +21,21 @@ function fill_notification_list(data) {
menu.innerHTML = "";
for (var i=0; i < data.unread_list.length; i++) {
var item = data.unread_list[i];
- menu.innerHTML = menu.innerHTML + "