From 0b405acfcfd12f378c459c106da15294daf11dd5 Mon Sep 17 00:00:00 2001 From: Vermaas <vermaas@astron.nl> Date: Tue, 27 Jun 2023 08:49:58 +0200 Subject: [PATCH] add 'remove' button in annotations modal --- atdb/taskdatabase/services/algorithms.py | 6 +++--- .../validation/annotate_quality_sasid.html | 2 ++ atdb/taskdatabase/urls.py | 2 ++ atdb/taskdatabase/views.py | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index e6640f37..75d1f4ca 100644 --- a/atdb/taskdatabase/services/algorithms.py +++ b/atdb/taskdatabase/services/algorithms.py @@ -59,10 +59,10 @@ def get_min_start_and_max_end_time(sas_id): tasks = Task.objects.filter(sas_id=sas_id) for task in tasks: try: - # If more entrees are found for 'processing' task, get the latest + # If more entries are found for 'processing' task, get the latest latest_start_time = LogEntry.objects.filter(task=task.pk).filter(step_name='running').filter(status='processing').latest('timestamp') start_time = latest_start_time.timestamp - # If more entrees are found for 'processed' task, get the latest + # If more entries are found for 'processed' task, get the latest lastest_end_time = LogEntry.objects.filter(task=task.pk).filter(step_name='running').filter(status='processed').latest('timestamp') end_time = lastest_end_time.timestamp if min_start_time is None: @@ -842,7 +842,7 @@ def construct_summary(task): line += '<td colspan="2">' + str(round(record['size_ratio'],3)) + '</td>' line += '</tr>' - if 'rfi_percent' in record.keys(): + if 'rfi_percent' in record: # add RFI percentage (if present) rfi = record['rfi_percent'] line += '<tr><td><b>RFI percentage</b></td>' diff --git a/atdb/taskdatabase/templates/taskdatabase/validation/annotate_quality_sasid.html b/atdb/taskdatabase/templates/taskdatabase/validation/annotate_quality_sasid.html index 86ff0efb..a8d71065 100644 --- a/atdb/taskdatabase/templates/taskdatabase/validation/annotate_quality_sasid.html +++ b/atdb/taskdatabase/templates/taskdatabase/validation/annotate_quality_sasid.html @@ -13,6 +13,8 @@ {{ form }} </div> <div><button class="btn btn-success btn-sm" type="submit"><i class="fas fa-check"></i> OK</button> + <a href="{% url 'clear-annotations-sasid' task.id %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-trash-alt"></i> Remove</a>  + <a href="{% url 'validation' %}" class="btn btn-warning btn-sm" role="button"><i class="fas fa-times-circle"></i> Cancel</a>  </div> </form> diff --git a/atdb/taskdatabase/urls.py b/atdb/taskdatabase/urls.py index 874b4da1..7fdc8043 100644 --- a/atdb/taskdatabase/urls.py +++ b/atdb/taskdatabase/urls.py @@ -31,6 +31,8 @@ urlpatterns = [ path('annotate_quality_sasid/<int:id>', views.AnnotateQualitySasId, name='annotate-quality-sasid'), path('annotate_quality_sasid/<int:id>/<page>', views.AnnotateQualitySasId, name='annotate-quality-sasid'), path('show_inspectionplots/<int:id>/<page>', views.ShowInspectionPlots, name='inspection-plots'), + path('clear_annotations_sasid/<int:id>', views.ClearAnnotationsSasID, name='clear-annotations-sasid'), + path('clear_annotations_sasid/<int:id>/<page>', views.ClearAnnotationsSasID, name='clear-annotations-sasid'), path('show_inspectionplots_sasid/<int:id>/<expand_image>', views.ShowInspectionPlotsSasId, name='inspection-plots-sasid'), path('show_summary/<int:id>/<page>', views.ShowSummarySasId, name='summary'), diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index 0ef41c97..d767d08b 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -677,6 +677,23 @@ def AnnotateQualitySasId(request, id=0, page=0): return render(request, "taskdatabase/validation/annotate_quality_sasid.html", {'task': task, 'page': page, 'form': form}) +def ClearAnnotationsSasID(request, id=0): + + task = Task.objects.get(id=id) + tasks = Task.objects.filter(sas_id=task.sas_id) + for task in tasks: + try: + task.remarks['quality_sasid'] = None + except: + task.remarks = {} + task.remarks['quality_sasid'] = None + + task.save() + + return redirect('validation') + + + def ShowInspectionPlots(request, id=0, page=0): # a GET means that the form should be presented to be filled in task = Task.objects.get(id=id) -- GitLab