diff --git a/.gitignore b/.gitignore index 21e9974..90b342c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ MANIFEST .coverage htmlcov /.idea/ +*.egg-info diff --git a/.travis.yml b/.travis.yml index c28c526..b8bcff3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,27 @@ language: python python: - - "2.6" - "2.7" - "3.3" - "3.4" + - "3.5" env: - - DJANGO=1.6 - DJANGO=1.7 - DJANGO=1.8 + - DJANGO=1.9 install: # command to install dependencies - "pip install coveralls" - "pip install pytz" # Needed for tests - - pip install -q Django==$DJANGO --use-mirrors + - pip install -q Django==$DJANGO - "pip install ." # command to run tests script: - coverage run --branch --source=notifications manage.py test matrix: exclude: - - python: "2.6" + - python: "3.5" env: DJANGO=1.7 - - python: "2.6" - env: DJANGO=1.8 + - python: "3.3" + env: DJANGO=1.9 after_success: - coveralls diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b6bf4c3..564e165 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,8 +1,38 @@ Changelog -========== +========= + +1.0 +----- + +The first major version that requires Django 1.7+. + +- Drop support for Django 1.6 and below (@zhang-z) +- Django 1.9 compability (@illing2005) +- Now depends on Django built-in migration facility, "south_migrations" dependence was removed (@zhang-z) +- Make django-notification compatible with django-model-utils >= 2.4 ( #87, #88, #90 ) (@zhang-z) +- Fix a RemovedInDjango110Warning in unittest (@zhang-z) +- Fix pep8 & use setuptools (@areski) +- Fix typo- in doc (@areski, @zhang-z) +- Add app_name in urls.py (@zhang-z) +- Use Django's vendored copy of six (@funkybob) +- Tidy with flake8 (@funkybob) +- Remove custom now() function (@funkybob, @yangyubo) +- notify.send() accepts User or Group (@Evidlo) + +0.8.0 +----- + +0.8 is the last major version supports Django 1.4~1.6, version 0.8.0 will go into bugfix mode, no new features will be accepted. + +- Bugfixes for live-updater, and added a live tester page (@LegoStormtroopr) +- Class-based classes (@alazaro) +- Fixed urls in tests (@alazaro) +- Added app_label to Notification model in order to fix a Django 1.9 deprecation warning (@Heldroe) +- django-model-utils compatible issue (must >=2.0.3 and <2.4) (@zhang-z) +- Reliable setup.py versioning (@yangyubo) 0.7.1 ------- +----- - Able to pass level when adding notification (@Arthur) - Fix deprecation notice in Django 1.8 (@ashokfernandez) @@ -12,7 +42,7 @@ Changelog - Add missing migration for Notification model (@shezadkhan137) 0.7.0 ------- +----- - Add filters and displays to Django model Admin - Support Django 1.8, compatible with both django-south (django < 1.7) and built-in schema migration (django >= 1.7) @@ -20,14 +50,14 @@ Changelog - Test fixtures, and integrated with travis-ci 0.6.2 ------- +----- - Fix README.rst reStructuredText syntax format - Use relative imports - Add contributors to AUTHORS.txt 0.6.1 ------- +----- - Add support for custom user model - mark_as_unread @@ -35,13 +65,13 @@ Changelog - Use different `now` function according to the `USE_TZ` setting 0.6.0 ------- +----- - Improve documentation - Add unicode support at admin panel or shell 0.5.5 ------- +----- Support for arbitrary data attribute. @@ -51,7 +81,7 @@ Support for arbitrary data attribute. Fix package descriptions and doc links. 0.5 ------ +--- First version based on `django-activity-stream `_ v0.4.3 diff --git a/README.rst b/README.rst index 0f0769e..0c6c1b2 100644 --- a/README.rst +++ b/README.rst @@ -1,6 +1,7 @@ ``django-notifications`` Documentation ======================================= + |build-status| |coveralls| `django-notifications `_ is a GitHub notification alike app for Django, it was derived from `django-activity-stream `_ @@ -24,6 +25,12 @@ For example: `justquick `_ ``(actor)`` *closed* ` Nomenclature of this specification is based on the Activity Streams Spec: ``_ +Requirements +============ + +- Python 2.7, 3.3, 3.4, 3.5 +- Django 1.7, 1.8, 1.9 + Installation ============ @@ -58,34 +65,15 @@ Add the notifications urls to your urlconf:: import notifications - urlpatterns = patterns('', + urlpatterns = [ ... - url('^inbox/notifications/', include(notifications.urls)), + url('^inbox/notifications/', include(notifications.urls, namespace='notifications')), ... - ) + ] The method of installing these urls, importing rather than using ``'notifications.urls'``, is required to ensure that the urls are installed in the ``notifications`` namespace. - -How to migrate schema -========================================= - -For Django 1.4~1.6 ------------------- - -`django-south` support is shipped with `django-notifications`. - -#. Install latest version (>=1.0) `django-south `_ -#. Execute ``manage.py migrate notifications`` to migrate `django-notifications` schema - -Note: If you use a `custom user model `_ in your application, you may want to check `reverse dependencies `_ of South to run your migrations in the correct order. - -For Django 1.7 --------------- - -Django 1.7 has built-in support for migrations. No need to install `django-south`. - -#. Execute ``manage.py migrate notifications`` +To run schema migration, execute ``python manage.py migrate notifications``. Generating Notifications ========================= @@ -95,7 +83,7 @@ Generating notifications is probably best done in a separate signal. :: from django.db.models.signals import post_save - from notifications import notify + from notifications.signals import notify from myapp.models import MyModel def my_handler(sender, instance, created, **kwargs): @@ -107,11 +95,12 @@ To generate an notification anywhere in your code, simply import the notify sign :: - from notifications import notify + from notifications.signals import notify notify.send(user, recipient=user, verb='you reached level 10') - notify.send(comment.user, recipient=user, verb=u'replied', action_object=comment, + // "recipient" can also be a Group, the notification will be sent to all the Users in the Group + notify.send(comment.user, recipient=group, verb=u'replied', action_object=comment, description=comment.comment, target=comment.content_object) notify.send(follow_instance.user, recipient=follow_instance.follow_object, verb=u'has followed you', @@ -245,7 +234,7 @@ Storing the count in a variable for further processing is advised, such as:: Live-updater API ================ -To ensure users always have the most up-to-date notfications, `django-notifications` includes a simple javascript API +To ensure users always have the most up-to-date notifications, `django-notifications` includes a simple javascript API for updating specific fields within a django template. There are two possible API calls that can be made: diff --git a/manage.py b/manage.py index af81138..ff94b6d 100755 --- a/manage.py +++ b/manage.py @@ -7,4 +7,4 @@ if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "notifications.tests.settings") from django.core.management import execute_from_command_line - execute_from_command_line(sys.argv) \ No newline at end of file + execute_from_command_line(sys.argv) diff --git a/notifications/__init__.py b/notifications/__init__.py index 0631da7..5a713a6 100644 --- a/notifications/__init__.py +++ b/notifications/__init__.py @@ -1,32 +1,13 @@ -try: - from notifications.signals import notify -except ImportError: - pass +# -*- coding: utf-8 -*- +""" + django-notifications + ~~~~~ + A GitHub notification alike app for Django. + :copyright: (c) 2015 by django-notifications team. + :license: BSD, see LICENSE.txt for more details. +""" -try: - from notifications.urls import urlpatterns - 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() +# PEP 386-compliant version number: N.N[.N]+[{a|b|c|rc}N[.N]+][.postN][.devN] +__version__ = '1.0' +default_app_config = 'notifications.apps.Config' diff --git a/notifications/admin.py b/notifications/admin.py index a2cc972..cefc9f2 100644 --- a/notifications/admin.py +++ b/notifications/admin.py @@ -3,6 +3,7 @@ from django.contrib import admin from .models import Notification + class NotificationAdmin(admin.ModelAdmin): list_display = ('recipient', 'actor', 'level', 'target', 'unread', 'public') diff --git a/notifications/apps.py b/notifications/apps.py new file mode 100644 index 0000000..f7e6f6c --- /dev/null +++ b/notifications/apps.py @@ -0,0 +1,11 @@ +from django.apps import AppConfig + + +class Config(AppConfig): + name = "notifications" + + def ready(self): + super(Config, self).ready() + # this is for backwards compability + import notifications.signals + notifications.notify = notifications.signals.notify diff --git a/notifications/migrations/0004_auto_20150826_1508.py b/notifications/migrations/0004_auto_20150826_1508.py index eb493c3..a109dc1 100644 --- a/notifications/migrations/0004_auto_20150826_1508.py +++ b/notifications/migrations/0004_auto_20150826_1508.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from django.db import models, migrations -import notifications.models +from django.utils import timezone class Migration(migrations.Migration): @@ -15,6 +15,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='notification', name='timestamp', - field=models.DateTimeField(default=notifications.models.now), + field=models.DateTimeField(default=timezone.now), ), ] diff --git a/notifications/models.py b/notifications/models.py index 181d750..52f0ad1 100644 --- a/notifications/models.py +++ b/notifications/models.py @@ -1,8 +1,8 @@ -import datetime from django.conf import settings from django.contrib.contenttypes.models import ContentType - from django import get_version +from django.utils import timezone + from distutils.version import StrictVersion if StrictVersion(get_version()) >= StrictVersion('1.8.0'): @@ -12,30 +12,20 @@ else: from django.db import models from django.core.exceptions import ImproperlyConfigured -from six import text_type +from django.utils.six import text_type from .utils import id2slug from .signals import notify -from model_utils import managers, Choices +from model_utils import Choices from jsonfield.fields import JSONField - -def now(): - # Needs to be be a function as USE_TZ can change based on if we are testing or not. - _now = datetime.datetime.now - if getattr(settings, 'USE_TZ'): - try: - from django.utils import timezone - _now = timezone.now - except ImportError: - pass - return _now() +from django.contrib.auth.models import Group -#SOFT_DELETE = getattr(settings, 'NOTIFICATIONS_SOFT_DELETE', False) +# SOFT_DELETE = getattr(settings, 'NOTIFICATIONS_SOFT_DELETE', False) def is_soft_delete(): - #TODO: SOFT_DELETE = getattr(settings, ...) doesn't work with "override_settings" decorator in unittest + # TODO: SOFT_DELETE = getattr(settings, ...) doesn't work with "override_settings" decorator in unittest # But is_soft_delete is neither a very elegant way. Should try to find better approach return getattr(settings, 'NOTIFICATIONS_SOFT_DELETE', False) @@ -170,27 +160,23 @@ class Notification(models.Model): verb = models.CharField(max_length=255) description = models.TextField(blank=True, null=True) - target_content_type = models.ForeignKey(ContentType, related_name='notify_target', - blank=True, null=True) + target_content_type = models.ForeignKey(ContentType, related_name='notify_target', blank=True, null=True) target_object_id = models.CharField(max_length=255, blank=True, null=True) - target = GenericForeignKey('target_content_type', - 'target_object_id') + target = GenericForeignKey('target_content_type', 'target_object_id') - action_object_content_type = models.ForeignKey(ContentType, - related_name='notify_action_object', blank=True, null=True) - action_object_object_id = models.CharField(max_length=255, blank=True, - null=True) - action_object = GenericForeignKey('action_object_content_type', - 'action_object_object_id') + action_object_content_type = models.ForeignKey(ContentType, blank=True, null=True, + related_name='notify_action_object') + action_object_object_id = models.CharField(max_length=255, blank=True, null=True) + action_object = GenericForeignKey('action_object_content_type', 'action_object_object_id') - timestamp = models.DateTimeField(default=now) + timestamp = models.DateTimeField(default=timezone.now) public = models.BooleanField(default=True) deleted = models.BooleanField(default=False) emailed = models.BooleanField(default=False) data = JSONField(blank=True, null=True) - objects = managers.PassThroughManager.for_queryset_class(NotificationQuerySet)() + objects = NotificationQuerySet.as_manager() class Meta: ordering = ('-timestamp', ) @@ -212,7 +198,7 @@ class Notification(models.Model): return u'%(actor)s %(verb)s %(action_object)s %(timesince)s ago' % ctx return u'%(actor)s %(verb)s %(timesince)s ago' % ctx - def __str__(self):#Adds support for Python 3 + def __str__(self): # Adds support for Python 3 return self.__unicode__() def timesince(self, now=None): @@ -249,31 +235,48 @@ def notify_handler(verb, **kwargs): Handler function to create Notification instance upon action signal call. """ + # Pull the options out of kwargs kwargs.pop('signal', None) recipient = kwargs.pop('recipient') actor = kwargs.pop('sender') - newnotify = Notification( - recipient = recipient, - actor_content_type=ContentType.objects.get_for_model(actor), - actor_object_id=actor.pk, - verb=text_type(verb), - public=bool(kwargs.pop('public', True)), - description=kwargs.pop('description', None), - timestamp=kwargs.pop('timestamp', now()), - level=kwargs.pop('level', Notification.LEVELS.info), - ) + optional_objs = [ + (kwargs.pop(opt, None), opt) + for opt in ('target', 'action_object') + ] + public = bool(kwargs.pop('public', True)) + description = kwargs.pop('description', None) + timestamp = kwargs.pop('timestamp', timezone.now()) + level = kwargs.pop('level', Notification.LEVELS.info) - for opt in ('target', 'action_object'): - obj = kwargs.pop(opt, None) - if not obj is None: - setattr(newnotify, '%s_object_id' % opt, obj.pk) - setattr(newnotify, '%s_content_type' % opt, - ContentType.objects.get_for_model(obj)) + # Check if User or Group + if isinstance(recipient, Group): + recipients = recipient.user_set.all() + else: + recipients = [recipient] - if len(kwargs) and EXTRA_DATA: - newnotify.data = kwargs + for recipient in recipients: + newnotify = Notification( + recipient=recipient, + actor_content_type=ContentType.objects.get_for_model(actor), + actor_object_id=actor.pk, + verb=text_type(verb), + public=public, + description=description, + timestamp=timestamp, + level=level, + ) - newnotify.save() + # Set optional objects + for obj, opt in optional_objs: + if obj is not None: + setattr(newnotify, '%s_object_id' % opt, obj.pk) + setattr(newnotify, '%s_content_type' % opt, + ContentType.objects.get_for_model(obj)) + + if len(kwargs) and EXTRA_DATA: + newnotify.data = kwargs + + newnotify.save() # connect the signal diff --git a/notifications/south_migrations/0001_initial.py b/notifications/south_migrations/0001_initial.py deleted file mode 100644 index b7ede3d..0000000 --- a/notifications/south_migrations/0001_initial.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - -try: - from django.contrib.auth import get_user_model -except ImportError: # django < 1.5 - from django.contrib.auth.models import User -else: - User = get_user_model() - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding model 'Notification' - db.create_table('notifications_notification', ( - ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), - ('recipient', self.gf('django.db.models.fields.related.ForeignKey')(related_name='notifications', to=User)), - ('readed', self.gf('django.db.models.fields.BooleanField')(default=False)), - ('actor_content_type', self.gf('django.db.models.fields.related.ForeignKey')(related_name='notify_actor', to=orm['contenttypes.ContentType'])), - ('actor_object_id', self.gf('django.db.models.fields.CharField')(max_length=255)), - ('verb', self.gf('django.db.models.fields.CharField')(max_length=255)), - ('description', self.gf('django.db.models.fields.TextField')(null=True, blank=True)), - ('target_content_type', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='notify_target', null=True, to=orm['contenttypes.ContentType'])), - ('target_object_id', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), - ('action_object_content_type', self.gf('django.db.models.fields.related.ForeignKey')(blank=True, related_name='notify_action_object', null=True, to=orm['contenttypes.ContentType'])), - ('action_object_object_id', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True)), - ('timestamp', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime.now)), - ('public', self.gf('django.db.models.fields.BooleanField')(default=True)), - )) - db.send_create_signal('notifications', ['Notification']) - - - def backwards(self, orm): - # Deleting model 'Notification' - db.delete_table('notifications_notification') - - - models = { - 'auth.group': { - 'Meta': {'object_name': 'Group'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - 'auth.permission': { - 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'auth.user': { - 'Meta': {'object_name': 'User'}, - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'notifications.notification': { - 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'Notification'}, - 'action_object_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_action_object'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'action_object_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'actor_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notify_actor'", 'to': "orm['contenttypes.ContentType']"}), - 'actor_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'readed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'recipient': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notifications'", 'to': "orm['auth.User']"}), - 'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_target'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'target_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'verb': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['notifications'] diff --git a/notifications/south_migrations/0002_auto__add_field_notification_data.py b/notifications/south_migrations/0002_auto__add_field_notification_data.py deleted file mode 100644 index c8925d3..0000000 --- a/notifications/south_migrations/0002_auto__add_field_notification_data.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Notification.data' - db.add_column('notifications_notification', 'data', - self.gf('django.db.models.fields.TextField')(null=True, blank=True), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'Notification.data' - db.delete_column('notifications_notification', 'data') - - - models = { - 'auth.group': { - 'Meta': {'object_name': 'Group'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - 'auth.permission': { - 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'auth.user': { - 'Meta': {'object_name': 'User'}, - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'notifications.notification': { - 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'Notification'}, - 'action_object_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_action_object'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'action_object_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'actor_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notify_actor'", 'to': "orm['contenttypes.ContentType']"}), - 'actor_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'data': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'readed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'recipient': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notifications'", 'to': "orm['auth.User']"}), - 'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_target'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'target_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'verb': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['notifications'] \ No newline at end of file diff --git a/notifications/south_migrations/0003_auto__add_field_notification_unread.py b/notifications/south_migrations/0003_auto__add_field_notification_unread.py deleted file mode 100644 index 6063a6a..0000000 --- a/notifications/south_migrations/0003_auto__add_field_notification_unread.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Notification.unread' - db.add_column('notifications_notification', 'unread', - self.gf('django.db.models.fields.BooleanField')(default=True), - keep_default=True) - - - def backwards(self, orm): - # Deleting field 'Notification.unread' - db.delete_column('notifications_notification', 'unread') - - - models = { - 'auth.group': { - 'Meta': {'object_name': 'Group'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - 'auth.permission': { - 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'auth.user': { - 'Meta': {'object_name': 'User'}, - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'notifications.notification': { - 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'Notification'}, - 'action_object_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_action_object'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'action_object_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'actor_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notify_actor'", 'to': "orm['contenttypes.ContentType']"}), - 'actor_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'data': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'readed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'recipient': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notifications'", 'to': "orm['auth.User']"}), - 'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_target'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'target_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'unread': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'verb': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['notifications'] \ No newline at end of file diff --git a/notifications/south_migrations/0004_convert_readed_to_unread.py b/notifications/south_migrations/0004_convert_readed_to_unread.py deleted file mode 100644 index 90194b4..0000000 --- a/notifications/south_migrations/0004_convert_readed_to_unread.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import DataMigration -from django.db import models - -class Migration(DataMigration): - - def forwards(self, orm): - "" - orm['notifications.Notification'].objects.filter(readed=True).update(unread=False) - orm['notifications.Notification'].objects.filter(readed=False).update(unread=True) - - def backwards(self, orm): - "Write your backwards methods here." - orm['notifications.Notification'].objects.filter(unread=True).update(readed=False) - orm['notifications.Notification'].objects.filter(unread=False).update(readed=True) - - models = { - 'auth.group': { - 'Meta': {'object_name': 'Group'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - 'auth.permission': { - 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'auth.user': { - 'Meta': {'object_name': 'User'}, - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'notifications.notification': { - 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'Notification'}, - 'action_object_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_action_object'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'action_object_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'actor_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notify_actor'", 'to': "orm['contenttypes.ContentType']"}), - 'actor_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'data': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'readed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'recipient': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notifications'", 'to': "orm['auth.User']"}), - 'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_target'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'target_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'unread': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'verb': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['notifications'] - symmetrical = True diff --git a/notifications/south_migrations/0005_auto__del_field_notification_readed.py b/notifications/south_migrations/0005_auto__del_field_notification_readed.py deleted file mode 100644 index 5b9f3bc..0000000 --- a/notifications/south_migrations/0005_auto__del_field_notification_readed.py +++ /dev/null @@ -1,78 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Deleting field 'Notification.readed' - db.delete_column('notifications_notification', 'readed') - - - def backwards(self, orm): - # Adding field 'Notification.readed' - db.add_column('notifications_notification', 'readed', - self.gf('django.db.models.fields.BooleanField')(default=False), - keep_default=True) - - - models = { - 'auth.group': { - 'Meta': {'object_name': 'Group'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - 'auth.permission': { - 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'auth.user': { - 'Meta': {'object_name': 'User'}, - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'notifications.notification': { - 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'Notification'}, - 'action_object_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_action_object'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'action_object_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'actor_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notify_actor'", 'to': "orm['contenttypes.ContentType']"}), - 'actor_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'data': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'recipient': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notifications'", 'to': "orm['auth.User']"}), - 'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_target'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'target_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'unread': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'verb': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['notifications'] \ No newline at end of file diff --git a/notifications/south_migrations/0006_auto__add_field_notification_level.py b/notifications/south_migrations/0006_auto__add_field_notification_level.py deleted file mode 100644 index 596a5c2..0000000 --- a/notifications/south_migrations/0006_auto__add_field_notification_level.py +++ /dev/null @@ -1,79 +0,0 @@ -# -*- coding: utf-8 -*- -import datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Notification.level' - db.add_column('notifications_notification', 'level', - self.gf('django.db.models.fields.CharField')(default='info', max_length=20), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'Notification.level' - db.delete_column('notifications_notification', 'level') - - - models = { - 'auth.group': { - 'Meta': {'object_name': 'Group'}, - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - 'auth.permission': { - 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - 'auth.user': { - 'Meta': {'object_name': 'User'}, - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - 'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - 'notifications.notification': { - 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'Notification'}, - 'action_object_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_action_object'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'action_object_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'actor_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notify_actor'", 'to': "orm['contenttypes.ContentType']"}), - 'actor_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'data': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'level': ('django.db.models.fields.CharField', [], {'default': "'info'", 'max_length': '20'}), - 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'recipient': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notifications'", 'to': "orm['auth.User']"}), - 'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_target'", 'null': 'True', 'to': "orm['contenttypes.ContentType']"}), - 'target_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'unread': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'verb': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['notifications'] \ No newline at end of file diff --git a/notifications/south_migrations/0007_auto__del_field_notification_data__add_field_notification_deleted__add.py b/notifications/south_migrations/0007_auto__del_field_notification_data__add_field_notification_deleted__add.py deleted file mode 100644 index 072407e..0000000 --- a/notifications/south_migrations/0007_auto__del_field_notification_data__add_field_notification_deleted__add.py +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Deleting field 'Notification.data' - db.delete_column(u'notifications_notification', 'data') - - # Adding field 'Notification.deleted' - db.add_column(u'notifications_notification', 'deleted', - self.gf('django.db.models.fields.BooleanField')(default=False), - keep_default=False) - - # Adding field 'Notification.emailed' - db.add_column(u'notifications_notification', 'emailed', - self.gf('django.db.models.fields.BooleanField')(default=False), - keep_default=False) - - - def backwards(self, orm): - # Adding field 'Notification.data' - db.add_column(u'notifications_notification', 'data', - self.gf('django.db.models.fields.TextField')(null=True, blank=True), - keep_default=False) - - # Deleting field 'Notification.deleted' - db.delete_column(u'notifications_notification', 'deleted') - - # Deleting field 'Notification.emailed' - db.delete_column(u'notifications_notification', 'emailed') - - - models = { - u'auth.group': { - 'Meta': {'object_name': 'Group'}, - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - u'auth.permission': { - 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - u'auth.user': { - 'Meta': {'object_name': 'User'}, - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - u'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - u'notifications.notification': { - 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'Notification'}, - 'action_object_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_action_object'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}), - 'action_object_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'actor_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notify_actor'", 'to': u"orm['contenttypes.ContentType']"}), - 'actor_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'emailed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'level': ('django.db.models.fields.CharField', [], {'default': "'info'", 'max_length': '20'}), - 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'recipient': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notifications'", 'to': u"orm['auth.User']"}), - 'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_target'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}), - 'target_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'unread': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'verb': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['notifications'] \ No newline at end of file diff --git a/notifications/south_migrations/0008_auto__add_field_notification_data.py b/notifications/south_migrations/0008_auto__add_field_notification_data.py deleted file mode 100644 index e8496d5..0000000 --- a/notifications/south_migrations/0008_auto__add_field_notification_data.py +++ /dev/null @@ -1,81 +0,0 @@ -# -*- coding: utf-8 -*- -from south.utils import datetime_utils as datetime -from south.db import db -from south.v2 import SchemaMigration -from django.db import models - - -class Migration(SchemaMigration): - - def forwards(self, orm): - # Adding field 'Notification.data' - db.add_column(u'notifications_notification', 'data', - self.gf('jsonfield.fields.JSONField')(null=True, blank=True), - keep_default=False) - - - def backwards(self, orm): - # Deleting field 'Notification.data' - db.delete_column(u'notifications_notification', 'data') - - - models = { - u'auth.group': { - 'Meta': {'object_name': 'Group'}, - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), - 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) - }, - u'auth.permission': { - 'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'}, - 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) - }, - u'auth.user': { - 'Meta': {'object_name': 'User'}, - 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), - 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), - 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), - 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}), - 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) - }, - u'contenttypes.contenttype': { - 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, - 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), - 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) - }, - u'notifications.notification': { - 'Meta': {'ordering': "('-timestamp',)", 'object_name': 'Notification'}, - 'action_object_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_action_object'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}), - 'action_object_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'actor_content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notify_actor'", 'to': u"orm['contenttypes.ContentType']"}), - 'actor_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}), - 'data': ('jsonfield.fields.JSONField', [], {'null': 'True', 'blank': 'True'}), - 'deleted': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - 'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), - 'emailed': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), - u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'level': ('django.db.models.fields.CharField', [], {'default': "'info'", 'max_length': '20'}), - 'public': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'recipient': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'notifications'", 'to': u"orm['auth.User']"}), - 'target_content_type': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'notify_target'", 'null': 'True', 'to': u"orm['contenttypes.ContentType']"}), - 'target_object_id': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), - 'timestamp': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), - 'unread': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), - 'verb': ('django.db.models.fields.CharField', [], {'max_length': '255'}) - } - } - - complete_apps = ['notifications'] \ No newline at end of file diff --git a/notifications/south_migrations/__init__.py b/notifications/south_migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/notifications/templatetags/notifications_tags.py b/notifications/templatetags/notifications_tags.py index 054bfd0..5bd0999 100644 --- a/notifications/templatetags/notifications_tags.py +++ b/notifications/templatetags/notifications_tags.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- from django.core.urlresolvers import reverse from django.template import Library -from django.template.base import TemplateSyntaxError -from django.template import Node register = Library() + @register.assignment_tag(takes_context=True) def notifications_unread(context): user = user_context(context) @@ -13,34 +12,40 @@ def notifications_unread(context): return '' return user.notifications.unread().count() + # Requires vanilla-js framework - http://vanilla-js.com/ @register.simple_tag -def register_notify_callbacks(badge_id='live_notify_badge',menu_id='live_notify_list',refresh_period=15,callbacks="",api_name='list',fetch=5): - refresh_period=int(refresh_period)*1000 +def register_notify_callbacks(badge_id='live_notify_badge', + menu_id='live_notify_list', + refresh_period=15, + callbacks='', + api_name='list', + fetch=5): + refresh_period = int(refresh_period)*1000 - if api_name=='list': + if api_name == 'list': api_url = reverse('notifications:live_unread_notification_list') - elif api_name=='count': + elif api_name == 'count': api_url = reverse('notifications:live_unread_notification_count') else: return "" - - definitions=""" + definitions = """ notify_badge_id='{badge_id}'; notify_menu_id='{menu_id}'; notify_api_url='{api_url}'; notify_fetch_count='{fetch_count}'; notify_unread_url='{unread_url}'; notify_mark_all_unread_url='{mark_all_unread_url}'; - notify_refresh_period={refresh};""".format( - badge_id=badge_id, - menu_id=menu_id, - refresh=refresh_period, - api_url=api_url, - unread_url=reverse('notifications:unread'), - mark_all_unread_url=reverse('notifications:mark_all_as_read'), - fetch_count=fetch - ) + notify_refresh_period={refresh}; + """.format( + badge_id=badge_id, + menu_id=menu_id, + refresh=refresh_period, + api_url=api_url, + unread_url=reverse('notifications:unread'), + mark_all_unread_url=reverse('notifications:mark_all_as_read'), + fetch_count=fetch + ) script = "