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