Fix bugs with snapshots: opening earliest snapshot, deleting latest
This commit is contained in:
parent
57ace376d8
commit
02b0fae3f7
2 changed files with 7 additions and 4 deletions
|
@ -121,7 +121,7 @@ class Snapshot(models.Model):
|
|||
try:
|
||||
_next = self.__class__.objects.get(previous=self)
|
||||
except self.__class__.DoesNotExist:
|
||||
pass
|
||||
super().delete(*args, **kwargs)
|
||||
else:
|
||||
_next.previous = self.previous
|
||||
super().delete(*args, **kwargs)
|
||||
|
|
|
@ -123,9 +123,12 @@ def snapshot(request, date=None):
|
|||
_transactions = None
|
||||
else:
|
||||
_snapshot = get_object_or_404(Snapshot, date=date)
|
||||
_transactions = Transaction.objects.filter(
|
||||
date__lt=_snapshot.date, date__gte=_snapshot.previous.date
|
||||
)
|
||||
if _snapshot.previous is None:
|
||||
_transactions = None
|
||||
else:
|
||||
_transactions = Transaction.objects.filter(
|
||||
date__lt=_snapshot.date, date__gte=_snapshot.previous.date
|
||||
)
|
||||
return render(
|
||||
request,
|
||||
"main/snapshot.html",
|
||||
|
|
Loading…
Reference in a new issue