minor fixes and downgrading requests (#535)
This commit is contained in:
parent
727bc87ede
commit
bfc80f982c
|
@ -149,16 +149,16 @@ def get_by_name(authority_name):
|
|||
return database.get(Authority, authority_name, field='name')
|
||||
|
||||
|
||||
def get_authority_role(ca_name, creator):
|
||||
def get_authority_role(ca_name, creator=None):
|
||||
"""
|
||||
Attempts to get the authority role for a given ca uses current_user
|
||||
as a basis for accomplishing that.
|
||||
|
||||
:param ca_name:
|
||||
"""
|
||||
if creator:
|
||||
if creator.is_admin:
|
||||
return role_service.get_by_name("{0}_admin".format(ca_name))
|
||||
else:
|
||||
return role_service.get_by_name("{0}_operator".format(ca_name))
|
||||
|
||||
|
||||
|
|
|
@ -118,11 +118,16 @@ def unwrap_pagination(data, output_schema):
|
|||
if isinstance(data, dict):
|
||||
if data.get('total') == 0:
|
||||
return data
|
||||
else:
|
||||
|
||||
marshaled_data = {'total': data['total']}
|
||||
marshaled_data['items'] = output_schema.dump(data['items'], many=True).data
|
||||
return marshaled_data
|
||||
else:
|
||||
|
||||
elif isinstance(data, list):
|
||||
marshaled_data = {'total': len(data)}
|
||||
marshaled_data['items'] = output_schema.dump(data, many=True).data
|
||||
return marshaled_data
|
||||
|
||||
return output_schema.dump(data).data
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue