Fixed plaid connection attaching to the wrong account
This commit is contained in:
parent
6f728d8792
commit
b5b9604e63
@ -33,6 +33,7 @@ class ConnectionViewSet(viewsets.ModelViewSet):
|
|||||||
public_token = request.data.get("public_token")
|
public_token = request.data.get("public_token")
|
||||||
name = request.data.get("name", "dummyName")
|
name = request.data.get("name", "dummyName")
|
||||||
account_id = request.data.get("account")
|
account_id = request.data.get("account")
|
||||||
|
print(f"Account ID Detected: {account_id}")
|
||||||
if public_token is None:
|
if public_token is None:
|
||||||
return Response(
|
return Response(
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
@ -42,11 +43,13 @@ class ConnectionViewSet(viewsets.ModelViewSet):
|
|||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
data="ERROR: missing account_id")
|
data="ERROR: missing account_id")
|
||||||
accounts = Account.objects.filter(pk=account_id)
|
accounts = Account.objects.filter(pk=account_id)
|
||||||
|
|
||||||
if not accounts:
|
if not accounts:
|
||||||
return Response(
|
return Response(
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
data="ERROR: invalid account_id")
|
data="ERROR: invalid account_id")
|
||||||
else:
|
else:
|
||||||
|
print(f"Account Found: {accounts[0]}")
|
||||||
account = accounts[0]
|
account = accounts[0]
|
||||||
print(request)
|
print(request)
|
||||||
plaid = importlib.import_module(f"connection.connections.plaid_client")
|
plaid = importlib.import_module(f"connection.connections.plaid_client")
|
||||||
|
|||||||
@ -34,11 +34,16 @@ class UserViewSet(viewsets.ModelViewSet):
|
|||||||
request.user.admin_accounts.all() | \
|
request.user.admin_accounts.all() | \
|
||||||
request.user.view_accounts.all()
|
request.user.view_accounts.all()
|
||||||
for qrtr_account in user_qrtr_accounts.distinct():
|
for qrtr_account in user_qrtr_accounts.distinct():
|
||||||
|
print(f"Getting Connections for {qrtr_account}")
|
||||||
connections = qrtr_account.connection_set.all()
|
connections = qrtr_account.connection_set.all()
|
||||||
|
print(connections)
|
||||||
for connection in connections:
|
for connection in connections:
|
||||||
|
print("Getting items from plaid for given account")
|
||||||
|
print(connection)
|
||||||
conn_name = connection.type.name
|
conn_name = connection.type.name
|
||||||
conn_accs = []
|
conn_accs = []
|
||||||
client_lib = importlib.import_module(f"connection.connections.{connection.type.filename}")
|
client_lib = importlib.import_module(f"connection.connections.{connection.type.filename}")
|
||||||
|
print(type(connection.credentials))
|
||||||
client = client_lib.Connection(connection.credentials)
|
client = client_lib.Connection(connection.credentials)
|
||||||
connection.credentials = client.credentials
|
connection.credentials = client.credentials
|
||||||
connection.save()
|
connection.save()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user