add simple case and series size display
This commit is contained in:
+13
-1
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user