Name | Actions | ||
+ + | ++ + | ++ + | ++ + | +
Instance Name | Server Name | Config | UDP | TCP | PID | ||||
{{name}} | +{{executor.serverName}} | +{{executor.config}} | +{{executor.udpPort}} | +{{executor.tcpPort}} | + ++ {% if executor.is_alive %} + {{executor.p.pid}} + {% else %} + exited with {{executor.retval}} + {% endif %} + | + {% if executor.is_alive %} ++ + | + {% else %} + | + + | + + | + {% endif %} +
{}
', long, short) + + def render_time(self, value): + if(value == 2147483647): + return '---' + s = value//1000 + m = s//60 + s %=60 + if m==0: return '%02i.%03i'%(s, value%1000) + return '%i:%02i.%03i'%(m, s, value%1000) + + def render_bestLap(self, value): + return format_html('{}
', + ' | '.join(list(map(self.render_time, value['bestSplits']))), + self.render_time(value['bestLap'])) + + def render_totaltime(self, value): + return self.render_time(value) + + +class Results(tables.Table): + name = Column() + type = Column() + track = Column() + entries = Column() + wetSession = Column() + view = TemplateColumn(template_name='results/table/results_view_column.html') + download = TemplateColumn(template_name='results/table/results_download_column.html') + simresults = TemplateColumn(template_name='results/table/results_simresults_column.html') + # delete = TemplateColumn(template_name='results/table/results_delete_column.html') + + +def parse_url(args, kwargs): + """ Read the select results file and display the selected portion of the json object """ + instance = kwargs['instance'] + result = args[0] + results_path = os.path.join(DATA_DIR, 'instances', instance, 'results') + return os.path.join(results_path, result+'.json') + + +def results(request, *args, **kwargs): + """ Read the select results file and display the selected portion of the json object """ + results = json.load(open(parse_url(args, kwargs), 'rb')) + path = request.path + if path[0] == '/': path = path[1:] + if path[-1] == '/': path = path[:-1] + path = path.split('/') + + context = { + 'path': [(j, '/'+'/'.join(path[:i+1])) for i,j in enumerate(path)], + 'table': LeaderBoard(results['sessionResult']['leaderBoardLines']) + } + return render(request, 'results/results.html', context) + + +def download(request, *args, **kwargs): + _f = parse_url(args, kwargs) + print(_f, os.path.basename(_f)) + if _f is not None and os.path.isfile(_f): + with open(_f, 'r') as fh: + response = HttpResponse(fh.read(), content_type="text/plain") + response['Content-Disposition'] = 'inline; filename=' + os.path.basename(_f) + return response + raise Http404 + + +def resultSelect(request, instance): + """ Show available results """ + results_path = os.path.join(DATA_DIR, 'instances', instance, 'results') + files = sorted(glob.glob('%s/*.json'%(results_path)), reverse=True) + files = filter(lambda x: not x.endswith('entrylist.json') , files) + + results = [] + for f in files: + r = json.load(open(f, 'rb')) + + results.append(dict( + name=os.path.splitext(ntpath.basename(f))[0], + type=r['sessionType'], # TODO: decode session type, seems to be borked atm + entries=len(r['sessionResult']['leaderBoardLines']), + wetSession=r['sessionResult']['isWetSession'], + track=r['trackName'], + )) + + path = request.path + if path[0] == '/': path = path[1:] + if path[-1] == '/':path = path[:-1] + path = path.split('/') + + table = Results(results) + RequestConfig(request).configure(table) + + context = { + 'path' : [(j, '/'+'/'.join(path[:i+1])) for i,j in enumerate(path)], + 'table' : table, + } + return render(request, 'results/results.html', context) diff --git a/ACC/templates/base.html b/ACC/templates/base.html new file mode 100644 index 0000000..c4c2bbd --- /dev/null +++ b/ACC/templates/base.html @@ -0,0 +1,84 @@ + + + + + + + + + + + + +You are not logged in
+ login + {% endif %} + +{% endblock %} diff --git a/ACC/templates/main_app.html b/ACC/templates/main_app.html new file mode 100644 index 0000000..154bdfe --- /dev/null +++ b/ACC/templates/main_app.html @@ -0,0 +1,16 @@ +{% extends "base.html" %} +{% block base %} + +