Example #1
0
def network_choice_widget(node: colander.SchemaNode, kw: dict):
    request = kw["request"]
    dbsession = request.dbsession
    query = dbsession.query(AssetNetwork)
    vocab = convert_query_to_tuples(
        query,
        first_column=lambda o: uuid_to_slug(o.id),
        second_column=lambda o: o.human_friendly_name)
    return deform.widget.SelectWidget(values=vocab)
Example #2
0
def network_choice_widget(node: colander.SchemaNode, kw: dict):
    request = kw["request"]
    dbsession = request.dbsession
    query = dbsession.query(AssetNetwork)
    vocab = convert_query_to_tuples(
        query,
        first_column=lambda o: uuid_to_slug(o.id),
        second_column=lambda o: o.human_friendly_name)
    return deform.widget.SelectWidget(values=vocab)
Example #3
0
def group_vocabulary(node, kw):
    """Convert all groups on the site to (uuid, name) tuples for checkbox and select widgets."""

    Group = defer_group_class(node, kw)
    request = kw["request"]

    def first_column_getter(group: Group):
        return uuid_to_slug(group.uuid)

    return convert_query_to_tuples(request.dbsession.query(Group).all(), first_column=first_column_getter, second_column="name")
Example #4
0
def group_vocabulary(node, kw):
    """Convert all groups on the site to (uuid, name) tuples for checkbox and select widgets."""

    Group = defer_group_class(node, kw)
    request = kw["request"]

    def first_column_getter(group: Group):
        return uuid_to_slug(group.uuid)

    return convert_query_to_tuples(request.dbsession.query(Group).all(),
                                   first_column=first_column_getter,
                                   second_column="name")
Example #5
0
def group_vocabulary(node: c.SchemaNode, kw: dict) -> t.List[t.Tuple[str, str]]:
    """Convert all groups on the site to (uuid, name) tuples for checkbox and select widgets.

    :param node: Colander SchemaNode
    :param kw: Keyword arguments.
    :return: List of tuples with uuid, name for all groups on the site.
    """
    Group = defer_group_class(node, kw)
    request = kw["request"]

    def first_column_getter(group: Group):
        return uuid_to_slug(group.uuid)

    return convert_query_to_tuples(request.dbsession.query(Group).all(), first_column=first_column_getter, second_column="name")