Beispiel #1
0
def _setup_tenants(sess):
    # Create tenant. Cascade also creates a resource and a group
    ten = tmgr.create_tenant(sess, SYSTEM_UID, name=DEFAULT_TENANT_NAME,
        title=DEFAULT_TENANT_TITLE, cascade=True)
    # Put all so far existing users into our group
    g = ten.load_my_group()
    uu = sess.query(User)
    for u in uu:
        create_group_member(sess, owner=SYSTEM_UID, group=g, member_user=u)
Beispiel #2
0
def add_user(sess, tenant, user, owner, **kwargs):
    """
    Adds a user to tenant's group.

    :param sess: A DB session instance.
    :param tenant: ID, ``name``, or instance of a tenant.
    :param user: ID, ``principal``, or instance of a user.
    :param owner: ID, ``principal``, or instance of a user.
    """
    ten = Tenant.find(sess, tenant)
    g_ten = ten.load_my_group()
    create_group_member(sess, owner, g_ten, member_user=user, **kwargs)
    sess.flush()
Beispiel #3
0
def setup_tenants(sess):
    # Create tenant. Cascade also creates a resource and a group
    tmgr.create_tenant(sess, SYSTEM_UID, name=DEFAULT_TENANT_NAME,
        title=DEFAULT_TENANT_TITLE, cascade=True)
    # Put all so far existing users into our group
    g = sess.query(Group).filter(sa.and_(
        Group.tenant_id == None,
        Group.name == DEFAULT_TENANT_NAME,
        Group.kind == GROUP_KIND_TENANT
    )).one()
    uu = sess.query(User)
    for u in uu:
        create_group_member(sess, owner=SYSTEM_UID, group=g, member_user=u)
Beispiel #4
0
def add_user(sess, tenant, user, owner, **kwargs):
    """
    Adds a user to tenant's group.

    :param sess: A DB session instance.
    :param tenant: ID, ``name``, or instance of a tenant.
    :param user: ID, ``principal``, or instance of a user.
    :param owner: ID, ``principal``, or instance of a user.
    """
    ten = Tenant.find(sess, tenant)
    g_ten = sess.query(Group).filter(
        Group.name == ten.name,
        Group.kind == GROUP_KIND_TENANT
    ).one()
    create_group_member(sess, owner, g_ten, member_user=user, **kwargs)
    sess.flush()
Beispiel #5
0
 def create_group_member(self):
     data = self._parse(self.args.data)
     data['owner'] = pym.auth.const.ROOT_UID
     rs = authmgr.create_group_member(data)
     self._print(self._db_data_to_list([rs])[0])
Beispiel #6
0
 def create_group_member(self):
     data = self._parse(self.args.data)
     data['owner'] = pym.auth.const.ROOT_UID
     rs = authmgr.create_group_member(data)
     self._print(self._db_data_to_list([rs])[0])