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

validation per sas_id instead of per task

parent 364153ea
No related branches found
No related tags found
1 merge request!265SDC 791 validation per SAS_ID
Pipeline #40128 passed
......@@ -34,7 +34,7 @@
{% include 'taskdatabase/pagination.html' %}
</div>
</div>
<p class="footer"> Version 21 November 2022
<p class="footer"> Version 25 November 2022
</div>
......
......@@ -7,7 +7,7 @@
<div class="card-body">
<h4>Quality Annotation</h4>
<form class="post-form" action="{% url 'annotate-quality' task.id %}" method="POST">
<form class="post-form" action="{% url 'annotate-quality-sasid' task.sas_id %}" method="POST">
{% csrf_token %}
<div>
{{ form }}
......
......@@ -4,29 +4,9 @@
{% if task.status != "removed_invisible" %}
<div class="row">
<tr class="{{ task.status }}">
<td>
<a href="{{ task.get_absolute_url }}" target="_blank">{{ task.id }} </a>
</td>
<td>
{% if user.is_authenticated %}
<a class="btn btn-primary btn-sm"
href="{% url 'task-details' task.id my_tasks.number %}"
data-popup-url="{% url 'task-details' task.id my_tasks.number %}"
><i class="fas fa-list"></i> Details
</a>&nbsp;
{% if task.has_quality %}
<a class="open-modal btn btn-primary btn-sm"
href="{% url 'task-quality' task.id my_tasks.number %}"
data-popup-url="{% url 'task-quality' task.id my_tasks.number %}"
><i class="fas fa-balance-scale"></i> Quality
</a>&nbsp;
{% endif %}
{% endif %}
</td>
<td>{{ task.project }}</td>
<td>{{ task.sas_id }}</td>
<td>{{ task.project }}</td>
<td>{{ task.filter }} </td>
......
<tr>
<th>
<a href="{% url 'sort-tasks' '-pk' 'validation' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-up"></i></a>
ID
<a href="{% url 'sort-tasks' 'id' 'validation' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-down"></i></a>
<a href="{% url 'sort-tasks' '-sas_id' 'validation' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-up"></i></a>
SAS_ID
<a href="{% url 'sort-tasks' 'sas_id' 'validation' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-down"></i></a>
</th>
<th>Details</th>
<th>
<a href="{% url 'sort-tasks' '-project' 'validation' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-up"></i></a>
Project
<a href="{% url 'sort-tasks' 'project' 'validation' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-down"></i></a>
</th>
<th>
<a href="{% url 'sort-tasks' '-sas_id' 'validation' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-up"></i></a>
SAS_ID
<a href="{% url 'sort-tasks' 'sas_id' 'validation' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-down"></i></a>
</th>
<th>
<a href="{% url 'sort-tasks' '-filter' 'validation' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-up"></i></a>
Filter
......
......@@ -11,7 +11,7 @@
<div class="col-12">
<h3>Validation</h3>
These are the tasks in status <b>stored</b> that can be validated. Click one of the quality buttons to validate.
These are the SAS_ID's in status <b>stored</b> that can be validated. Click one of the quality buttons to validate.
<td>{% include 'taskdatabase/filter/search.html' %}</td>
......
......@@ -26,6 +26,7 @@ urlpatterns = [
path('annotate_quality/<int:id>/<page>', views.AnnotateQuality, name='annotate-quality'),
path('annotate_quality/<int:id>', views.AnnotateQuality, name='annotate-quality'),
path('annotate_quality/', views.AnnotateQuality, name='annotate-quality'),
path('annotate_quality_sasid/<sas_id>', views.AnnotateQualitySasId, name='annotate-quality-sasid'),
path('show_inspectionplots/<int:id>/<page>', views.ShowInspectionPlots, name='inspection-plots'),
path('show-inputs/<int:id>/', views.ShowInputs, name='show-inputs'),
......
......@@ -337,8 +337,9 @@ class ShowValidationPage(ListView):
def get_queryset(self):
stored_tasks = Task.objects.filter(status__icontains='stored')
tasks = get_filtered_tasks(self.request, stored_tasks)
stored_tasks = Task.objects.filter(status__icontains='stored').order_by("sas_id")
tasks = stored_tasks.distinct("sas_id")
#tasks = get_filtered_tasks(self.request, stored_tasks)
# exclude the failed tasks
tasks = tasks.exclude(status__icontains="failed")
......@@ -557,6 +558,37 @@ def AnnotateQuality(request, id=0, page=0, new_remark=""):
{'task': task, 'page': page, 'form': form})
def AnnotateQualitySasId(request, sas_id=0, page=0, new_remark=""):
# a POST means that the form is filled in and should be stored in the database
if request.method == "POST":
form = QualityAnnotationForm(request.POST)
if form.is_valid():
tasks = Task.objects.filter(sas_id=sas_id)
for task in tasks:
try:
task.remarks['quality'] = request.POST.get("annotation", "")
except:
task.remarks = {}
task.remarks['quality'] = request.POST.get("annotation", "")
task.save()
return redirect_with_params('validation', '?page=' + request.POST.get("return_to_page", 1))
else:
# a GET means that the form should be presented to be filled in
task = Task.objects.get(id=id)
try:
quality_remarks = task.remarks['quality']
except:
quality_remarks = ""
form = QualityAnnotationForm(initial={'annotation': quality_remarks, 'return_to_page': page})
return render(request, "taskdatabase/validation/annotate_quality.html",
{'task': task, 'page': page, 'form': form})
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)
......@@ -926,10 +958,20 @@ def TaskSetStatus(request, pk, new_status, page=0):
def TaskValidate(request, pk, quality, new_status, page=0):
model = Task
task = Task.objects.get(pk=pk)
task.new_status = new_status
task.quality = quality
task.save()
# find all tasks with the same SAS_ID, and set this quality to all of the
sas_id = task.sas_id
tasks = Task.objects.filter(sas_id=sas_id)
for task in tasks:
if task.status == 'stored':
task.quality = quality
task.new_status = new_status
# task.save()
#task.new_status = new_status
#task.quality = quality
#task.save()
if page == 0:
# redirect to details screen
......
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