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

add discard button to validation screen also

parent 785eca06
No related branches found
No related tags found
2 merge requests!295merge all the updates to master into this branch also,!294adding (initial) discard mechanism
Pipeline #49093 passed
......@@ -42,3 +42,15 @@ logging[14/Apr/2023 14:17:24,827] unsupported operand type(s) for +=: 'NoneType'
[01/May/2023 17:07:47,382] task 25485 - (regular) - 146233 has no plots, skipped.
[01/May/2023 17:07:48,568] unsupported operand type(s) for &: 'bool' and 'str'
[01/May/2023 17:07:48,569] task 25485 - (regular) - 146233 has no plots, skipped.
[04/May/2023 14:35:18,946] 'NoneType' object is not subscriptable
[04/May/2023 14:35:18,946] task 25378 - (regular) - 116876 has no plots, skipped.
[04/May/2023 14:35:21,861] 'NoneType' object is not subscriptable
[04/May/2023 14:35:21,861] task 25378 - (regular) - 116876 has no plots, skipped.
[04/May/2023 14:35:52,010] 'NoneType' object is not subscriptable
[04/May/2023 14:35:52,010] task 25378 - (regular) - 116876 has no plots, skipped.
[04/May/2023 14:35:52,100] 'NoneType' object is not subscriptable
[04/May/2023 14:35:52,100] task 25378 - (regular) - 116876 has no plots, skipped.
[04/May/2023 14:35:52,193] 'NoneType' object is not subscriptable
[04/May/2023 14:35:52,193] task 25378 - (regular) - 116876 has no plots, skipped.
[04/May/2023 14:35:52,294] 'NoneType' object is not subscriptable
[04/May/2023 14:35:52,294] task 25378 - (regular) - 116876 has no plots, skipped.
......@@ -26,5 +26,5 @@
<a href="{% url 'sort-tasks' 'filter' 'discarded' %}" class="btn btn-light btn-sm" role="button"><i class="fas fa-sort-down"></i></a>
</th>
<th>Cleanup Policy</th>
<th>Remarks</th>
<th>Reason</th>
</tr>
\ No newline at end of file
......@@ -37,7 +37,7 @@
<td>{{ task.filter }} </td>
<td>{{ task.cleanup_policy }} </td>
<td>{{ task.remarks }} </td>
<td>{{ task.remarks.discard_reason }} </td>
</tr>
</div>
{% endif %}
......
......@@ -41,7 +41,6 @@
<td>
{% include "taskdatabase/failures/retry_buttons.html" %}
<a href="{% url 'task-discard-view' task.pk 'discarded' my_tasks.number %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-trash-alt"></i> Discard</a>
</td>
</tr>
......
{% extends 'taskdatabase/base.html' %}
{% block myBlock %}
<div class="container-fluid details-container">
<div class="card">
<div class="card-body">
<form action="./{{ page }}" method="POST">{% csrf_token %}
<div class="text-center">
<h5> Are you sure you want to discard all ({{ count }}) tasks with SAS_ID {{ sas_id }}?</h5>
Enter a reason for discarding (optional)
{% csrf_token %}
<div>
{{ my_form }}
</div>
<p>
<button class="btn btn-success btn-sm" type="submit"><i class="fas fa-check"></i> OK</button>
<a href="{% url 'validation' %}" class="btn btn-warning btn-sm" role="button"><i class="fas fa-times-circle"></i> Cancel</a>&nbsp
</p>
</div>
</form>
</div>
</div>
</div>
{% endblock %}
\ No newline at end of file
......@@ -22,4 +22,5 @@
<th>Annotate</th>
<th>Quality</th>
<th>Validate (choose a Q)</th>
<th>Discard</th>
</tr>
\ No newline at end of file
......@@ -68,7 +68,7 @@
</td>
<td class="{{ task.quality }}">{{ task.quality|default_if_none:"-" }}</td>
<td>{% include "taskdatabase/validation/validation_buttons.html" %}</td>
<td><a href="{% url 'task-discard-view-sasid' task.pk 'discarded' my_tasks.number %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-trash-alt"></i></a></td>
</tr>
</div>
{% endif %}
......
......@@ -98,6 +98,7 @@ urlpatterns = [
path('tasks/<int:pk>/validate/<quality>/<new_status>/<page>', views.TaskValidate, name='task-validate-view'),
path('tasks/<int:pk>/retry/<new_status>/<page>', views.TaskRetry, name='task-retry-view'),
path('tasks/<int:pk>/discard/<new_status>/<page>', views.TaskDiscard, name='task-discard-view'),
path('tasks/<int:pk>/discard_sasid/<new_status>/<page>', views.TaskDiscardSasId, name='task-discard-view-sasid'),
path('tasks/<int:pk>/change_priority/<priority_change>/<page>', views.ChangePriority, name='task-change-priority'),
path('tasks/<int:pk>/change_priority/<priority_change>', views.ChangePriority, name='task-change-priority'),
......
......@@ -1129,6 +1129,51 @@ def TaskDiscard(request, pk, new_status, page=0):
return render(request, "taskdatabase/failures/confirm_discard.html", {'task': task, 'page': page})
def TaskDiscardSasId(request, pk, new_status, page=0):
# TODO: when the cleanup service in place,
# make a change in this line in failures\tasks.html. Change 'discard' into 'discarded'.
# <a href="{% url 'task-discard-view' task.pk 'discarded' my_tasks.number %}"
task = Task.objects.get(pk=pk)
sas_id = task.sas_id
tasks = Task.objects.filter(sas_id=sas_id)
if request.method == "POST":
form = QualityAnnotationForm(request.POST)
for task in tasks:
task.cleanup_policy = task.status
if form.is_valid():
try:
task.remarks['discard_reason'] = request.POST.get("annotation", "")
except:
task.remarks = {}
task.remarks['discard_reason'] = request.POST.get("annotation", "")
task.new_status = new_status
task.save()
# return to the validation page
return redirect_with_params('validation', '?page=' + page)
else:
# a GET means that the form should be presented to be filled in
try:
discard_reason = task.remarks['discard_reason']
except:
discard_reason = ""
count=tasks.count()
my_form = QualityAnnotationForm(initial={'annotation': discard_reason, 'return_to_page': page})
# if not a POST, then render the confirmaton page, which will return to this function with a POST.
return render(request, "taskdatabase/validation/confirm_discard.html",
{'task': task, 'my_form': my_form, 'page': page, 'sas_id': sas_id, 'count': count})
# set a filter value in the session, used later by the 'get_searched_tasks' mechanism
def TaskSetFilter(request, filter, redirect_to_page):
request.session['task_filter'] = filter
......
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