Skip to content

Commit

Permalink
Merge pull request #2502 from ckan/open-id-removal
Browse files Browse the repository at this point in the history
Remove open-id related nag messages.
  • Loading branch information
joetsoi committed Sep 9, 2015
2 parents bdde94c + 55c10f1 commit d9ebb7e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 161 deletions.
30 changes: 7 additions & 23 deletions ckan/controllers/home.py
Expand Up @@ -74,30 +74,14 @@ def index(self):
except search.SearchError:
c.package_count = 0

if c.userobj is not None:
msg = None
if c.userobj and not c.userobj.email:
url = h.url_for(controller='user', action='edit')
is_google_id = \
c.userobj.name.startswith(
'https://www.google.com/accounts/o8/id')
if not c.userobj.email and (is_google_id and
not c.userobj.fullname):
msg = _(u'Please <a href="{link}">update your profile</a>'
u' and add your email address and your full name. '
u'{site} uses your email address'
u' if you need to reset your password.'.format(
link=url, site=g.site_title))
elif not c.userobj.email:
msg = _('Please <a href="%s">update your profile</a>'
' and add your email address. ') % url + \
_('%s uses your email address'
' if you need to reset your password.') \
% g.site_title
elif is_google_id and not c.userobj.fullname:
msg = _('Please <a href="%s">update your profile</a>'
' and add your full name.') % (url)
if msg:
h.flash_notice(msg, allow_html=True)
msg = _('Please <a href="%s">update your profile</a>'
' and add your email address. ') % url + \
_('%s uses your email address'
' if you need to reset your password.') \
% g.site_title
h.flash_notice(msg, allow_html=True)

return base.render('home/index.html', cache_force=True)

Expand Down
53 changes: 53 additions & 0 deletions ckan/tests/controllers/test_home.py
@@ -0,0 +1,53 @@
from routes import url_for

from ckan.tests import factories
import ckan.tests.helpers as helpers


class TestHome(helpers.FunctionalTestBase):

def test_home_renders(self):
app = self._get_test_app()
response = app.get(url_for('home'))
assert 'Welcome to CKAN' in response.body

def test_template_head_end(self):
app = self._get_test_app()
# test-core.ini sets ckan.template_head_end to this:
test_link = '<link rel="stylesheet" ' \
'href="TEST_TEMPLATE_HEAD_END.css" type="text/css">'
response = app.get(url_for('home'))
assert test_link in response.body

def test_template_footer_end(self):
app = self._get_test_app()
# test-core.ini sets ckan.template_footer_end to this:
test_html = '<strong>TEST TEMPLATE_FOOTER_END TEST</strong>'
response = app.get(url_for('home'))
assert test_html in response.body

def test_email_address_nag(self):
# before CKAN 1.6, users were allowed to have no email addresses
app = self._get_test_app()
# can't use factory to create user as without email it fails validation
from ckan import model
model.repo.new_revision()
user = model.user.User(name='has-no-email')
model.Session.add(user)
model.Session.commit()
env = {'REMOTE_USER': user.name.encode('ascii')}

response = app.get(url=url_for('home'), extra_environ=env)

assert 'update your profile' in response.body
assert url_for(controller='user', action='edit') in response.body
assert ' and add your email address.' in response.body

def test_email_address_no_nag(self):
app = self._get_test_app()
user = factories.User(email='filled_in@nicely.com')
env = {'REMOTE_USER': user['name'].encode('ascii')}

response = app.get(url=url_for('home'), extra_environ=env)

assert 'add your email address' not in response
138 changes: 0 additions & 138 deletions ckan/tests/legacy/functional/test_home.py

This file was deleted.

0 comments on commit d9ebb7e

Please sign in to comment.