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 a8e8b35..67d8108 100644 Binary files a/db.sqlite3 and b/db.sqlite3 differ