Skip to content
Snippets Groups Projects
Commit defc1984 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

Merge branch 'SDC-1187-add-archived-page' into 'master'

updates after demo to SDCO

See merge request !334
parents d8e0d82e 277e082c
No related branches found
No related tags found
1 merge request!334updates after demo to SDCO
Pipeline #69050 passed
...@@ -280,16 +280,42 @@ class Task(models.Model): ...@@ -280,16 +280,42 @@ class Task(models.Model):
@property @property
def sas_id_archived(self): def sas_id_archived(self):
"""
check if this task already has an output SAS_ID at the LTA
"""
try: try:
return self.archive['sas_id_archived'] return self.archive['sas_id_archived']
except: except:
return None 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):
try:
if task.archive['sas_id_archived']:
return task.archive['sas_id_archived']
except:
pass
except:
return None
@property @property
def path_to_lta(self): def sasid_path_to_lta(self):
"""
check if any task belonging to this sas_id already has a 'path_to_lta' setting
"""
try: try:
return self.archive['path_to_lta'] for task in Task.objects.filter(sas_id=self.sas_id):
try:
if task.archive['path_to_lta']:
return task.archive['path_to_lta']
except:
# if 'path_to_lta' is not found, or 'archive' is empty, continue to the next task
pass
except: except:
return None return None
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 12 Jan 2024 <p class="footer"> Version 15 Jan 2024
</div> </div>
{% include 'taskdatabase/refresh.html' %} {% include 'taskdatabase/refresh.html' %}
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
<td>{{ task.sasid_ingested_fraction.completion }}%</td> <td>{{ task.sasid_ingested_fraction.completion }}%</td>
<td> <td>
{% if task.sas_id_archived != None %} {% if task.sas_id_has_archived != None %}
<a href={{ task.path_to_lta }} target="_blank"> <a href={{ task.path_to_lta }} target="_blank">
<img src="{% static 'taskdatabase/ldvlogo_small.png' %}" height="20" alt="link to LTA"> <img src="{% static 'taskdatabase/ldvlogo_small.png' %}" height="20" alt="link to LTA">
{{ task.sas_id_archived }} {{ task.sas_id_has_archived }}
</a>&nbsp; </a>&nbsp;
{% else %} {% else %}
- -
......
from django.test import TestCase
from taskdatabase.models import Task, Workflow
class TaskModelTestCase(TestCase):
def setUp(self):
# Create tasks for testing
# the first 2 have no valid path set
self.task1 = Task.objects.create(sas_id=12345,archive={})
self.task2 = Task.objects.create(sas_id=12345,archive={'path_to_lta': None})
# this task has a valid path_to_lta set
self.task3 = Task.objects.create(sas_id=12345,archive={'path_to_lta': '/sample/path'})
# this sasid has no path_to_lta set at all
self.task4 = Task.objects.create(sas_id=66666,archive={})
self.task5 = Task.objects.create(sas_id=66666,archive={})
def test_path_to_lta_with_path(self):
# if only one of the tasks has a path_to_lta, then the other tasks should also return that path
for task in Task.objects.filter(sas_id=12345):
result = task.sasid_path_to_lta
self.assertEqual(result, '/sample/path')
def test_path_to_lta_without_path(self):
# if one of the tasks has 'path_to_lta' set, then return None
for task in Task.objects.filter(sas_id=66666):
result = task.sasid_path_to_lta
self.assertEqual(result, None)
\ No newline at end of file
...@@ -553,6 +553,7 @@ def get_filtered_tasks(request, pre_filtered_tasks=None, distinct=None): ...@@ -553,6 +553,7 @@ def get_filtered_tasks(request, pre_filtered_tasks=None, distinct=None):
# check filtered_tasks on the session # check filtered_tasks on the session
# if it is at its max limit, then this is not a query targeted at 1 SAS_ID. # if it is at its max limit, then this is not a query targeted at 1 SAS_ID.
# in that case don't apply the filter, so that all SAS_ID's show up on the page. # in that case don't apply the filter, so that all SAS_ID's show up on the page.
# nv: 15jan2024, this disturbs how users now work with the filter, need to find a different solution.
try: try:
filtered_tasks_on_session = len(request.session['filtered_tasks_as_list']) filtered_tasks_on_session = len(request.session['filtered_tasks_as_list'])
if filtered_tasks_on_session != settings.QUERY_LIMIT_MULTI_CHANGE: if filtered_tasks_on_session != settings.QUERY_LIMIT_MULTI_CHANGE:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment