From ff38f063d0f997c869e42c0a730f9eb2a6f16ecf Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 22 Jul 2016 18:44:54 -0400 Subject: [PATCH] update noftifications needed a new way to populate the noticetype table because of signal deprecation --- context_processors.py | 3 ++- core/__init__.py | 1 + core/apps.py | 11 +++++++++++ core/signals.py | 4 ++-- requirements_versioned.pip | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 core/apps.py diff --git a/context_processors.py b/context_processors.py index 4907c1e6..02db6a84 100644 --- a/context_processors.py +++ b/context_processors.py @@ -3,9 +3,10 @@ def is_preview(request): return {'jquery_home': settings.JQUERY_HOME, 'jquery_ui_home': settings.JQUERY_UI_HOME, 'is_preview': settings.IS_PREVIEW, 'show_google_analytics': settings.SHOW_GOOGLE_ANALYTICS} def count_unseen(request): - from notification.models import Notice, NoticeManager + if request.user.is_anonymous(): count = 0 else: + from notification.models import Notice count = Notice.objects.unseen_count_for(request.user) return {'unseen_count': count} \ No newline at end of file diff --git a/core/__init__.py b/core/__init__.py index e69de29b..833e95ff 100755 --- a/core/__init__.py +++ b/core/__init__.py @@ -0,0 +1 @@ +default_app_config = 'regluit.core.apps.CoreConfig' \ No newline at end of file diff --git a/core/apps.py b/core/apps.py new file mode 100644 index 00000000..b2f19b32 --- /dev/null +++ b/core/apps.py @@ -0,0 +1,11 @@ +from django.apps import AppConfig +from django.db.models.signals import post_migrate + +from regluit.core.signals import create_notice_types + +class CoreConfig(AppConfig): + name = 'regluit.core' + verbose_name = 'regluit core' + + def ready(self): + post_migrate.connect(create_notice_types, sender=self) \ No newline at end of file diff --git a/core/signals.py b/core/signals.py index 64735e0a..282acaca 100644 --- a/core/signals.py +++ b/core/signals.py @@ -61,7 +61,7 @@ post_save.connect(create_api_key, sender=User) # create notification types (using django-notification) -- tie to syncdb -def create_notice_types(app, created_models, verbosity, **kwargs): +def create_notice_types( **kwargs): notification.create_notice_type("comment_on_commented", _("Comment on Commented Work"), _("A comment has been received on a book that you've commented on.")) notification.create_notice_type("wishlist_comment", _("Book List Comment"), _("A comment has been received on one of your books."), default = 1) notification.create_notice_type("wishlist_official_comment", _("Book List Comment"), _("The author or publisher, or and Unglue.it staffer, has commented on one of your faves.")) @@ -101,7 +101,7 @@ signals.post_syncdb.connect(create_notice_types, sender=notification) # define the notifications and tie them to corresponding signals -from django.contrib.comments.signals import comment_was_posted +from django_comments.signals import comment_was_posted def notify_comment(comment, request, **kwargs): logger.info('comment %s notifying' % comment.pk) diff --git a/requirements_versioned.pip b/requirements_versioned.pip index 22460c23..bcb9a9eb 100644 --- a/requirements_versioned.pip +++ b/requirements_versioned.pip @@ -35,7 +35,7 @@ django-maintenancemode==0.10 django-mptt==0.7.4 django-nose-selenium==0.7.3 #django-notification==0.2 -git+git://github.com/eshellman/django-notification.git@8bb7afbbb07e8cad74bc1cf17e0ac6fc117c0497 +git+git://github.com/eshellman/django-notification.git@412c7a03a327195a1017c2be92c8e2caabc880b6 django-registration==2.1.1 django-selectable==0.9.0 django-smtp-ssl==1.0