From e77a6509fb93817271910fa8485fe7d999facc20 Mon Sep 17 00:00:00 2001 From: AndyGrant Date: Sun, 10 Jun 2018 22:03:55 -0400 Subject: [PATCH] Edit test priority and throughput -- show results --- OpenBench/views.py | 31 +++++++++++++++++++++++++++--- Templates/OpenBench/viewTest.html | 27 ++++++++++++++++++++++++++ db.sqlite3 | Bin 62464 -> 63488 bytes 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/OpenBench/views.py b/OpenBench/views.py index af04ce9..c4b5976 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -87,13 +87,13 @@ def index(request, page=0, username=None, error=''): # Get tests pending approval pending = Test.objects.filter(approved=False) pending = pending.exclude(deleted=True) - pending = pending.order_by('creation') + pending = pending.order_by('-creation') # Get tests currently running active = Test.objects.filter(approved=True) active = active.exclude(finished=True) active = active.exclude(deleted=True) - active = active.order_by('priority', 'currentllr') + active = active.order_by('-priority', '-currentllr') # Get the complted tests (sliced later) completed = Test.objects.filter(finished=True) @@ -174,7 +174,32 @@ def viewTest(request, id): @login_required(login_url='/login/') def editTest(request, id): - pass + + try: + # Only let approvers or the author edit a test + test = Test.objects.get(id=id) + profile = Profile.objects.get(user=request.user) + if not profile.approver and test.author != profile.user.username: + raise Exception("Only Admins Or Test Owners Can Edit A Test") + + # Edit the provided test + test = Test.objects.get(id=id) + test.priority = int(request.POST['priority']) + test.throughput = max(0, int(request.POST['throughput'])) + test.save() + + # Log the test stopping + event = LogEvent() + event.data = 'Edit test {0} ({1}) P={2} TP={3}'.format(str(test), test.id, test.priority, test.throughput) + event.author = request.user.username + event.save() + + return HttpResponseRedirect('/index/') + + # Bad test id, permissions, or other + except Exception as error: + return index(request, error=str(error)) + @login_required(login_url='/login/') def approveTest(request, id): diff --git a/Templates/OpenBench/viewTest.html b/Templates/OpenBench/viewTest.html index 617c0bc..7b6b7a0 100644 --- a/Templates/OpenBench/viewTest.html +++ b/Templates/OpenBench/viewTest.html @@ -104,5 +104,32 @@ +
+ + + + + + + + + + + + + {% for result in results %} + + + + + + + + + + {% endfor %} +
UserMachineUpdatedGamesWinsLossesDrawsCrashesTime
{{result.machine.owner}} + {{result.machine.osname}} + {{result.lastseen}}{{result.games}}{{result.wins}}{{result.losses}}{{result.draws}}{{result.crashes}}{{result.time}}
{% endblock %} \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index a8e8b35371e28047da56e312489e9f6f1fa28438..67d8108f9e442e3a5a4cace96779332d43058f44 100644 GIT binary patch delta 663 zcmZp8!QAkHd4e?S8U_XiyNL?+jB7R~yx?LK-|We~dkPN|^EaS4gB|m4=5Lz?7Cd8S z1@de~H~(JDX2Z|y%fP}=&csm8_>fVDY1+hz>CBBrER*#gc4-({85mm`8R(fC7@L_I z8W|W`=o*;m8X77Xpvr94c__~$0J4H%GlL`}qpq&HEC6w}v zni-m4m;{&E^n`^+f{P)Jfq6NzAJbQ+*-TE1FB#hyl^G5)#7&&&#FHq>#?Z(t>FAo0 zSu#0yk+y|GfUSW-NPw-Ofq{WzUP@7FIhyH4R>l^31{M}ZhQPXKG+&YOZH&Vr*z^94;_|K#)qW-!&p z=6dFq76yi<;e1d-uJG^zBZ7(9j)8e0v)yJv1tVsjL~&I2Ap0D9ut6f;$lT1-C{~P> Vp%xKpny^sAr4baHz%Vd00RU1Ns>1*P delta 159 zcmZqpz})bHd4e?SECvP!+ldPHjI%Z-yx?Nw+w94`dkPmL^KYOygDvy#&3td(GH?F9 zn9YVCD8Ry~!@%s#_>fVDY1(E*4jIPHIuGTUm>Z2)ChI@!Q8PBMGBD6HH!(9ZGcYnR zw9qv$(={|yFfg=2mf7@#g@=oo=_>>Ca%MlKuRwF2GckqpO%C{MI$7b9*kq^A`v6_= BE^hz;