subscribe author to comment for his post if watchlist is enabled
authorAlexander Solovyov <piranha@piranha.org.ua>
Thu Oct 16 22:33:49 2008 +0300 (8 days ago)
changeset 10523552cd0d34cd
parent 105118b16def9ae7
child 105334586edd6d5f
child 105499f39a118795
subscribe author to comment for his post if watchlist is enabled
apps/blog/models.py
       1 --- a/apps/blog/models.py	Thu Oct 16 11:07:50 2008 +0300
       2 +++ b/apps/blog/models.py	Thu Oct 16 22:33:49 2008 +0300
       3 @@ -102,7 +102,6 @@
       4  
       5  xmlrpc.dispatcher.register_function(create_ping_func(**ping_details), 'pingback.ping')
       6  
       7 -
       8  if settings.ENABLE_PINGBACK:
       9      ping_links = ping_external_links(content_attr='html', url_attr='get_absolute_url',
      10                                       filtr=lambda x: not x.is_draft)
      11 @@ -111,3 +110,11 @@
      12      ping_dirs = ping_directories(content_attr='html', url_attr='get_absolute_url',
      13                                   filtr=lambda x: not x.is_draft)
      14      models.signals.post_save.connect(ping_dirs, sender=Post)
      15 +
      16 +if 'watchlist' in settings.INSTALLED_APPS:
      17 +    from watchlist.models import Subscription
      18 +    def subscribe_author(instance, created, **kwargs):
      19 +        if not created:
      20 +            return
      21 +        Subscription.objects.subscribe(instance.author, instance)
      22 +    models.signals.post_save.connect(subscribe_author, sender=Post)