Add support for org-wide default permissions
This commit is contained in:
parent
e1e283698e
commit
3da5a77e33
4 changed files with 56 additions and 13 deletions
|
@ -559,7 +559,7 @@ def prototype_view(proto, org_members):
|
|||
}
|
||||
|
||||
return {
|
||||
'activating_user': prototype_user_view(proto.activating_user),
|
||||
'activating_user': prototype_user_view(proto.activating_user) if proto.activating_user else None,
|
||||
'delegate': delegate_view,
|
||||
'role': proto.role.name,
|
||||
'id': proto.uuid,
|
||||
|
@ -588,7 +588,7 @@ def log_prototype_action(action_kind, orgname, prototype, **kwargs):
|
|||
log_params = {
|
||||
'prototypeid': prototype.uuid,
|
||||
'username': username,
|
||||
'activating_username': prototype.activating_user.username,
|
||||
'activating_username': prototype.activating_user.username if prototype.activating_user else None,
|
||||
'role': prototype.role.name
|
||||
}
|
||||
|
||||
|
@ -614,7 +614,10 @@ def create_organization_prototype_permission(orgname):
|
|||
abort(404)
|
||||
|
||||
details = request.get_json()
|
||||
activating_username = details['activating_user']['name']
|
||||
activating_username = None
|
||||
|
||||
if 'activating_user' in details and details['activating_user'] and 'name' in details['activating_user']:
|
||||
activating_username = details['activating_user']['name']
|
||||
|
||||
delegate = details['delegate']
|
||||
delegate_kind = delegate['kind']
|
||||
|
@ -623,13 +626,14 @@ def create_organization_prototype_permission(orgname):
|
|||
delegate_username = delegate_name if delegate_kind == 'user' else None
|
||||
delegate_teamname = delegate_name if delegate_kind == 'team' else None
|
||||
|
||||
activating_user = model.get_user(activating_username)
|
||||
activating_user = (model.get_user(activating_username)
|
||||
if activating_username else None)
|
||||
delegate_user = (model.get_user(delegate_username)
|
||||
if delegate_username else None)
|
||||
delegate_team = (model.get_organization_team(orgname, delegate_teamname)
|
||||
if delegate_teamname else None)
|
||||
|
||||
if not activating_user:
|
||||
if activating_username and not activating_user:
|
||||
abort(404)
|
||||
|
||||
if not delegate_user and not delegate_team:
|
||||
|
|
Reference in a new issue