def render(self): settings = self.request.registry.settings use_ldap = False if 'pyvac.use_ldap' in settings: use_ldap = asbool(settings.get('pyvac.use_ldap')) user_attr = {} users_teams = {} active_users = [] if use_ldap: # synchronise user groups/roles User.sync_ldap_info(self.session) ldap = LdapCache() user_attr = ldap.get_users_units() users_teams = {} for team, members in ldap.list_teams().iteritems(): for member in members: users_teams.setdefault(member, []).append(team) active_users = ldap.list_active_users() return { u'user_count': User.find(self.session, count=True), u'users': User.find(self.session, order_by=[User.dn]), 'use_ldap': use_ldap, 'ldap_info': user_attr, 'users_teams': users_teams, 'active_users': active_users, }
def render(self): # synchronise user groups/roles User.sync_ldap_info(self.session) ldap = LdapCache() users_entity = {} for chapter, members in ldap.list_chapters().iteritems(): for member in members: users_entity.setdefault(member, []).append(chapter) # keep only managed users for managers # use all users for admin overviews = {} if self.user.is_admin or self.user.has_feature( 'chapter_overview_full'): # noqa for _, target_chapter in self.chapter_leaders.items(): chapter_stats = self.get_chapter_stats(target_chapter, users_entity) # noqa overviews.update({target_chapter: chapter_stats}) elif self.user.is_manager: # retrieve logged chapter leader target_chapter = self.chapter_leaders[self.user.login] chapter_stats = self.get_chapter_stats(target_chapter, users_entity) # noqa overviews = {target_chapter: chapter_stats} else: return HTTPFound(location=route_url('home', self.request)) return {'users_entity': users_entity, 'overviews': overviews}
def render(self): from datetime import datetime today = datetime.now() end_date = datetime(today.year, 10, 31) previsions = Request.get_previsions(self.session, end_date) users_per_id = dict([(user.id, user) for user in User.find(self.session)]) settings = self.request.registry.settings use_ldap = False if 'pyvac.use_ldap' in settings: use_ldap = asbool(settings.get('pyvac.use_ldap')) user_attr = {} users_teams = {} if use_ldap: # synchronise user groups/roles User.sync_ldap_info(self.session) ldap = LdapCache() user_attr = ldap.get_users_units() users_teams = {} for team, members in ldap.list_teams().iteritems(): for member in members: users_teams.setdefault(member, []).append(team) return {'users_per_id': users_per_id, 'use_ldap': use_ldap, 'ldap_info': user_attr, 'users_teams': users_teams, 'previsions': previsions, 'today': today, 'end_date': end_date, }
def render(self): settings = self.request.registry.settings use_ldap = False if 'pyvac.use_ldap' in settings: use_ldap = asbool(settings.get('pyvac.use_ldap')) user_attr = {} users_teams = {} if use_ldap: # synchronise user groups/roles User.sync_ldap_info(self.session) ldap = LdapCache() user_attr = ldap.get_users_units() users_teams = {} for team, members in ldap.list_teams().iteritems(): for member in members: users_teams.setdefault(member, []).append(team) return {u'user_count': User.find(self.session, count=True), u'users': User.find(self.session, order_by=[User.dn]), 'use_ldap': use_ldap, 'ldap_info': user_attr, 'users_teams': users_teams, }
def render(self): from datetime import datetime today = datetime.now() end_date = datetime(today.year, 10, 31) previsions = Request.get_previsions(self.session, end_date) users_per_id = dict([(user.id, user) for user in User.find(self.session)]) settings = self.request.registry.settings use_ldap = False if 'pyvac.use_ldap' in settings: use_ldap = asbool(settings.get('pyvac.use_ldap')) user_attr = {} users_teams = {} if use_ldap: # synchronise user groups/roles User.sync_ldap_info(self.session) ldap = LdapCache() user_attr = ldap.get_users_units() users_teams = {} for team, members in list(ldap.list_teams().items()): for member in members: users_teams.setdefault(member, []).append(team) return {'users_per_id': users_per_id, 'use_ldap': use_ldap, 'ldap_info': user_attr, 'users_teams': users_teams, 'previsions': previsions, 'today': today, 'end_date': end_date, }
def render(self): # synchronise user groups/roles User.sync_ldap_info(self.session) ldap = LdapCache() users_entity = {} for team, members in list(ldap.list_teams().items()): for member in members: users_entity.setdefault(member, []).append(team) # keep only managed users for managers # use all users for admin overviews = {} if self.user.is_admin or self.user.has_feature('squad_overview_full'): for _, target_squad in list(self.squad_leaders.items()): squad_stats = self.get_squad_stats(target_squad, users_entity) overviews.update({target_squad: squad_stats}) elif self.user.is_manager: # retrieve logged squad leader target_squad = self.squad_leaders[self.user.login] squad_stats = self.get_squad_stats(target_squad, users_entity) overviews = {target_squad: squad_stats} else: return HTTPFound(location=route_url('home', self.request)) return {'users_entity': users_entity, 'overviews': overviews}
def render(self): settings = self.request.registry.settings use_ldap = False if 'pyvac.use_ldap' in settings: use_ldap = asbool(settings.get('pyvac.use_ldap')) user_attr = {} if use_ldap: # synchronise user groups/roles User.sync_ldap_info(self.session) ldap = LdapCache() user_attr = ldap.get_users_units() return {u'user_count': User.find(self.session, count=True), u'users': User.find(self.session, order_by=[User.dn]), 'use_ldap': use_ldap, 'ldap_info': user_attr, }