From b5b9604e637f45dc5ebe33c9d09775c576c8dac9 Mon Sep 17 00:00:00 2001 From: DJ Gillespie Date: Wed, 16 Sep 2020 14:35:37 -0600 Subject: [PATCH] Fixed plaid connection attaching to the wrong account --- connection/views.py | 3 +++ user/views.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/connection/views.py b/connection/views.py index 79fd885..4b62b89 100644 --- a/connection/views.py +++ b/connection/views.py @@ -33,6 +33,7 @@ class ConnectionViewSet(viewsets.ModelViewSet): public_token = request.data.get("public_token") name = request.data.get("name", "dummyName") account_id = request.data.get("account") + print(f"Account ID Detected: {account_id}") if public_token is None: return Response( status=status.HTTP_400_BAD_REQUEST, @@ -42,11 +43,13 @@ class ConnectionViewSet(viewsets.ModelViewSet): status=status.HTTP_400_BAD_REQUEST, data="ERROR: missing account_id") accounts = Account.objects.filter(pk=account_id) + if not accounts: return Response( status=status.HTTP_400_BAD_REQUEST, data="ERROR: invalid account_id") else: + print(f"Account Found: {accounts[0]}") account = accounts[0] print(request) plaid = importlib.import_module(f"connection.connections.plaid_client") diff --git a/user/views.py b/user/views.py index dff87c8..9d29732 100644 --- a/user/views.py +++ b/user/views.py @@ -34,11 +34,16 @@ class UserViewSet(viewsets.ModelViewSet): request.user.admin_accounts.all() | \ request.user.view_accounts.all() for qrtr_account in user_qrtr_accounts.distinct(): + print(f"Getting Connections for {qrtr_account}") connections = qrtr_account.connection_set.all() + print(connections) for connection in connections: + print("Getting items from plaid for given account") + print(connection) conn_name = connection.type.name conn_accs = [] client_lib = importlib.import_module(f"connection.connections.{connection.type.filename}") + print(type(connection.credentials)) client = client_lib.Connection(connection.credentials) connection.credentials = client.credentials connection.save()