def post_save(self, sender, document, **kwargs): """ Post save hook handler Emits timeline entry through the realtime service """ from core.models import VosaeUser from timeline.api.resources import TimelineEntryResource ter = TimelineEntryResource() perms = [] if document.access_permission: perms.append(document.access_permission) if document.see_permission: perms.append(document.see_permission) for user_id in VosaeUser.objects.filter( tenant=document.tenant, permissions__acquired__all=perms).values_list('id'): try: resource_type = ter._get_type_from_class( ter._meta.polymorphic, document.__class__) except: resource_type = None emit_to_channel(u'private-user-{0}'.format(unicode(user_id)), u'new-timeline-entry', { u'id': unicode(document.id), u'type': resource_type })
def post_save(self, sender, document, created, **kwargs): """ Post save hook handler Triggers a "statistics-update" message through the realtime service """ from core.models import VosaeUser if document.USED_BY: for user_id in VosaeUser.objects.filter(tenant=document.tenant, status='ACTIVE').values_list('id'): emit_to_channel(u'private-user-{0}'.format(unicode(user_id)), u'statistics-update', { u'statistics': document.USED_BY })
def post_save(self, sender, document, created, **kwargs): """ Post save hook handler Triggers a "statistics-update" message through the realtime service """ from core.models import VosaeUser if document.USED_BY: for user_id in VosaeUser.objects.filter( tenant=document.tenant, status='ACTIVE').values_list('id'): emit_to_channel(u'private-user-{0}'.format(unicode(user_id)), u'statistics-update', {u'statistics': document.USED_BY})
def post_save(self, sender, document, **kwargs): """ Post save hook handler Emits notification through the realtime service """ from notification.api.resources import NotificationResource nr = NotificationResource() try: resource_type = nr._get_type_from_class(nr._meta.polymorphic, document.__class__) except: resource_type = None emit_to_channel(u'private-user-{0}'.format(unicode(document.recipient.id)), u'new-notification', { u'id': unicode(document.id), u'type': resource_type })
def post_save(self, sender, document, **kwargs): """ Post save hook handler Emits notification through the realtime service """ from notification.api.resources import NotificationResource nr = NotificationResource() try: resource_type = nr._get_type_from_class(nr._meta.polymorphic, document.__class__) except: resource_type = None emit_to_channel( u'private-user-{0}'.format(unicode(document.recipient.id)), u'new-notification', { u'id': unicode(document.id), u'type': resource_type })
def post_save(self, sender, document, **kwargs): """ Post save hook handler Emits timeline entry through the realtime service """ from core.models import VosaeUser from timeline.api.resources import TimelineEntryResource ter = TimelineEntryResource() perms = [] if document.access_permission: perms.append(document.access_permission) if document.see_permission: perms.append(document.see_permission) for user_id in VosaeUser.objects.filter(tenant=document.tenant, permissions__acquired__all=perms).values_list('id'): try: resource_type = ter._get_type_from_class(ter._meta.polymorphic, document.__class__) except: resource_type = None emit_to_channel(u'private-user-{0}'.format(unicode(user_id)), u'new-timeline-entry', { u'id': unicode(document.id), u'type': resource_type })