From 6bf0e7d78a8a013946f8be5f395765dfb25e25b0 Mon Sep 17 00:00:00 2001 From: Vermaas <vermaas@astron.nl> Date: Mon, 15 Jan 2024 14:57:19 +0100 Subject: [PATCH] bugfix: show SAS_ID (output) --- atdb/taskdatabase/models.py | 24 ++++++++++++++++++- .../templates/taskdatabase/index.html | 2 +- .../templates/taskdatabase/ingest/tasks.html | 4 ++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index 20b6ee28..dc641500 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -280,16 +280,38 @@ class Task(models.Model): @property def sas_id_archived(self): + """ + check if this task already has an output SAS_ID at the LTA + """ try: return self.archive['sas_id_archived'] except: return None + @property + def sas_id_has_archived(self): + """ + check if any task belonging to this sas_id already has an output SAS_ID at the LTA + """ + try: + for task in Task.objects.filter(sas_id=self.sas_id): + if task.archive['sas_id_archived']: + return task.archive['sas_id_archived'] + except: + return None @property def path_to_lta(self): + """ + check if any task belonging to this sas_id already has a 'path_to_lta' setting + """ try: - return self.archive['path_to_lta'] + for task in Task.objects.filter(sas_id=self.sas_id): + if task.archive['path_to_lta']: + try: + return task.archive['path_to_lta'] + except: + pass except: return None diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 624dbd49..3903b2dc 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -31,7 +31,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 12 Jan 2024 + <p class="footer"> Version 15 Jan 2024 </div> {% include 'taskdatabase/refresh.html' %} diff --git a/atdb/taskdatabase/templates/taskdatabase/ingest/tasks.html b/atdb/taskdatabase/templates/taskdatabase/ingest/tasks.html index 1a61c352..7c4537f2 100644 --- a/atdb/taskdatabase/templates/taskdatabase/ingest/tasks.html +++ b/atdb/taskdatabase/templates/taskdatabase/ingest/tasks.html @@ -27,10 +27,10 @@ <td>{{ task.sasid_ingested_fraction.completion }}%</td> <td> - {% if task.sas_id_archived != None %} + {% if task.sas_id_has_archived != None %} <a href={{ task.path_to_lta }} target="_blank"> <img src="{% static 'taskdatabase/ldvlogo_small.png' %}" height="20" alt="link to LTA"> - {{ task.sas_id_archived }} + {{ task.sas_id_has_archived }} </a> {% else %} - -- GitLab