From 41422d0b32dcf735d7cb9e55ab22e0aea09a0821 Mon Sep 17 00:00:00 2001 From: AndyGrant Date: Thu, 24 Oct 2019 04:26:12 -0400 Subject: [PATCH] Grey out illegal buttons in viewTest --- OpenBench/static/style.css | 7 +++- OpenBench/views.py | 3 +- Templates/OpenBench/viewTest.html | 67 ++++++++++++++++++++++++------- 3 files changed, 60 insertions(+), 17 deletions(-) diff --git a/OpenBench/static/style.css b/OpenBench/static/style.css index fb8edbe..c465628 100644 --- a/OpenBench/static/style.css +++ b/OpenBench/static/style.css @@ -142,8 +142,13 @@ a:link, a:visited, a:hover, a:active { background-color: #FA8E8E; } +#content #actions .deadbutton { + background-color: #808080; + pointer-events: none; +} + #content #actions input { - width: 240px; + width: 260px; } #content #actions input[type=submit] { diff --git a/OpenBench/views.py b/OpenBench/views.py index 2727698..3c28204 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -306,7 +306,8 @@ def viewTest(request, id): # Build context dictionary for test template test = Test.objects.get(id=id) results = Result.objects.all().filter(test=test) - data = {'test' : test, 'results' : results} + profile = Profile.objects.get(user=request.user) if request.user.is_authenticated else None + data = {'test' : test, 'results' : results, 'profile' : profile} return render(request, 'viewTest.html', data) # Unable to find test diff --git a/Templates/OpenBench/viewTest.html b/Templates/OpenBench/viewTest.html index 85121fa..4723169 100644 --- a/Templates/OpenBench/viewTest.html +++ b/Templates/OpenBench/viewTest.html @@ -87,14 +87,47 @@

Actions

+ + + {% if not test.approved and profile.approver and profile.user.username is not test.author %} + Approve + {% elif not test.approved and request.user.is_superuser %} Approve - {% if test.finished %} - Restart {% else %} - Stop + Approve {% endif %} + + + {% if test.finished and profile.approver %} + Restart + {% elif test.finished and profile.user.username is test.author %} + Restart + {% elif test.finished %} + Restart + {% endif %} + + + {% if not test.finished and profile.approver %} + Stop + {% elif not test.finished and profile.user.username is test.author %} + Stop + {% elif not test.finished %} + Stop + {% endif %} + + + {% if profile.approver or profile.user.username is test.author %} Delete -

{{test.dev.name}} vs {{test.base.name}} DIFF

+ {% else %} + Delete + {% endif %} + + +

{{test.dev.name}} vs {{test.base.name}} + DIFF +

+ +
{{test|longStatBlock|linebreaksbr}}
@@ -103,7 +136,11 @@

+ {% if profile.approver or profile.user.username is test.author %} + {% else %} + + {% endif %}

@@ -121,17 +158,17 @@ Time {% for result in results %} - - {{result.machine.owner}} - {{result.machine.osname}} - {{result.updated|date:'Y-m-d H:i'}} - {{result.games}} - {{result.wins}} - {{result.losses}} - {{result.draws}} - {{result.crashes}} - {{result.timeloss}} - + + {{result.machine.owner}} + {{result.machine.osname}} + {{result.updated|date:'Y-m-d H:i'}} + {{result.games}} + {{result.wins}} + {{result.losses}} + {{result.draws}} + {{result.crashes}} + {{result.timeloss}} + {% endfor %}