minor fixes and downgrading requests (#535)

This commit is contained in:
kevgliss 2016-11-28 16:50:26 -08:00 committed by GitHub
parent 727bc87ede
commit bfc80f982c
3 changed files with 17 additions and 12 deletions

View File

@ -149,17 +149,17 @@ def get_by_name(authority_name):
return database.get(Authority, authority_name, field='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 Attempts to get the authority role for a given ca uses current_user
as a basis for accomplishing that. as a basis for accomplishing that.
:param ca_name: :param ca_name:
""" """
if creator.is_admin: if creator:
return role_service.get_by_name("{0}_admin".format(ca_name)) if creator.is_admin:
else: return role_service.get_by_name("{0}_admin".format(ca_name))
return role_service.get_by_name("{0}_operator".format(ca_name)) return role_service.get_by_name("{0}_operator".format(ca_name))
def render(args): def render(args):

View File

@ -118,12 +118,17 @@ def unwrap_pagination(data, output_schema):
if isinstance(data, dict): if isinstance(data, dict):
if data.get('total') == 0: if data.get('total') == 0:
return data return data
else:
marshaled_data = {'total': data['total']} marshaled_data = {'total': data['total']}
marshaled_data['items'] = output_schema.dump(data['items'], many=True).data marshaled_data['items'] = output_schema.dump(data['items'], many=True).data
return marshaled_data return marshaled_data
else:
return output_schema.dump(data).data 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
def validate_schema(input_schema, output_schema): def validate_schema(input_schema, output_schema):

View File

@ -43,7 +43,7 @@ install_requires = [
'Flask-Principal==0.4.0', 'Flask-Principal==0.4.0',
'Flask-Mail==0.9.1', 'Flask-Mail==0.9.1',
'SQLAlchemy-Utils==0.32.9', 'SQLAlchemy-Utils==0.32.9',
'requests==2.12.1', 'requests==2.11.1',
'psycopg2==2.6.2', 'psycopg2==2.6.2',
'arrow==0.9.0', 'arrow==0.9.0',
'six==1.10.0', 'six==1.10.0',