diff --git a/OpenBench/config.py b/OpenBench/config.py index 6088389..30b55b7 100644 --- a/OpenBench/config.py +++ b/OpenBench/config.py @@ -20,10 +20,15 @@ OPENBENCH_CONFIG = { - # Sidebar link, location of resources, and contact information + 'error' : { + 'disabled' : 'Account has not been enabled. Contact andrew@grantnet.us', + 'fakeuser' : 'This is not a real OpenBench User. Create an OpenBench account', + }, + + + # Link to the repo on the sidebar, as well as the core files 'framework' : 'http://github.com/AndyGrant/OpenBench/', 'corefiles' : 'http://github.com/AndyGrant/OpenBench/raw/master/CoreFiles/', - 'serveradmin' : 'andrew@grantnet.us', # SPRT Elo bounds and type I/II errors 'sprt' : { 'elolower' : 0.00, 'eloupper' : 5.00, 'alpha' : 0.05, 'beta' : 0.05 }, diff --git a/OpenBench/views.py b/OpenBench/views.py index 3ffe039..33a846c 100644 --- a/OpenBench/views.py +++ b/OpenBench/views.py @@ -41,10 +41,22 @@ import OpenBench.utils, datetime def render(request, template, data={}): - # Provide Configuration & User information + # Always provide the basic configuration data.update({'config' : OPENBENCH_CONFIG}) + if request.user.is_authenticated: - data.update({'profile' : Profile.objects.get(user=request.user)}) + + # Provide user information when possible + profile = Profile.objects.filter(user=request.user).first() + data.update({'config' : OPENBENCH_CONFIG, 'profile' : profile}) + + # Warn Users that they need to be enabled + if profile and not profile.enabled: + data.update({'error' : OPENBENCH_CONFIG['error']['disabled']}) + + # Warn any non-OpenBench users made by some means + if request.user.is_authenticated and not profile: + data.update({'error' : OPENBENCH_CONFIG['error']['fakeuser']}) # Wrapper to simplify django's rendering function return django.shortcuts.render(request, 'OpenBench/{0}'.format(template), data) diff --git a/Templates/OpenBench/base.html b/Templates/OpenBench/base.html index d6555a9..1fe6997 100644 --- a/Templates/OpenBench/base.html +++ b/Templates/OpenBench/base.html @@ -22,14 +22,6 @@ {% endif %} - - {% if request.user.is_authenticated and not profile.enabled %} -