Finalize hiding public information in settings
This commit is contained in:
1 parent
c02e0782b6
commit
f22883647d
4 files changed
+21
-13
No files matched your search
+7
-3
@@ -20,7 +20,9 @@
|
||||
|
||||
USE_CROSS_APPROVAL = False
|
||||
|
||||
REQUIRE_LOGIN_TO_VIEW = False
|
||||
REQUIRE_LOGIN_TO_VIEW = True
|
||||
|
||||
REQUIRE_MANUAL_REGISTRATION = True
|
||||
|
||||
OPENBENCH_CONFIG = {
|
||||
|
||||
@@ -29,8 +31,10 @@ OPENBENCH_CONFIG = {
|
||||
|
||||
# Generic Error Messages useful to those setting up their own instance
|
||||
'error' : {
|
||||
'disabled' : 'Account has not been enabled. Contact andrew@grantnet.us',
|
||||
'fakeuser' : 'This is not a real OpenBench User. Create an OpenBench account',
|
||||
'disabled' : 'Account has not been enabled. Contact andrew@grantnet.us',
|
||||
'fakeuser' : 'This is not a real OpenBench User. Create an OpenBench account',
|
||||
'requires_login' : 'All pages require a user login to access',
|
||||
'manual_registration' : 'Registration can only be done via an Administrator',
|
||||
},
|
||||
|
||||
# Link to the repo on the sidebar, as well as the core files
|
||||
|
||||
@@ -271,10 +271,13 @@ a:link, a:visited, a:hover, a:active {
|
||||
background-color: #00AF00;
|
||||
}
|
||||
|
||||
#error {
|
||||
#error pre {
|
||||
background-color: #EE7676;
|
||||
padding: 8px;
|
||||
padding: 6px;
|
||||
margin: 0px;
|
||||
text-align: center;
|
||||
font-family: "Courier Prime";
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
#content form h3 {
|
||||
|
||||
+7
-7
@@ -53,11 +53,8 @@ def render(request, template, content={}, always_allow=False):
|
||||
data.update({'config' : OpenBench.config.OPENBENCH_CONFIG})
|
||||
|
||||
if OpenBench.config.REQUIRE_LOGIN_TO_VIEW:
|
||||
|
||||
if not request.user.is_authenticated and not always_allow:
|
||||
return django.http.HttpResponseRedirect('/login/')
|
||||
|
||||
return django.shortcuts.render(request, 'OpenBench/{0}'.format(template), data)
|
||||
return login(request, OpenBench.config.OPENBENCH_CONFIG['error']['requires_login'])
|
||||
|
||||
if request.user.is_authenticated:
|
||||
|
||||
@@ -130,7 +127,9 @@ def register(request):
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if request.method == 'GET':
|
||||
return render(request, 'register.html', always_allow=True)
|
||||
if not OpenBench.config.REQUIRE_MANUAL_REGISTRATION:
|
||||
return render(request, 'register.html', always_allow=True)
|
||||
return login(request, OpenBench.config.OPENBENCH_CONFIG['error']['manual_registration'])
|
||||
|
||||
if request.POST['password1'] != request.POST['password2']:
|
||||
return index(request, error='Passwords Do Not Match')
|
||||
@@ -151,7 +150,7 @@ def register(request):
|
||||
|
||||
return django.http.HttpResponseRedirect('/index/')
|
||||
|
||||
def login(request):
|
||||
def login(request, error=''):
|
||||
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
# #
|
||||
@@ -163,7 +162,8 @@ def login(request):
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
if request.method == 'GET':
|
||||
return render(request, 'login.html', always_allow=True)
|
||||
data = { 'error' : error }
|
||||
return render(request, 'login.html', data, always_allow=True)
|
||||
|
||||
try:
|
||||
user = authenticate(request)
|
||||
|
||||
Reference in new issue
Block a user