Add AccountSelect widget and update account field in forms

- Introduced AccountSelect widget for improved account selection in forms.
- Updated AccountForm, StatementForm, and TransactionFiltersForm to use AccountSelect.
- Modified account model options to include 'archived' in ordering.
- Added new migration for account model options change.
This commit is contained in:
Edgar P. Burkhart 2025-01-04 18:45:36 +01:00
parent ccbf433ec0
commit a238401f13
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
7 changed files with 73 additions and 2 deletions

View file

@ -1,3 +1,4 @@
from django.forms.widgets import Select
from main.forms import IconInput, NummiForm
from .models import Account
@ -15,3 +16,7 @@ class AccountForm(NummiForm):
widgets = {
"icon": IconInput(),
}
class AccountSelect(Select):
template_name = "account/forms/widgets/account.html"

View file

@ -0,0 +1,20 @@
# Generated by Django 4.2.7 on 2025-01-04 17:44
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("account", "0003_account_archived"),
]
operations = [
migrations.AlterModelOptions(
name="account",
options={
"ordering": ["-default", "archived", "name"],
"verbose_name": "Account",
"verbose_name_plural": "Accounts",
},
),
]

View file

@ -41,7 +41,7 @@ class Account(UserModel):
)
class Meta:
ordering = ["-default", "name"]
ordering = ["-default", "archived", "name"]
verbose_name = _("Account")
verbose_name_plural = _("Accounts")

View file

@ -0,0 +1,5 @@
{% load main_extras %}
<span class="ico-input account-select">
{{ "bank"|remix }}
{% include "django/forms/widgets/select.html" %}
</span>