From 9ec29cf03b472b5767682c506b533e0a2a8e3b2b Mon Sep 17 00:00:00 2001 From: AndyGrant Date: Fri, 25 Oct 2019 05:49:45 -0400 Subject: [PATCH] Cleanup templates for all views Make use of the block structure to clean up index/events/search heavily Fix a bug for the paging context on the events view --- OpenBench/config.py | 46 ++-- OpenBench/static/style.css | 6 +- OpenBench/views.py | 13 +- Templates/OpenBench/Blocks/pagebrowser.html | 13 + Templates/OpenBench/Blocks/testsummary.html | 9 + Templates/OpenBench/base.html | 124 ++++----- Templates/OpenBench/eventLog.html | 54 ++-- Templates/OpenBench/index.html | 82 +++--- Templates/OpenBench/login.html | 20 +- Templates/OpenBench/machines.html | 54 ++-- Templates/OpenBench/newTest.html | 178 ++++++------- Templates/OpenBench/register.html | 26 +- Templates/OpenBench/search.html | 114 ++++---- Templates/OpenBench/users.html | 69 ++--- Templates/OpenBench/viewProfile.html | 60 +++-- Templates/OpenBench/viewTest.html | 271 ++++++++------------ 16 files changed, 542 insertions(+), 597 deletions(-) create mode 100644 Templates/OpenBench/Blocks/pagebrowser.html create mode 100644 Templates/OpenBench/Blocks/testsummary.html diff --git a/OpenBench/config.py b/OpenBench/config.py index 4087e86..c59b410 100644 --- a/OpenBench/config.py +++ b/OpenBench/config.py @@ -27,36 +27,42 @@ FRAMEWORK_DEFAULTS = { 'engines' : { 'Ethereal' : { - 'name' : 'Ethereal', - 'source' : 'https://github.com/AndyGrant/Ethereal', - 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' }, - 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, - 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, - 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, - 'nps' : 1500000, - 'proto' : 'uci', + 'proto' : 'uci', + 'nps' : 1500000, + 'name' : 'Ethereal', + 'source' : 'https://github.com/AndyGrant/Ethereal', + 'testmodes' : { + 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' }, + 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, + 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, + 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, + }, }, 'Laser' : { + 'proto' : 'uci', + 'nps' : 625000, 'name' : 'Laser', 'source' : 'https://github.com/jeffreyan11/uci-chess-engine', - 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' }, - 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, - 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, - 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, - 'nps' : 625000, - 'proto' : 'uci', + 'testmodes' : { + 'stc' : { 'threads' : 1, 'hash' : 8, 'timecontrol' : '10.0+0.1' }, + 'ltc' : { 'threads' : 1, 'hash' : 64, 'timecontrol' : '60.0+0.6' }, + 'smpstc' : { 'threads' : 8, 'hash' : 64, 'timecontrol' : '5.0+0.05' }, + 'smpltc' : { 'threads' : 8, 'hash' : 256, 'timecontrol' : '20.0+0.2' }, + }, }, 'Weiss' : { + 'proto' : 'uci', + 'nps' : 4000000, 'name' : 'Weiss', 'source' : 'https://github.com/TerjeKir/weiss', - 'stc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '10.0+0.1' }, - 'ltc' : { 'threads' : 1, 'hash' : 128, 'timecontrol' : '60.0+0.6' }, - 'smpstc' : { 'threads' : 8, 'hash' : 128, 'timecontrol' : '5.0+0.05' }, - 'smpltc' : { 'threads' : 8, 'hash' : 512, 'timecontrol' : '20.0+0.2' }, - 'nps' : 4000000, - 'proto' : 'uci', + 'testmodes' : { + 'stc' : { 'threads' : 1, 'hash' : 32, 'timecontrol' : '10.0+0.1' }, + 'ltc' : { 'threads' : 1, 'hash' : 128, 'timecontrol' : '60.0+0.6' }, + 'smpstc' : { 'threads' : 8, 'hash' : 128, 'timecontrol' : '5.0+0.05' }, + 'smpltc' : { 'threads' : 8, 'hash' : 512, 'timecontrol' : '20.0+0.2' }, + }, }, }, diff --git a/OpenBench/static/style.css b/OpenBench/static/style.css index 7df2fa6..dd95569 100644 --- a/OpenBench/static/style.css +++ b/OpenBench/static/style.css @@ -101,8 +101,10 @@ a:link, a:visited, a:hover, a:active { } #content .summarytable th { + padding-top: 20px; padding-right: 10px; - font-size: 20px; + padding-bottom: 20px; + font-size: 16px; color: #00CCFF; } @@ -120,7 +122,7 @@ a:link, a:visited, a:hover, a:active { } #content #actions { - float: left; + float: right; } #content #actions .anchorbutton { diff --git a/OpenBench/views.py b/OpenBench/views.py index 8517e18..3d5fa30 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -98,9 +98,10 @@ def editProfile(request): profile.user.email = request.POST['email'] profile.engine = request.POST['enginename'] profile.repo = request.POST['repo'] + profile.user.save() profile.save() - # Change Passwords + # Change Passwords if requested password1 = request.POST['password1'] password2 = request.POST['password2'] if password1 != '' and password1 == password2: @@ -110,8 +111,8 @@ def editProfile(request): username=request.user.username, password=password1)) - # Send back to see the changes - return HttpResponseRedirect('/viewProfile/') + # Send back to see the homepage + return HttpResponseRedirect('/index/') def index(request, page=1, pageLength=24, greens=False, username=None, error=''): @@ -257,15 +258,15 @@ def machines(request): data = {'machines' : Machine.objects.filter(updated__gte=target)} return render(request, 'machines.html', data) -def eventLog(request, page=0, pageLength=50): +def eventLog(request, page=1, pageLength=50): # Choose events within the given page, if any events = LogEvent.objects.all().order_by('-id') items = len(events) start = page * pageLength end = start + pageLength - start = max(0, min(start, items)) - end = max(0, min(end, items)) + start = max(1, min(start, items)) + end = max(1, min(end, items)) paging = pagingContext(page, pageLength, items, 'eventLog') # Build context dictionary for event log template diff --git a/Templates/OpenBench/Blocks/pagebrowser.html b/Templates/OpenBench/Blocks/pagebrowser.html new file mode 100644 index 0000000..a9ffa73 --- /dev/null +++ b/Templates/OpenBench/Blocks/pagebrowser.html @@ -0,0 +1,13 @@ +
+ {% if paging.prev != paging.next %} + <-- + {% for page in paging.pages %} + {% if page != "..." %} + {{page}} + {% else %} + {{page}} + {% endif %} + {% endfor %} + --> + {% endif %} +
\ No newline at end of file diff --git a/Templates/OpenBench/Blocks/testsummary.html b/Templates/OpenBench/Blocks/testsummary.html new file mode 100644 index 0000000..bbf236d --- /dev/null +++ b/Templates/OpenBench/Blocks/testsummary.html @@ -0,0 +1,9 @@ +{% load mytags %} + + {{test.author|slice:":6"}} + {{test.engine}} + {{test.dev.name}} + diff + {{test.timecontrol}} + {{test|shortStatBlock|linebreaksbr}} + \ No newline at end of file diff --git a/Templates/OpenBench/base.html b/Templates/OpenBench/base.html index 799a24d..59a18a7 100644 --- a/Templates/OpenBench/base.html +++ b/Templates/OpenBench/base.html @@ -1,69 +1,77 @@ + -{% load static %} + {% load static %} - - - OpenBench - - - + + + OpenBench + + + + + + {% if error %} +
+ {{error}} +
+ {% endif %} + + + {% if request.user.is_authenticated and not profile.enabled %} +
+ {{profile.user.username}}! Your account is not enabled. + Contact the Admin ( {{config.serveradmin}} ) +
+ {% endif %} + +