Add old style / templates, hook up index

This commit is contained in:
AndyGrant committed 2018-06-09 18:54:42 -04:00
1 parent 9b400155a1
commit e0159edd35
7 files changed
+254 -20

No files matched your search

+5 -2
View File
@@ -25,6 +25,9 @@ class Machine(Model):
owner = CharField(max_length=64)
osname = CharField(max_length=128)
cores = IntegerField(default=0)
mnps = FloatField(default=0.00)
lastseen = DateTimeField(auto_now=True)
def __str__(self):
@@ -41,7 +44,6 @@ class Results(Model):
draws = IntegerField(default=0)
crashes = IntegerField(default=0)
time = IntegerField(default=0)
lastseen = DateTimeField(default=0)
def __str__(self):
@@ -80,11 +82,12 @@ class Test(Model):
passed = BooleanField(default=False)
failed = BooleanField(default=False)
finished = BooleanField(default=False)
deleted = BooleanField(default=False)
approved = BooleanField(default=False)
creation = DateTimeField(auto_now=True)
complted = DateTimeField(auto_now=True)
completion = DateTimeField(auto_now=True)
def __str__(self):
return '{0} vs {1} @ {2}'.format(self.dev.name, self.base.name, self.timecontrol)
+136
View File
@@ -0,0 +1,136 @@
body {
font-family: "Courier New";
font-size: 20px;
}
#sidebar {
float: left;
margin: 20px;
padding-right: 20px;
}
#content {
float: left;
padding-top: 20px;
padding-bottom: 20px;
display: block;
width: auto;
}
#errormessagebar {
background-color: RED;
padding: 8px;
text-align: center;
}
table {
background-color: none;
}
.tabletitle {
background-color: GREEN;
font-size: 20px;
}
th, td {
border: 1px solid black;
}
th {
text-align: center;
padding: 3px 16px;
background-color: #4CAF50;
color: white;
}
td {
padding: 2px 16px;
text-align: right;
}
tr:nth-child(even){background-color: #DBDBDB}
tr:nth-child(odd){background-color: #BDBDBD}
.failed:nth-child(even){background-color: #FAA5A5}
.failed:nth-child(odd){background-color: #FA8E8E}
.passed:nth-child(even){background-color: #2FFA62}
.passed:nth-child(odd){background-color: #9DF779}
.active:nth-child(even){background-color: #E9FA32}
.active:nth-child(odd){background-color: #EEF788}
ul {
list-style-type: none;
display: block;
margin: 20px 0px 0px 0px;
padding-left: 10px;
}
li {
margin: 8px;
}
.listheader {
font-weight: bold;
color: grey;
}
table {
line-height: 75%;
}
a:link, a:visited, a:hover, a:active {
text-decoration: none;
color: blue;
}
#pagebrowse {
display: inline-block;
text-align: center;
width: 100%;
margin-top: 8px;
}
.page {
border-style: solid;
border-width: 2px;
border-color: black;
border-radius: 4px;
font-weight: bold;
text-align: center;
display: inline-block;
padding-top : 8px;
padding-bottom: 8px;
width: 5%;
}
input[type=text], input[type=password], textarea, select {
padding: 8px 6px;
display: inline-block;
vertical-align: middle;
width: 400px;
}
input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 8px 6px;
margin: 8px 0;
border: none;
border-radius: 4px;
cursor: pointer;
width: 100%;
}
input[type=submit]:hover {
background-color: #45a049;
}
label, option {
display: inline-block;
width: 140px;
font-weight:bold;
vertical-align: middle;
}
+49
View File
@@ -0,0 +1,49 @@
from django import template
from OpenBench.models import Test
def oneDigitPrecision(value):
try:
value = round(value, 1)
if "." not in str(value):
return str(value) + ".0"
pre, post = str(value).split(".")
post += "0"
return pre + "." + post[0:1]
except:
return value
def twoDigitPrecision(value):
try:
value = round(value, 2)
if "." not in str(value):
return str(value) + ".00"
pre, post = str(value).split(".")
post += "00"
return pre + "." + post[0:2]
except:
return value
def gitDiffLink(test):
if type(test) != Test:
dev = test["dev"]["source"]
base = test["base"]["source"]
devsha = test["dev"]["sha"]
basesha = test["base"]["sha"]
else:
dev = test.dev.source
base = test.base.source
devsha = test.dev.sha
basesha = test.base.sha
repo = "/".join(dev.split("/")[:-2])
return "{0}/compare/{1}...{2}".format(repo, basesha[:8], testsha[:8])
register = template.Library()
register.filter("oneDigitPrecision", oneDigitPrecision)
register.filter("twoDigitPrecision", twoDigitPrecision)
register.filter("gitDiffLink", gitDiffLink)
+30 -9
View File
@@ -9,15 +9,13 @@ from django.contrib.auth.models import User
from OpenBench.config import *
from OpenBench.models import LogEvent
from OpenBench.models import LogEvent, Machine, Test
# Wrap django.shortcuts.render to add framework settings
def render(request, template, data):
data.update(FRAMEWORK_DEFAULTS)
return djangoRender(request, 'OpenBench/{0}'.format(template), data)
## ADMIN
def register(request):
# User trying to view the registration page
@@ -59,8 +57,6 @@ def logout(request):
logoutUser(request)
return HttpResponseRedirect("/index/")
## CONTENT VIEWING
def eventLog(request):
# Build context dictionary for template
@@ -73,9 +69,36 @@ def eventLog(request):
return render(request, "eventLog.html", data)
def index(request, page=0):
pass
## TEST MANAGMENT
# Get tests pending approval
pending = Test.objects.filter(approved=False)
pending = pending.exclude(deleted=True)
pending = pending.order_by('creation')
# Get tests currently running
active = Test.objects.filter(approved=True)
active = active.exclude(passed=True)
active = active.exclude(failed=True)
active = active.exclude(deleted=True)
active = active.order_by('priority', 'currentllr')
# Get the last 50 completed tests
completed = Test.objects.filter(finished=True)
completed = completed.exclude(deleted=True)
completed = completed.order_by('completion')
# Get machines currently active workloads
# machines = Machine.objects.get()
# machines = Machines played within last <minutes>
# Save my @nitrocan @defenchess
data = {
'pending' : [],
'active' : [],
'completed' : [],
}
return render(request, 'index.html', data)
def newTest(request):
pass
@@ -89,8 +112,6 @@ def viewTest(request, id):
def approveTest(request, id):
pass
## CLIENT TARGETS
def getFiles(request):
pass
+1
View File
@@ -43,6 +43,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'OpenBench',
'OpenBench.templatetags',
]
MIDDLEWARE = [
+33 -9
View File
@@ -1,5 +1,7 @@
{% extends "OpenBench/base.html" %}
{% load mytags %}
{% block title %}
Index
{% endblock %}
@@ -7,12 +9,12 @@ Index
{% block content %}
<table>
<tr>
<th class="tabletitle"> TEST </th>
<th class="tabletitle"> DIFF </th>
<th class="tabletitle"> APPROVE </th>
<th class="tabletitle">TEST</th>
<th class="tabletitle">DIFF</th>
<th class="tabletitle">APPROVE</th>
</tr>
{% for test in pendingtests %}
{% for test in pending %}
<tr class={{test.status}}>
<td style="text-align:left;font-weight:bold">
<a href="/viewTest/{{test.id}}">{{test.dev.name}}</a>
@@ -22,16 +24,18 @@ Index
</td>
<td><a href="/approveTest/{{test.id}}">approve</a></td>
</tr>
{% endfor %}
</table>
<table>
<tr>
<th class="tabletitle"> TEST </th>
<th class="tabletitle"> DIFF </th>
<th class="tabletitle"> STATS </th>
<th class="tabletitle"> ELO </th>
<th class="tabletitle">AUTHOR</th>
<th class="tabletitle">TEST</th>
<th class="tabletitle">DIFF</th>
<th class="tabletitle">STATS</th>
<th class="tabletitle">ELO</th>
</tr>
{% for test in activetests %}
{% for test in active %}
<tr class={{test.status}}>
<td style="text-align:left;font-weight:bold">
<a href="/viewTest/{{test.id}}">{{test.dev.name}}</a>
@@ -48,5 +52,25 @@ Index
</strong></td>
<td> {{enginetest.elo|twoDigitPrecision}} </td>
</tr>
{% endfor %}
{% for test in completed %}
<tr class={{test.status}}>
<td style="text-align:left;font-weight:bold">
<a href="/viewTest/{{test.id}}">{{test.dev.name}}</a>
</td>
<td style="text-align:left;font-weight:bold">
<a href="{{test|gitDiffLink}}">diff</a>
</td>
<td style="text-align:left;font-size:14px"><strong>
SPRT @ {{test.timecontrol}}s Threads={{test.threads}} Hash={{test.hashsize}}MB<br>
LLR: {{test.currentllr|twoDigitPrecision}} ({{test.lowerllr|twoDigitPrecision}},
{{test.upperllr|twoDigitPrecision}}) [{{test.elolower|twoDigitPrecision}},
{{test.eloupper|twoDigitPrecision}}] <br> Games: {{test.games}}
W: {{test.wins}} L: {{test.losses}} D: {{test.draws}}
</strong></td>
<td> {{enginetest.elo|twoDigitPrecision}} </td>
</tr>
{% endfor %}
</table>
{% endblock %}
BIN
View File
Binary file not shown.