add simple case and series size display

This commit is contained in:
Ross
2024-12-19 00:02:26 +00:00
parent e0974ae300
commit 8c43c40215
6 changed files with 83 additions and 1 deletions
+13 -1
View File
@@ -336,6 +336,8 @@ class SeriesBase(models.Model):
choices=SeriesModifiedChocies.choices,
)
total_image_size = models.BigIntegerField(null=True, blank=True, help_text="Stores a (cached) total size of images within the series")
class Meta:
abstract = True
@@ -531,7 +533,14 @@ class SeriesBase(models.Model):
i.save()
n = n + 1
def get_total_image_size(self):
def get_total_image_size(self, refresh=False):
"""Returns the total size of all images in the series.
If refresh is set to True the size will be recalculated and saved to the database
(in the field 'total_image_size')."""
if not refresh and self.total_image_size:
return self.total_image_size
images = self.images.filter(removed=False)
size = 0
@@ -539,6 +548,9 @@ class SeriesBase(models.Model):
for i in images:
size += i.get_file_size()
self.total_image_size = size
self.save()
return size
def anonymise_images(self):