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:
|
try:
|
||||||
_next = self.__class__.objects.get(previous=self)
|
_next = self.__class__.objects.get(previous=self)
|
||||||
except self.__class__.DoesNotExist:
|
except self.__class__.DoesNotExist:
|
||||||
pass
|
super().delete(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
_next.previous = self.previous
|
_next.previous = self.previous
|
||||||
super().delete(*args, **kwargs)
|
super().delete(*args, **kwargs)
|
||||||
|
|
|
@ -123,6 +123,9 @@ def snapshot(request, date=None):
|
||||||
_transactions = None
|
_transactions = None
|
||||||
else:
|
else:
|
||||||
_snapshot = get_object_or_404(Snapshot, date=date)
|
_snapshot = get_object_or_404(Snapshot, date=date)
|
||||||
|
if _snapshot.previous is None:
|
||||||
|
_transactions = None
|
||||||
|
else:
|
||||||
_transactions = Transaction.objects.filter(
|
_transactions = Transaction.objects.filter(
|
||||||
date__lt=_snapshot.date, date__gte=_snapshot.previous.date
|
date__lt=_snapshot.date, date__gte=_snapshot.previous.date
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue