def get_users(): current_user = get_current_user() result = [] customers = assigneesHandler.get_customers(current_user.get('username')) if authentication.has_full_access(current_user): # super user, master admin result = [_set_customers(u) for u in UserDao.get_all()] elif authentication.user_is_master(current_user): if authentication.user_is_assigned_master(current_user): # master user (assigned master customer) users = [_set_customers(u) for u in UserDao.get_all()] result = [u for u in users if authentication.allow_semi_user_changes(u)] else: # master user (not assigned master customer) for customer in customers: assigned_users = assigneesHandler.get_assignees(customer.get('customer')) users = [get_user(a['user']) for a in assigned_users] result = result + [u for u in users if authentication.allow_semi_user_changes(u)] else: # can only be assigned to one.. customer = customers[0] assigned_users = assigneesHandler.get_assignees(customer.get('customer')) users = [get_user(a['user']) for a in assigned_users] result = [u for u in users if u and authentication.allow_semi_user_changes(u)] return result
def get_user(username=None): current_user = get_current_user() if not username: return current_user else: user = UserDao.get_user(username) if user: user = _set_customers(user) if authentication.allow_semi_user_changes(user): return user
def update_user(user): if authentication.allow_full_user_changes(user): return full_update_user(user) if authentication.allow_semi_user_changes(user): return semi_update_user(user) return False