From bfc80f982ca8b5803454338bbf370df161b2e9b4 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Mon, 28 Nov 2016 16:50:26 -0800 Subject: [PATCH] minor fixes and downgrading requests (#535) --- lemur/authorities/service.py | 10 +++++----- lemur/common/schema.py | 17 +++++++++++------ setup.py | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lemur/authorities/service.py b/lemur/authorities/service.py index 1ca0e80f..5b312e11 100644 --- a/lemur/authorities/service.py +++ b/lemur/authorities/service.py @@ -149,17 +149,17 @@ 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.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)) + if creator: + if creator.is_admin: + return role_service.get_by_name("{0}_admin".format(ca_name)) + return role_service.get_by_name("{0}_operator".format(ca_name)) def render(args): diff --git a/lemur/common/schema.py b/lemur/common/schema.py index 759cda4e..332e8656 100644 --- a/lemur/common/schema.py +++ b/lemur/common/schema.py @@ -118,12 +118,17 @@ 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: - return output_schema.dump(data).data + + marshaled_data = {'total': data['total']} + marshaled_data['items'] = output_schema.dump(data['items'], many=True).data + return marshaled_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): diff --git a/setup.py b/setup.py index c20d07d6..c5a000e6 100644 --- a/setup.py +++ b/setup.py @@ -43,7 +43,7 @@ install_requires = [ 'Flask-Principal==0.4.0', 'Flask-Mail==0.9.1', 'SQLAlchemy-Utils==0.32.9', - 'requests==2.12.1', + 'requests==2.11.1', 'psycopg2==2.6.2', 'arrow==0.9.0', 'six==1.10.0',