Default fields

Fixes #3
This commit is contained in:
Edgar P. Burkhart 2022-12-31 18:59:29 +01:00
parent 748f9e5fb6
commit d9304db43d
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -96,7 +96,10 @@ class TransactionCreateView(NummiCreateView):
def get_form_kwargs(self):
return super().get_form_kwargs() | {
"initial": {
"snapshot": self.kwargs.get("snapshot"),
"snapshot": (
self.kwargs.get("snapshot")
or Snapshot.objects.filter(user=self.request.user).first()
),
},
}
@ -128,7 +131,10 @@ class SnapshotCreateView(NummiCreateView):
def get_form_kwargs(self):
return super().get_form_kwargs() | {
"initial": {
"account": self.kwargs.get("account"),
"account": (
self.kwargs.get("account")
or Account.objects.filter(user=self.request.user).first()
),
},
}