-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding ability to make signup private process #427
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can extend the WebTest from the test/init.py and have the setup waiting for you.I know you need to tweak the config, but perhaps we can do that by sticking an override_config attribute on the class? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome idea, i'll work on it |
||
"""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': '[email protected]' | ||
} | ||
) | ||
self.assertIn(self.message, res.body) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so then I'd make this match. 'signup_enabled'. It makes it clear what true/false do to this. |
||
return { | ||
'signup': True | ||
} | ||
else: | ||
return {} | ||
else: | ||
if not username: | ||
return HTTPFound(location=request.route_url("bmark_recent")) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,9 @@ email.host=sendmail | |
fulltext.engine=whoosh | ||
fulltext.index=bookie_test | ||
|
||
#Change to false to disable signups | ||
signup_process = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this also needs to go into the test_pgsql.ini. We've recently set that up on the CI server. http://ci.bookie.io:8080 |
||
|
||
# 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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about making this more explicit. 'signup_enabled'