Repository: adamcharnock/django-hordak (language: python)

Issue:
class AccountTransactionsView(LoginRequiredMixin, SingleObjectMixin, View): ->class AccountTransactionsView(LoginRequiredMixin, SingleObjectMixin, ListView):
Hi!
after migrating from django-hordak==1.10.0 to  django-hordak==1.10.1
there is error when trying to view account transactions:
 **'super' object has no attribute 'get'** 
/usr/local/lib/python3.9/site-packages/hordak/views/accounts.py, line 89, in get
            return super(AccountTransactionsView, self).get(request, *args, **kwargs)

Please verify if instead of View in class AccountTransactionsView(LoginRequiredMixin, SingleObjectMixin, **View**): 
should be ListView, i.e.: class AccountTransactionsView(LoginRequiredMixin, SingleObjectMixin, **ListView**): like it was in previous version.
Best regards,
Pawel


Discussion / hints:

Fix patch:
diff --git a/hordak/views/accounts.py b/hordak/views/accounts.py
index 64413c7b..6d752d86 100644
--- a/hordak/views/accounts.py
+++ b/hordak/views/accounts.py
@@ -1,6 +1,5 @@
 from django.contrib.auth.mixins import LoginRequiredMixin
 from django.urls.base import reverse_lazy
-from django.views import View
 from django.views.generic.detail import SingleObjectMixin
 from django.views.generic.edit import CreateView, UpdateView
 from django.views.generic.list import ListView
@@ -78,7 +77,8 @@ class AccountUpdateView(LoginRequiredMixin, UpdateView):
     success_url = reverse_lazy("hordak:accounts_list")
 
 
-class AccountTransactionsView(LoginRequiredMixin, SingleObjectMixin, View):
+# TODO: remove ignore comment once https://github.com/typeddjango/django-stubs/issues/873 is fixed
+class AccountTransactionsView(LoginRequiredMixin, SingleObjectMixin, ListView):  # type: ignore
     template_name = "hordak/accounts/account_transactions.html"
     model = Leg
     slug_field = "uuid"


Test patch:
diff --git a/hordak/tests/views/test_accounts.py b/hordak/tests/views/test_accounts.py
index e4abe32a..b44603fd 100644
--- a/hordak/tests/views/test_accounts.py
+++ b/hordak/tests/views/test_accounts.py
@@ -1,11 +1,41 @@
+import django
 from django.test import TestCase
 from django.urls import reverse
 
 from hordak.forms.accounts import AccountForm
-from hordak.models import Account
+from hordak.models import Account, Leg, Transaction
 from hordak.tests.utils import DataProvider
 
 
+class AccountTransactionsViewTestCase(DataProvider, TestCase):
+    def setUp(self):
+        self.bank_account = self.account(is_bank_account=True, type=Account.TYPES.asset)
+        self.income_account = self.account(
+            is_bank_account=False, type=Account.TYPES.income
+        )
+        transaction = Transaction.objects.create()
+        Leg.objects.create(
+            amount=-10, account=self.bank_account, transaction=transaction
+        )
+        Leg.objects.create(
+            amount=10, account=self.income_account, transaction=transaction
+        )
+
+        self.view_url = reverse(
+            "hordak:accounts_transactions", kwargs={"uuid": self.bank_account.uuid}
+        )
+        self.login()
+
+    def test_get(self):
+        response = self.client.get(self.view_url)
+        # Tests needs to be run with LANG="US" environment variable
+        self.assertContains(response, "<td>€10.00</td>", html=True)
+        if django.VERSION >= (3, 0, 0):
+            self.assertContains(response, "<h5>Balance: €&nbsp;10.00</h5>", html=True)
+        else:  # Django 2.2
+            self.assertContains(response, "<h5>Balance: € 10.00</h5>", html=True)
+
+
 class AccountListViewTestCase(DataProvider, TestCase):
     def setUp(self):
         self.view_url = reverse("hordak:accounts_list")