Begin implementing per-requisition configuration
This commit is contained in:
@@ -1,16 +1,50 @@
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpResponse
|
||||
from django.urls import reverse
|
||||
from mixins.views import ObjectList
|
||||
from mixins.views import ObjectList, ObjectUpdate
|
||||
from rest_framework import status
|
||||
from two_factor.views.mixins import OTPRequiredMixin
|
||||
|
||||
from core.clients.aggregators.nordigen import NordigenClient
|
||||
from core.models import Aggregator
|
||||
from core.forms import RequisitionForm
|
||||
from core.models import Aggregator, Requisition
|
||||
from core.util import logs
|
||||
from core.views.helpers import synchronize_async_helper
|
||||
|
||||
log = logs.get_logger(__name__)
|
||||
|
||||
|
||||
class BanksRequisitionUpdate(LoginRequiredMixin, OTPRequiredMixin, ObjectUpdate):
|
||||
model = Requisition
|
||||
form_class = RequisitionForm
|
||||
|
||||
page_title = "Update settings for requisition"
|
||||
|
||||
submit_url_name = "requisition_update"
|
||||
submit_url_args = ["type", "aggregator_id", "req_id"]
|
||||
|
||||
pk_required = False
|
||||
|
||||
hide_cancel = True
|
||||
|
||||
def get_object(self, **kwargs):
|
||||
aggregator_id = self.kwargs["aggregator_id"]
|
||||
req_id = self.kwargs["req_id"]
|
||||
|
||||
try:
|
||||
aggregator = Aggregator.objects.get(
|
||||
user=self.request.user, pk=aggregator_id
|
||||
)
|
||||
except Aggregator.DoesNotExist:
|
||||
return HttpResponse(status=status.HTTP_404_NOT_FOUND)
|
||||
req, _ = Requisition.objects.get_or_create(
|
||||
user=self.request.user,
|
||||
aggregator=aggregator,
|
||||
requisition_id=req_id,
|
||||
)
|
||||
return req
|
||||
|
||||
|
||||
class BanksCurrencies(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
||||
"""
|
||||
Get a list of bank accounts with their details.
|
||||
@@ -45,7 +79,7 @@ class BanksCurrencies(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
||||
for agg in aggregators:
|
||||
for bank, accounts in agg.account_info.items():
|
||||
for account in accounts:
|
||||
ident = (bank, account["requisition_id"])
|
||||
ident = (bank, account["requisition_id"], account["aggregator_id"])
|
||||
if ident not in account_info:
|
||||
account_info[ident] = []
|
||||
account_info[ident].append(account)
|
||||
|
||||
Reference in New Issue
Block a user