order atlas tables by creation date by default
This commit is contained in:
+1
-1
@@ -1326,7 +1326,7 @@ class UncategorisedDicom(models.Model):
|
||||
|
||||
def get_dicom_info(self):
|
||||
try:
|
||||
ds = pydicom.read_file(self.image)
|
||||
ds = pydicom.dcmread(self.image)
|
||||
return ds
|
||||
except pydicom.errors.InvalidDicomError:
|
||||
return {"SeriesInstanceUID": "1234"}
|
||||
|
||||
@@ -65,6 +65,7 @@ class CaseTable(tables.Table):
|
||||
"author",
|
||||
)
|
||||
sequence = ("view", )#, "series")
|
||||
order_by = "-created_date"
|
||||
|
||||
def __init__(self, data=None, *args, **kwargs):
|
||||
super().__init__(
|
||||
@@ -125,6 +126,7 @@ class SeriesTable(tables.Table):
|
||||
"modified_date",
|
||||
)
|
||||
sequence = ("view", "popup", "images", "case")
|
||||
order_by = "-created_date"
|
||||
|
||||
def __init__(self, data=None, *args, **kwargs):
|
||||
super().__init__(
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
Atlas:
|
||||
{% if request.user.is_authenticated %}
|
||||
<a href="{% url 'atlas:collection_view' %}">Collections</a> /
|
||||
<a href="{% url 'atlas:case_view' %}?sort=-created_date">Cases</a> /
|
||||
<a href="{% url 'atlas:case_view' %}">Cases</a> /
|
||||
<a href="{% url 'atlas:series_view' %}">Series</a> /
|
||||
<a href="{% url 'atlas:categories_list' %}">Categories</a> /
|
||||
{% comment %} <a href="{% url 'atlas:resource_view' %}">Resources</a> / {% endcomment %}
|
||||
|
||||
@@ -488,13 +488,18 @@ class SeriesBase(models.Model):
|
||||
n = n + 1
|
||||
|
||||
def order_by_dicom(self, field="SliceLocation"):
|
||||
print(f"Ordering by dicom field {field}")
|
||||
images = self.images.filter(removed=False)
|
||||
|
||||
|
||||
files = []
|
||||
|
||||
for i in images:
|
||||
files.append((i, pydicom.dcmread(i.image.path)))
|
||||
|
||||
print("images to order")
|
||||
print(files)
|
||||
|
||||
# print("file count: {}".format(len(files)))
|
||||
|
||||
# skip files with no SliceLocation (eg scout views)
|
||||
@@ -522,6 +527,7 @@ class SeriesBase(models.Model):
|
||||
for f in slices:
|
||||
i = map[f[field].value]
|
||||
i.position = n
|
||||
print(f"Setting position {n} for {i}")
|
||||
i.save()
|
||||
n = n + 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user