diff --git a/bookie/templates/index.mako b/bookie/templates/index.mako
index 47c4a215..10b2d573 100644
--- a/bookie/templates/index.mako
+++ b/bookie/templates/index.mako
@@ -4,16 +4,20 @@
diff --git a/bookie/tests/test_auth/test_signup.py b/bookie/tests/test_auth/test_signup.py
index c8d09828..d449e679 100644
--- a/bookie/tests/test_auth/test_signup.py
+++ b/bookie/tests/test_auth/test_signup.py
@@ -7,6 +7,8 @@
urlencode,
)
import transaction
+from pyramid import testing
+from unittest import TestCase
from bookie.models import DBSession
from bookie.models.auth import Activation
@@ -204,3 +206,42 @@ def testSignupWorks(self):
email,
act.user.email,
"The activation email is the correct one.")
+
+
+class TestPrivateHosting(TestCase):
+ """Check if Signup is disabled in private hosting"""
+
+ message = 'This site is private please contact admin for invitation.'
+
+ def setUp(self):
+ from pyramid.paster import get_app
+ from bookie.tests import BOOKIE_TEST_INI
+ app = get_app(BOOKIE_TEST_INI, 'bookie')
+ # Changing signup_process to false to disable signups
+ app.registry.settings['signup_process'] = "false"
+ from webtest import TestApp
+ self.testapp = TestApp(app)
+ testing.setUp()
+
+ def tearDown(self):
+ testing.tearDown()
+
+ def testSignupPage(self):
+ """A signup form is not available."""
+ res = self.testapp.get('/signup')
+ self.assertIn(self.message, res.body)
+
+ def testMainPage(self):
+ """A signup form is not available in main page."""
+ res = self.testapp.get('/')
+ self.assertIn(self.message, res.body)
+
+ def testManualHit(self):
+ """Message should be shown if /signup_process is hit manually"""
+ res = self.testapp.post(
+ '/signup_process',
+ params={
+ 'email': 'testing@dummy.com'
+ }
+ )
+ self.assertIn(self.message, res.body)
\ No newline at end of file
diff --git a/bookie/views/__init__.py b/bookie/views/__init__.py
index c98c5b74..b3a0f4a1 100644
--- a/bookie/views/__init__.py
+++ b/bookie/views/__init__.py
@@ -1,6 +1,7 @@
"""Basic views with no home"""
from pyramid.httpexceptions import HTTPFound
from pyramid.httpexceptions import HTTPNotFound
+from pyramid.settings import asbool
from pyramid.view import view_config
from bookie.models.auth import UserMgr
@@ -30,7 +31,12 @@ def home(request):
username = username.lower()
if not request.user:
- return {}
+ if asbool(request.registry.settings.get('signup_process')):
+ return {
+ 'signup': True
+ }
+ else:
+ return {}
else:
if not username:
return HTTPFound(location=request.route_url("bmark_recent"))
diff --git a/bookie/views/api.py b/bookie/views/api.py
index 66ece5db..03aee510 100644
--- a/bookie/views/api.py
+++ b/bookie/views/api.py
@@ -656,7 +656,7 @@ def reset_password(request):
new = params.get('new_password', None)
# if we don't have any password info, try a json_body in case it's a json
- #POST
+ # POST
if current is None and new is None:
params = request.json_body
current = params.get('current_password', None)
diff --git a/bookie/views/auth.py b/bookie/views/auth.py
index 23518b1c..b7ee0c81 100644
--- a/bookie/views/auth.py
+++ b/bookie/views/auth.py
@@ -6,6 +6,7 @@
from pyramid.renderers import render_to_response
from pyramid.security import remember
from pyramid.security import forget
+from pyramid.settings import asbool
from pyramid.url import route_url
from pyramid.view import view_config
@@ -105,7 +106,12 @@ def signup(request):
this time so that we can stage invites across a specific number in waves.
"""
- return {}
+ if not asbool(request.registry.settings.get('signup_process')):
+ return {
+ 'message': 'This site is private please contact admin for invitation.'
+ }
+ else:
+ return {}
@view_config(route_name="signup_process", renderer="/auth/signup.mako")
@@ -116,6 +122,10 @@ def signup_process(request):
information.
"""
+ if not asbool(request.registry.settings.get('signup_process')):
+ return {
+ 'message': 'This site is private please contact admin for invitation.'
+ }
params = request.params
email = params.get('email', None)
diff --git a/sample.ini b/sample.ini
index 7a5d2840..f38e0912 100644
--- a/sample.ini
+++ b/sample.ini
@@ -21,6 +21,9 @@ email.host=sendmail
fulltext.engine=whoosh
fulltext.index=bookie_index
+#Change to false to disable signups
+signup_process = true
+
# what is the host that's providing the YUI combo loader?
combo_server=
# Set this to help bust the cache. It will add a prefix to the combo url you
diff --git a/test.ini b/test.ini
index ad297e4d..c4047f58 100644
--- a/test.ini
+++ b/test.ini
@@ -21,6 +21,9 @@ email.host=sendmail
fulltext.engine=whoosh
fulltext.index=bookie_test
+#Change to false to disable signups
+signup_process = true
+
# what is the host that's providing the YUI combo loader?
combo_server = http://127.0.0.1:8000
# set this to help bust the cache. It will add a prefix to the combo url you