def get_form(self, role=None): """Helper to create a GroupAddForm populated with all users and groups as options. Note that the first choice is blank so the first user alphabetically isn't always selected. Returns: GroupAddForm object. """ form = GroupAddForm(self.request.arguments) form.role.choices = [["member", "Member"]] if role in ("owner", "np-owner"): form.role.choices.append(["manager", "Manager"]) form.role.choices.append(["owner", "Owner"]) form.role.choices.append(["np-owner", "No-Permissions Owner"]) group_choices = [ (group.groupname, "Group: " + group.groupname) # (value, label) for group in get_all_groups(self.session) ] user_choices = [ (user.username, "User: "******"", "")] + sorted(group_choices + user_choices, key=operator.itemgetter(1)) return form
def get_form(self, role=None): """Helper to create a GroupAddForm populated with all users and groups as options. Note that the first choice is blank so the first user alphabetically isn't always selected. Returns: GroupAddForm object. """ form = GroupAddForm(self.request.arguments) form.role.choices = [["member", "Member"]] if role in ("owner", "np-owner"): form.role.choices.append(["manager", "Manager"]) form.role.choices.append(["owner", "Owner"]) form.role.choices.append(["np-owner", "No-Permissions Owner"]) group_choices = [ (group.groupname, "Group: " + group.groupname) # (value, label) for group in get_all_groups(self.session) ] user_choices = [ (user.username, "User: "******"", "")] + sorted( group_choices + user_choices, key=operator.itemgetter(1) ) return form
def get_form(self) -> ServiceAccountEnableForm: """Helper to create a ServiceAccountEnableForm populated with all groups. Note that the first choice is blank so the first user alphabetically isn't always selected. """ form = ServiceAccountEnableForm(self.request.arguments) group_choices = [ (group.groupname, "Group: " + group.groupname) # (value, label) for group in get_all_groups(self.session) ] form.owner.choices = [("", "")] + sorted(group_choices, key=operator.itemgetter(1)) return form
def get_form(self): """Helper to create a ServiceAccountEnableForm populated with all groups. Note that the first choice is blank so the first user alphabetically isn't always selected. Returns: ServiceAccountEnableForm object. """ form = ServiceAccountEnableForm(self.request.arguments) group_choices = [ (group.groupname, "Group: " + group.groupname) # (value, label) for group in get_all_groups(self.session) ] form.owner.choices = [("", "")] + sorted(group_choices, key=operator.itemgetter(1)) return form