diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index 857c36fc74b513fa8bbb5a49003080e640199c49..2da6782c85fe491db2105b4358d4cf7a4a2b15c8 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -44,7 +44,7 @@ def convert_quality_to_shortlist_for_template(task): list.append(str(task.quality_json['sensitivity'])) list.append(str(task.quality_json['observing-conditions'])) #url = '{ <a href="' + task.quality_json['plots'][0]["path"] + '">Diagnostic Plots</a> }' - list.append("Diagnostic Plots") + list.append("Diagnostic Plots (todo)") except Exception as err: pass diff --git a/atdb/taskdatabase/tables.py b/atdb/taskdatabase/tables.py index b096adb17e5c57ed1940a617d3b8f4a153bad6eb..a3fed15a22f4b0d647d9ec73f555677a52952b51 100644 --- a/atdb/taskdatabase/tables.py +++ b/atdb/taskdatabase/tables.py @@ -25,7 +25,7 @@ class TaskTable(tables.Table): class Meta: model = Task template_name = "django_tables2/bootstrap4.html" - fields = ("id", "workflow","filter","priority","status","project","sas_id","resume","actions","buttons") + fields = ("id", "workflow","filter","priority","status","quality","project","sas_id","resume","actions","buttons") # columns that need specific rendering status = StatusColumn() diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 8e7485289688aac4f86868fe82e48e9455cca1e2..fdbdeee83358306f4093137a8a09e74e7305d096 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -34,7 +34,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 1.0.0 (1 apr 2021 - 16:00) + <p class="footer"> Version 1.0.0 (2 apr 2021 - 6:00) </div> diff --git a/atdb/taskdatabase/templates/taskdatabase/validation/tasks_validation_headers.html b/atdb/taskdatabase/templates/taskdatabase/validation/tasks_validation_headers.html index 366e15aec5f2deea1ceedc429e44e55b25645d0d..1d8d9fcd43dab31fa3b90eeea1c13f7edd025062 100644 --- a/atdb/taskdatabase/templates/taskdatabase/validation/tasks_validation_headers.html +++ b/atdb/taskdatabase/templates/taskdatabase/validation/tasks_validation_headers.html @@ -9,6 +9,6 @@ <th>Sensitivity</th> <th>Conditions</th> <th>Diagnostic plots</th> - <th>Current Quality</th> + <th>Current Q</th> <th>Choose a Quality</th> </tr> \ No newline at end of file diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index ea83c2ea47ee2460f2b803a5df9cf805d951a5c6..6f95128d33096fe713e6304b9202ef33e6649c67 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -59,6 +59,7 @@ class TaskFilter(filters.FilterSet): 'project': ['exact', 'icontains'], 'sas_id': ['exact', 'icontains', 'in'], 'status': ['exact', 'icontains', 'in', 'startswith'], + 'quality': ['exact', 'icontains', 'in', 'startswith'], 'purge_policy': ['exact'], 'priority': ['exact', 'lte', 'gte'], 'resume': ['exact'], @@ -81,6 +82,7 @@ class TaskFilterQueryPage(filters.FilterSet): 'filter': ['exact', 'icontains'], 'priority': ['exact', 'gte', 'lte'], 'status': ['icontains', 'in'], + 'quality': ['icontains', 'in'], 'project': ['exact', 'icontains', 'in'], 'sas_id': ['exact', 'icontains', 'in'], # 'resume': ['exact'], @@ -215,7 +217,7 @@ class IndexView(ListView): try: filter = self.request.session['task_filter'] if filter != 'all': - tasks = get_searched_tasks(filter, sort) + tasks = get_filtered_tasks(filter, sort) except: pass @@ -229,7 +231,7 @@ class IndexView(ListView): pass if (search_box is not None): - tasks = get_searched_tasks(search_box, sort) + tasks = get_filtered_tasks(search_box, sort) # only return the 'regular' tasks, and not the 'postprocessing' tasks in the GUI # tasks = tasks.filter(task_type='regular') @@ -283,7 +285,7 @@ class PostProcessingTasksView(ListView): try: filter = self.request.session['task_filter'] if filter != 'all': - tasks = get_searched_tasks(filter, sort) + tasks = get_filtered_tasks(filter, sort) except: pass @@ -297,7 +299,7 @@ class PostProcessingTasksView(ListView): pass if (search_box is not None): - tasks = get_searched_tasks(search_box, sort) + tasks = get_filtered_tasks(search_box, sort) # only return the 'regular' tasks, and not the 'postprocessing' tasks in the GUI tasks = tasks.filter(task_type='postprocessing') @@ -351,12 +353,12 @@ class ShowQualityPage(ListView): try: filter = self.request.session['task_filter'] if filter != 'all': - tasks = get_searched_tasks(filter, sort) + tasks = get_filtered_tasks(filter, sort) except: pass if (search_box is not None): - tasks = get_searched_tasks(search_box, sort) + tasks = get_filtered_tasks(search_box, sort) # exclude the tasks without quality information #tasks = tasks.exclude(outputs__isnull=True) @@ -406,18 +408,18 @@ class ShowValidationPage(ListView): except: sort = '-creationTime' - tasks = Task.objects.filter(status__icontains='stored').order_by(sort) - + stored_tasks = Task.objects.filter(status__icontains='stored').order_by(sort) + tasks = stored_tasks # check if there is a 'task_filter' put on the session try: filter = self.request.session['task_filter'] if filter != 'all': - tasks = get_searched_tasks(filter, sort) + tasks = get_filtered_tasks(filter, sort, stored_tasks) except: pass if (search_box is not None): - tasks = get_searched_tasks(search_box, sort) + tasks = get_filtered_tasks(search_box, sort, stored_tasks) # exclude the tasks without quality information tasks = tasks.exclude(status__icontains="failed") @@ -465,18 +467,19 @@ class ShowFailuresPage(ListView): except: sort = '-creationTime' - tasks = Task.objects.filter(status__icontains='failed').order_by(sort) + failed_tasks = Task.objects.filter(status__icontains='failed').order_by(sort) + tasks = failed_tasks # check if there is a 'task_filter' put on the session - #try: - # filter = self.request.session['task_filter'] - # if filter != 'all': - # tasks = get_searched_tasks(filter, sort) - #except: - # pass + try: + filter = self.request.session['task_filter'] + if filter != 'all': + tasks = get_filtered_tasks(filter, sort, failed_tasks) + except: + pass if (search_box is not None): - tasks = get_searched_tasks(search_box, sort) + tasks = get_filtered_tasks(search_box, sort, failed_tasks) paginator = Paginator(tasks, config.TASKS_PER_PAGE) # Show 50 tasks per page page = self.request.GET.get('page') @@ -501,9 +504,14 @@ class ShowFailuresPage(ListView): return tasks +# this provides a broad range of filters for the search_box in the GUI +def get_filtered_tasks(search, sort, tasks=None): + if tasks: + tasks_to_filter = tasks + else: + tasks_to_filter = Task.objects.all() -def get_searched_tasks(search, sort): - tasks = Task.objects.filter( + filtered_tasks = tasks_to_filter.filter( Q(id__contains=search) | Q(sas_id__contains=search) | Q(creationTime__icontains=search) | @@ -511,7 +519,7 @@ def get_searched_tasks(search, sort): Q(status__icontains=search) | Q(status__in=search) | Q(project__icontains=search)).order_by(sort) - return tasks + return filtered_tasks class TaskTables2View(SingleTableView):