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")
|
||||
|
||||
total_images_series_size = models.BigIntegerField(null=True, blank=True)
|
||||
|
||||
def get_app_name(self):
|
||||
return "atlas"
|
||||
|
||||
@@ -495,6 +497,17 @@ class Case(models.Model, AuthorMixin, QuestionMixin):
|
||||
def get_series(self):
|
||||
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):
|
||||
to_keep = [
|
||||
|
||||
@@ -188,3 +188,6 @@
|
||||
|
||||
<p><b>Author(s):</b> {% for author in case.author.all %} <a
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user