add simple case and series size display
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-12-18 23:32
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('atlas', '0064_casecollection_exam_open_access'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='series',
|
||||||
|
name='total_image_size',
|
||||||
|
field=models.BigIntegerField(blank=True, help_text='Stores a (cached) total size of images within the series', null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-12-18 23:59
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('atlas', '0065_series_total_image_size'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='case',
|
||||||
|
name='total_images_series_size',
|
||||||
|
field=models.BigIntegerField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -390,6 +390,8 @@ class Case(models.Model, AuthorMixin, QuestionMixin):
|
|||||||
|
|
||||||
resource = models.ManyToManyField("Resource", through="CaseResource")
|
resource = models.ManyToManyField("Resource", through="CaseResource")
|
||||||
|
|
||||||
|
total_images_series_size = models.BigIntegerField(null=True, blank=True)
|
||||||
|
|
||||||
def get_app_name(self):
|
def get_app_name(self):
|
||||||
return "atlas"
|
return "atlas"
|
||||||
|
|
||||||
@@ -495,6 +497,17 @@ class Case(models.Model, AuthorMixin, QuestionMixin):
|
|||||||
def get_series(self):
|
def get_series(self):
|
||||||
return self.series.all().prefetch_related("images", "examination", "plane")
|
return self.series.all().prefetch_related("images", "examination", "plane")
|
||||||
|
|
||||||
|
def get_total_series_images_size(self, refresh=False):
|
||||||
|
if self.total_images_series_size is not None and not refresh:
|
||||||
|
return self.total_images_series_size
|
||||||
|
|
||||||
|
series = self.series.all()
|
||||||
|
size = sum(s.get_total_image_size(refresh=refresh) for s in series)
|
||||||
|
|
||||||
|
return size
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def extract_image_dicom_json_from_ds(ds, url, image_index):
|
def extract_image_dicom_json_from_ds(ds, url, image_index):
|
||||||
to_keep = [
|
to_keep = [
|
||||||
|
|||||||
@@ -188,3 +188,6 @@
|
|||||||
|
|
||||||
<p><b>Author(s):</b> {% for author in case.author.all %} <a
|
<p><b>Author(s):</b> {% for author in case.author.all %} <a
|
||||||
href="{% url 'atlas:author_detail' pk=author.pk %}">{{author}}</a>, {% endfor %}</p>
|
href="{% url 'atlas:author_detail' pk=author.pk %}">{{author}}</a>, {% endfor %}</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p><b>Case size:</b> {{ case.get_total_series_images_size | filesizeformat }}</p>
|
||||||
|
|||||||
+13
-1
@@ -336,6 +336,8 @@ class SeriesBase(models.Model):
|
|||||||
choices=SeriesModifiedChocies.choices,
|
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:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
|
||||||
@@ -531,7 +533,14 @@ class SeriesBase(models.Model):
|
|||||||
i.save()
|
i.save()
|
||||||
n = n + 1
|
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)
|
images = self.images.filter(removed=False)
|
||||||
|
|
||||||
size = 0
|
size = 0
|
||||||
@@ -539,6 +548,9 @@ class SeriesBase(models.Model):
|
|||||||
for i in images:
|
for i in images:
|
||||||
size += i.get_file_size()
|
size += i.get_file_size()
|
||||||
|
|
||||||
|
self.total_image_size = size
|
||||||
|
self.save()
|
||||||
|
|
||||||
return size
|
return size
|
||||||
|
|
||||||
def anonymise_images(self):
|
def anonymise_images(self):
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-12-18 23:32
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('longs', '0031_exam_results_supervisor_visible'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='longseries',
|
||||||
|
name='total_image_size',
|
||||||
|
field=models.BigIntegerField(blank=True, help_text='Stores a (cached) total size of images within the series', null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user