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
1 changed files with 8 additions and 2 deletions

View File

@ -96,7 +96,10 @@ class TransactionCreateView(NummiCreateView):
def get_form_kwargs(self): def get_form_kwargs(self):
return super().get_form_kwargs() | { return super().get_form_kwargs() | {
"initial": { "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): def get_form_kwargs(self):
return super().get_form_kwargs() | { return super().get_form_kwargs() | {
"initial": { "initial": {
"account": self.kwargs.get("account"), "account": (
self.kwargs.get("account")
or Account.objects.filter(user=self.request.user).first()
),
}, },
} }