def update_locations(): from hubspace.utilities.object import create_object from hubspace.openTimes import create_default_open_times, add_accessPolicy2Proxy from hubspace.model import Location, Group for location in Location.select(): cal = create_object('Resource', type='calendar', time_based=1, active=0, place=location.id, name='calendar', description='calendar') location.calendar = cal.id for level in ['member', 'host', 'director']: group = Group.select(AND(Group.q.level == level, Group.q.placeID == location.id))[0] access_policy = add_accessPolicy2Proxy(cal, group.id, 'Group', 5, None, None) create_default_open_times(access_policy)
def all_hosts(): """all hosts in the system """ users = [] for location in Location.select(): groups = Group.select(AND(Group.q.placeID==location.id, Group.q.level=="host")) for group in groups: for user in group.users: if user not in users: users.append(user) users.sort(display_name) return users