Example #1
0
 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,
     )
Example #2
0
 def _process(self):
     existing_group = self.group if not self.new_group else None
     form = EditGroupForm(obj=existing_group, group=existing_group)
     if form.validate_on_submit():
         form.populate_obj(self.group)
         if self.new_group:
             db.session.add(self.group)
             msg = _("The group '{name}' has been created.")
         else:
             msg = _("The group '{name}' has been updated.")
         db.session.flush()
         flash(msg.format(name=self.group.name), "success")
         return redirect(url_for(".groups"))
     return WPGroupsAdmin.render_template("group_edit.html", group=existing_group, form=form)
Example #3
0
 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)
Example #4
0
 def _process(self):
     group = self.group
     provider_title = multipass.identity_providers[group.provider].title if not group.is_local else _("Local")
     return WPGroupsAdmin.render_template("group_details.html", group=group, provider_title=provider_title)
Example #5
0
 def _process(self):
     group = self.group
     provider_title = multipass.auth_providers[group.provider].title if not group.is_local else _('Local')
     return WPGroupsAdmin.render_template('group_details.html', group=group, provider_title=provider_title)