def _announce_task(event, event_status): task_id = event['uuid'] user_id, owner_id, dc_id = user_owner_dc_ids_from_task_id(task_id) if owner_id == internal_id: return # probably beat task if event.get('queue', None) == 'mgmt': return # sent task on mgmt if event.get('direct', None): # Send signal to ObjectOwner only users = (int(owner_id), ) else: # Send signal to all affected users users = User.get_super_admin_ids() # SuperAdmins users.update(User.get_dc_admin_ids(dc_id=dc_id)) # DcAdmins users.add(int(user_id)) # TaskCreator users.add(int(owner_id)) # ObjectOwner debug('Sending signal for %s task %s to %s', event_status, task_id, users) # Signal! for i in users: new_task = signal('task-for-%s' % i) new_task.send(event, task_id=task_id, event_status=event_status)
def _announce_task(event, event_status): task_id = event['uuid'] user_id, owner_id, dc_id = user_owner_dc_ids_from_task_id(task_id) if owner_id == internal_id: return # probably beat task if event.get('queue', None) == 'mgmt': return # sent task on mgmt if event.get('direct', None): # Send signal to ObjectOwner only users = (int(owner_id),) elif event.get('broadcast', None): # Send signal to all active socket.io sessions from sio.namespaces import ACTIVE_USERS users = set(session[0] for session in itervalues(ACTIVE_USERS)) else: # Send signal to all affected users users = User.get_super_admin_ids() # SuperAdmins users.update(User.get_dc_admin_ids(dc_id=dc_id)) # DcAdmins users.add(int(user_id)) # TaskCreator users.add(int(owner_id)) # ObjectOwner debug('Sending signal for %s task %s to %s', event_status, task_id, users) # Signal! for i in users: new_task = signal('task-for-%s' % i) new_task.send(event, task_id=task_id, event_status=event_status)
def get_owners(request, dc=None, all=False, order_by=('username', )): """ Return QuerySet of all active users. WARNING: Use with care! """ dc = dc or request.dc qs = User.objects.exclude(id=settings.SYSTEM_USER).filter( is_active=True).order_by(*order_by).distinct() if all or dc.access == dc.PUBLIC: # Public DC is available for all active users return qs # Private DC is available to only staff, DC owner and DC admins ... admins = User.get_super_admin_ids() admins.update(User.get_dc_admin_ids(dc)) # ... and users who have access to DC: return qs.filter(Q(id__in=admins) | Q(roles__in=dc.roles.all()))
def _announce_task(event, event_status): task_id = event['uuid'] task_prefix = task_prefix_from_task_id(task_id) if task_prefix[2] == internal_id: # owner_id return # probably beat task if event.get('queue', None) == 'mgmt': return # sent task on mgmt users = User.get_super_admin_ids() # SuperAdmins users.update(User.get_dc_admin_ids(dc_id=task_prefix[4])) # DcAdmins users.add(int(task_prefix[0])) # TaskCreator users.add(int(task_prefix[2])) # ObjectOwner debug('Sending signal for %s task %s to %s', event_status, task_id, users) # Signal! for i in users: new_task = signal('task-for-%s' % i) new_task.send(event, task_id=task_id, event_status=event_status)