Make profile endpoint not error out
This patch makes it so that the check for if a user is a foundation admin will not error out when a foundation org does not exist. Instead an empty list is returned, saying that there are no foundation users. The documentation was also updated to give instructions for creating the Foundation group/organization, and adding a user to it. Closes-Bug: #1552548 Change-Id: If675d856b69ab854a3daf296f81050525ba5d50b
This commit is contained in:
parent
6ae61c6a70
commit
207e7948d6
@ -196,3 +196,35 @@ Now available:
|
||||
|
||||
- `http://<your server IP>:8000/v1/results/<test run id>` with response JSON
|
||||
including the detail test results of the specified `<test run id>`
|
||||
|
||||
####(Optional) Configure Foundation organization and group
|
||||
|
||||
Overall RefStack admin access is given to users belonging to a "Foundation"
|
||||
organization. To become a Foundation admin, first a "Foundation" organization
|
||||
must be created. Note that you must have logged into RefStack at least once so
|
||||
that a user record for your account is created.
|
||||
|
||||
- Log into MySQL: `mysql -u root -p`
|
||||
|
||||
- Create a group for the "Foundation" organization:
|
||||
|
||||
`INSERT INTO refstack.group (id, name, created_at) VALUES (UUID(), 'Foundation Group', NOW());`
|
||||
|
||||
- Get the group ID for the group you just created:
|
||||
|
||||
`SELECT id from refstack.group WHERE name = 'Foundation Group';`
|
||||
|
||||
- Get your OpenID:
|
||||
|
||||
`SELECT openid from refstack.user WHERE email = '<your email>';`
|
||||
|
||||
- Add your user account to the previously created "Foundation" group. Replace
|
||||
`<Group ID>` and `<Your OpenID>` with the values retrieved in the two previous steps:
|
||||
|
||||
`INSERT INTO refstack.user_to_group (created_by_user, user_openid, group_id, created_at)
|
||||
VALUES ('<Your OpenID>', '<Your OpenID>', '<Group ID>', NOW());`
|
||||
|
||||
- Create the actual "Foundation" organization using this group:
|
||||
|
||||
`INSERT INTO refstack.organization (id, type, name, group_id, created_by_user, created_at)
|
||||
VALUES (UUID(), 0, 'Foundation', '<Group ID>', '<Your OpenID>', NOW());`
|
||||
|
@ -23,6 +23,7 @@ import uuid
|
||||
from oslo_config import cfg
|
||||
from oslo_db import options as db_options
|
||||
from oslo_db.sqlalchemy import session as db_session
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
from refstack.api import constants as api_const
|
||||
@ -32,6 +33,7 @@ from refstack.db.sqlalchemy import models
|
||||
CONF = cfg.CONF
|
||||
|
||||
_FACADE = None
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
db_options.set_defaults(cfg.CONF)
|
||||
|
||||
@ -490,7 +492,8 @@ def get_foundation_users():
|
||||
session.query(models.Organization.group_id)
|
||||
.filter_by(type=api_const.FOUNDATION).first())
|
||||
if organization is None:
|
||||
raise NotFound('Foundation record could not found in DB.')
|
||||
LOG.warning('Foundation organization record not found in DB.')
|
||||
return []
|
||||
group_id = organization.group_id
|
||||
users = (session.query(models.UserToGroup.user_openid).
|
||||
filter_by(group_id=group_id))
|
||||
|
Loading…
Reference in New Issue
Block a user