Beispiel #1
0
def notify_message(sender, instance, **kwargs):
    from curia.notifications.models import Notification
    try:
        Notification.objects.get(user=instance.receiver, object_id=instance.sender.id, content_type=get_content_type(instance))
    except Notification.DoesNotExist:
        new_notification = Notification(user=instance.receiver, object_id=instance.sender.id, content_type=get_content_type(instance), title=u'%s: %s' % (smart_unicode(instance.sender), smart_unicode(instance.message[:17])), url=instance.get_absolute_url())
        new_notification.save()
Beispiel #2
0
def notify_user(user, instance, **kwargs):
    from curia.notifications.models import Notification, Watcher
    content_type = get_content_type(instance)
    
    from curia.authentication import has_perm    
    if has_perm(user, instance, 'view'):
        # handle negations on this specific object (this is redundant if this function was called for a specific notification on this object)
        if Watcher.objects.filter(user=user, content_type=content_type, object_id=instance.pk, inverse=True).count() != 0:
            return
    
        # handle negations on this content type for this user/group
        if Watcher.objects.filter(user=user, content_type=content_type, object_id__isnull=True, inverse=True).count() != 0:
            return
        
        owner_user = None
        owner_group = None
        if hasattr(instance, 'owner'):
            owner_user = instance.owner
        if hasattr(instance, 'owner_user'):
            owner_user = instance.owner_user
        if hasattr(instance, 'owner_group'):
            owner_group = instance.owner_group
            
        try:
            new_notification = Notification(user=user, object_id=instance.pk, content_type=content_type, title=unicode(instance), url=instance.get_absolute_url(), originator_user=get_current_user(), originator_group=get_current_community())
            new_notification.save()
            
            if user.notification_style == 'E': # notify on every event
                            send_notification_mail(user, new_notification)
        except:
            pass
Beispiel #3
0
def notify_message(sender, instance, **kwargs):
    from curia.notifications.models import Notification
    try:
        Notification.objects.get(user=instance.receiver,
                                 object_id=instance.sender.id,
                                 content_type=get_content_type(instance))
    except Notification.DoesNotExist:
        new_notification = Notification(
            user=instance.receiver,
            object_id=instance.sender.id,
            content_type=get_content_type(instance),
            title=u'%s: %s' % (smart_unicode(
                instance.sender), smart_unicode(instance.message[:17])),
            url=instance.get_absolute_url())
        new_notification.save()