From e0159edd35f9b4d4d1ad6f9cb50b295b9a6d4243 Mon Sep 17 00:00:00 2001 From: AndyGrant Date: Sat, 9 Jun 2018 18:54:42 -0400 Subject: [PATCH] Add old style / templates, hook up index --- OpenBench/models.py | 7 +- OpenBench/static/style.css | 136 +++++++++++++++++++++++++++++++ OpenBench/templatetags/mytags.py | 49 +++++++++++ OpenBench/views.py | 39 +++++++-- OpenSite/settings.py | 1 + Templates/OpenBench/index.html | 42 ++++++++-- db.sqlite3 | Bin 54272 -> 54272 bytes 7 files changed, 254 insertions(+), 20 deletions(-) create mode 100644 OpenBench/static/style.css create mode 100644 OpenBench/templatetags/mytags.py diff --git a/OpenBench/models.py b/OpenBench/models.py index 65868b9..9ad233f 100644 --- a/OpenBench/models.py +++ b/OpenBench/models.py @@ -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) diff --git a/OpenBench/static/style.css b/OpenBench/static/style.css new file mode 100644 index 0000000..b36fc26 --- /dev/null +++ b/OpenBench/static/style.css @@ -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; +} diff --git a/OpenBench/templatetags/mytags.py b/OpenBench/templatetags/mytags.py new file mode 100644 index 0000000..b577b95 --- /dev/null +++ b/OpenBench/templatetags/mytags.py @@ -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) + diff --git a/OpenBench/views.py b/OpenBench/views.py index e20f2de..6f3cde2 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -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 + # 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 diff --git a/OpenSite/settings.py b/OpenSite/settings.py index 0375b9c..9b47059 100644 --- a/OpenSite/settings.py +++ b/OpenSite/settings.py @@ -43,6 +43,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'OpenBench', + 'OpenBench.templatetags', ] MIDDLEWARE = [ diff --git a/Templates/OpenBench/index.html b/Templates/OpenBench/index.html index 0eafea9..199d85d 100644 --- a/Templates/OpenBench/index.html +++ b/Templates/OpenBench/index.html @@ -1,5 +1,7 @@ {% extends "OpenBench/base.html" %} +{% load mytags %} + {% block title %} Index {% endblock %} @@ -7,12 +9,12 @@ Index {% block content %} - - - + + + - {% for test in pendingtests %} + {% for test in pending %} + {% endfor %}
TEST DIFF APPROVE TESTDIFFAPPROVE
{{test.dev.name}} @@ -22,16 +24,18 @@ Index approve
- - - - + + + + + - {% for test in activetests %} + {% for test in active %} + {% endfor %} + + {% for test in completed %} + + + + + + + {% endfor %}
TEST DIFF STATS ELO AUTHORTESTDIFFSTATSELO
{{test.dev.name}} @@ -48,5 +52,25 @@ Index {{enginetest.elo|twoDigitPrecision}}
+ {{test.dev.name}} + + diff + + SPRT @ {{test.timecontrol}}s Threads={{test.threads}} Hash={{test.hashsize}}MB
+ LLR: {{test.currentllr|twoDigitPrecision}} ({{test.lowerllr|twoDigitPrecision}}, + {{test.upperllr|twoDigitPrecision}}) [{{test.elolower|twoDigitPrecision}}, + {{test.eloupper|twoDigitPrecision}}]
Games: {{test.games}} + W: {{test.wins}} L: {{test.losses}} D: {{test.draws}} +
{{enginetest.elo|twoDigitPrecision}}
{% endblock %} \ No newline at end of file diff --git a/db.sqlite3 b/db.sqlite3 index 71f4192518bf75e540d4f5087fcde743251ab5e8..b59a7d03bacf6e675ebb4ca865230d357c374d51 100644 GIT binary patch delta 914 zcmZoz!Q8NddBbEDJ|inr6DuP_JyS~y19Q{K3t6lYLKa}5S1eWtAv3U$5vx5y$P_G8 z&uWSgG6oABVl_h-Vq-Hw2pNG@d9axygbct!y=*pcAro`3&~;=Xh$9r)O{HM2HvyYv zz|6`ZuIiYWlAD<~c_F(5!VrkL)7X{aLdFpP9%t7^2!YMr#39bYewukN^8)7X&59gM z%##)P=PL5Dh>9{MmX>6c7N-`m2(ySPf_Vk0MY);9#hLkelkf5CGoISaC$NrLiHC)S zK~xl`T8J6QQv~slRSTPQRxu|rdof!xYi^bk`N>o-$ik@1$dZzplUkA*53+^_B9feu zn3oO_;pSsulx1W|Oi2MN;1XwH)MsRdYC)LJ2@!{CM2K^UurO*eGJ~`u1lfgH7*!dW zQZ`Q$ugl?L`o(mHX&zG(Q^IDs76m2_1s+xgMrCc5$*0<+*}0+YH*M0&TtK$0D%>f~ ziFpb@a}_}D*5L%o>6{DjFWJSMoL@9~!9H=W+`NKfC558Y z#GK8#OVb576)o7sH8mOgYd6o`I)jrfEi*5(IAgNn{w$W%lFaLb^Ab`2)KO20Fl&-L%{GttciL^5qrNy&dOc84U6Oo0b)m z6UQ*f0yH?nlBAFf))^5~7|Z~~7THK9F~|XEd7H|;W&#QD5FWtiu<6Y{RH1k>$#XzA zFnzr-PsRrC?;G>og#XSLN8&G-uIk@aqxP!gd)b9}BPN9fRhF-cp%H7yjBpH$Y2q6* zxnX1WEwUK4?#(^=o&Fzdzc>_A9S%C+3fJM*IF4KE_iv6HHFEz(jVQVf9yoOA)d#P> pdo3;Tr-_o!gQpk0t@qC)y0m{4wQY+o?q=wx{qz0p6E8n!{sQg^4`~1Z