Add restore button to test view page (#164)

This commit is contained in:
Alexandra authored and GitHub committed 2023-09-11 10:36:49 -04:00
1 parent c0bedf6fbc
commit 5d1ee29358
2 files changed
+13 -4

No files matched your search

+2 -1
View File
@@ -440,7 +440,7 @@ def test(request, id, action=None):
if not (test := Test.objects.filter(id=id).first()):
return django.http.HttpResponseRedirect('/index/')
if action not in ['APPROVE', 'RESTART', 'STOP', 'DELETE', 'MODIFY']:
if action not in ['APPROVE', 'RESTART', 'STOP', 'DELETE', 'RESTORE', 'MODIFY']:
data = { 'test' : test, 'results': Result.objects.filter(test=test) }
return render(request, 'test.html', data)
@@ -459,6 +459,7 @@ def test(request, id, action=None):
if action == 'RESTART': test.finished = False; test.save()
if action == 'STOP' : test.finished = True; test.save()
if action == 'DELETE' : test.deleted = True; test.save()
if action == 'RESTORE': test.deleted = False; test.save()
if action == 'MODIFY':
test.priority = int(request.POST['priority'])
+11 -3
View File
@@ -116,11 +116,19 @@
<a class="w-25 mr-2 anchorbutton btn-disabled">Stop</a>
{% endif %}
<!-- Delete Button: For Approvers or Test Authors -->
<!-- Delete/Restore Button: For Approvers or Test Authors -->
{% if profile.approver or profile.user.username == test.author %}
<a class="w-25 mr-2 anchorbutton btn-red" href="/test/{{test.id}}/DELETE">Delete</a>
{% if test.deleted %}
<a class="w-25 mr-2 anchorbutton btn-preset" href="/test/{{test.id}}/RESTORE">Restore</a>
{% else %}
<a class="w-25 mr-2 anchorbutton btn-red" href="/test/{{test.id}}/DELETE">Delete</a>
{% endif %}
{% else %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Delete</a>
{% if test.deleted %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Restore</a>
{% else %}
<a class="w-25 mr-2 anchorbutton btn-disabled">Delete</a>
{% endif %}
{% endif %}
<!-- Copy Button: Copy the current results statblock -->