diff --git a/atdb/taskdatabase/services/algorithms.py b/atdb/taskdatabase/services/algorithms.py index e6640f37bef8a27b73f9cd013307215dcaa3ba9f..75d1f4ca37db36ae9c68a8b4b50aebb01ed4bf68 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 86ff0efb6aa8f696bc2e7e95ceaa2dd8f4200385..a8d710651ba529049d6085654aa6ddaa3f7bc4fb 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 874b4da18ce9ef1a70525d9c84a5571ab740db46..7fdc80434b54e926e3ab33a25feddd4ee79ad942 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 0ef41c979f061cc4640d432783c492431e871c05..d767d08bf551d96253d746010c7aa590d731108d 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)