def _process(self): query = LocalGroup.query.options(joinedload(LocalGroup.members)).order_by(db.func.lower(LocalGroup.name)) groups = [g.proxy for g in query] providers = [p for p in multipass.identity_providers.itervalues() if p.supports_groups] form = SearchForm(obj=FormDefaults(exact=True)) if not providers: del form.provider else: form.provider.choices = [("", _("All")), ("indico", _("Local Groups"))] + [ (p.name, p.title) for p in sorted(providers, key=attrgetter("title")) ] search_results = None if form.validate_on_submit(): search_providers = None if not providers or not form.provider.data else {form.provider.data} search_results = GroupProxy.search(form.name.data, exact=form.exact.data, providers=search_providers) search_results.sort(key=attrgetter("provider", "name")) provider_titles = {p.name: p.title for p in multipass.identity_providers.itervalues()} provider_titles[None] = _("Local") return WPGroupsAdmin.render_template( "groups.html", groups=groups, providers=providers, form=form, search_results=search_results, provider_titles=provider_titles, )
def _process(self): query = LocalGroup.query.options(joinedload(LocalGroup.members)).order_by(db.func.lower(LocalGroup.name)) groups = [g.proxy for g in query] providers = [p for p in multipass.identity_providers.itervalues() if p.supports_groups] form = SearchForm(obj=FormDefaults(exact=True)) groups_enabled = True if not providers and not config.LOCAL_GROUPS: groups_enabled = False elif not providers: del form.provider else: choices = [('', _('All'))] if config.LOCAL_GROUPS: choices.append(('indico', _('Local Groups'))) choices += [(p.name, p.title) for p in sorted(providers, key=attrgetter('title'))] form.provider.choices = choices search_results = None if groups_enabled and form.validate_on_submit(): search_providers = None if not providers or not form.provider.data else {form.provider.data} search_results = GroupProxy.search(form.name.data, exact=form.exact.data, providers=search_providers) search_results.sort(key=attrgetter('provider', 'name')) provider_titles = {p.name: p.title for p in multipass.identity_providers.itervalues()} provider_titles[None] = _('Local') return WPGroupsAdmin.render_template('groups.html', groups=groups, providers=providers, form=form, search_results=search_results, provider_titles=provider_titles, groups_enabled=groups_enabled)
def _process(self): query = LocalGroup.query.options(joinedload(LocalGroup.members)).order_by(db.func.lower(LocalGroup.name)) groups = [GroupProxy(g.id, _group=g) for g in query] providers = [p for p in multipass.identity_providers.itervalues() if p.supports_groups] form = SearchForm(obj=FormDefaults(exact=True)) if not providers: del form.provider else: form.provider.choices = ([('', _('All')), ('indico', _('Local Groups'))] + [(p.name, p.title) for p in sorted(providers, key=attrgetter('title'))]) search_results = None if form.validate_on_submit(): search_providers = None if not providers or not form.provider.data else {form.provider.data} search_results = GroupProxy.search(form.name.data, exact=form.exact.data, providers=search_providers) search_results.sort(key=attrgetter('provider', 'name')) provider_titles = {p.name: p.title for p in multipass.auth_providers.itervalues()} provider_titles[None] = _('Local') return WPGroupsAdmin.render_template('groups.html', groups=groups, providers=providers, form=form, search_results=search_results, provider_titles=provider_titles)