43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||
|
from mixins.views import ObjectList, ObjectRead
|
||
|
from two_factor.views.mixins import OTPRequiredMixin
|
||
|
|
||
|
from core.models import Aggregator
|
||
|
from core.util import logs
|
||
|
|
||
|
log = logs.get_logger(__name__)
|
||
|
|
||
|
|
||
|
class BanksCurrencies(LoginRequiredMixin, OTPRequiredMixin, ObjectList):
|
||
|
"""
|
||
|
Get a list of configured currencies from the banks we use.
|
||
|
"""
|
||
|
|
||
|
list_template = "partials/banks-currencies-list.html"
|
||
|
page_title = "Bank Currencies"
|
||
|
|
||
|
context_object_name_singular = "currency"
|
||
|
context_object_name = "currencies"
|
||
|
|
||
|
list_url_name = "currencies"
|
||
|
list_url_args = ["type"]
|
||
|
|
||
|
def get_queryset(self, **kwargs):
|
||
|
aggregators = Aggregator.objects.filter(user=self.request.user, enabled=True)
|
||
|
|
||
|
account_info = {}
|
||
|
for agg in aggregators:
|
||
|
for bank, accounts in agg.account_info.items():
|
||
|
if bank not in account_info:
|
||
|
account_info[bank] = []
|
||
|
for account in accounts:
|
||
|
account_info[bank].append(account)
|
||
|
|
||
|
return account_info
|
||
|
|
||
|
|
||
|
class BankCurrencyDetails(LoginRequiredMixin, OTPRequiredMixin, ObjectRead):
|
||
|
"""
|
||
|
Get the bank details for the selected currency.
|
||
|
"""
|