Skip to content

Commit

Permalink
[user][s]: convert 'account' to 'user' throughout wui (first part of …
Browse files Browse the repository at this point in the history
…ticket:111).
  • Loading branch information
rufuspollock committed Sep 7, 2009
1 parent 2f5f45c commit 0a57ae7
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 39 deletions.
20 changes: 10 additions & 10 deletions ckan/controllers/account.py → ckan/controllers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@
from ckan.controllers.base import CkanBaseController

def login_form():
return render('account/login_form').replace('FORM_ACTION', '%s')
return render('user/login_form').replace('FORM_ACTION', '%s')

class AccountController(CkanBaseController):
class UserController(CkanBaseController):

def index(self):
if not c.user:
h.redirect_to(controller='account', action='login', id=None)
h.redirect_to(controller='user', action='login', id=None)
else:
q = model.Revision.query.filter_by(author=c.user).limit(20)
c.activity = q.limit(20).all()
return render('account/index')
return render('user/index')

# def login_form(self, return_url=''):
# return render('account/login_form')
# return render('user/login_form')
#
# def openid_form(self, return_url=''):
# return render('account/openid_form').replace('DOLAR', '$')
# return render('user/openid_form').replace('DOLAR', '$')
#
def login(self):
if c.user:
h.redirect_to(controller='account', action=None, id=None)
h.redirect_to(controller='user', action=None, id=None)
else:
form = render('account/openid_form')
form = render('user/openid_form')
# /login_openid page need not exist -- request gets intercepted by openid plugin
form = form.replace('FORM_ACTION', '/login_openid')
return form

def logout(self):
c.user = None
return render('account/logout')
return render('user/logout')

def apikey(self):
# logged in
Expand All @@ -44,5 +44,5 @@ def apikey(self):
apikey_object = model.ApiKey(name=username)
model.Session.commit()
c.api_key = apikey_object.key
return render('account/apikey')
return render('user/apikey')

14 changes: 2 additions & 12 deletions ckan/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
<py:when test="c.user">
<p>
Logged in as <strong>${c.user}</strong> |
<a href="/account/">My Account</a>
<a href="${h.url_for(controller='user',action=None)}">My Account</a>
| <a href="${h.url_for('/logout_openid')}">Logout</a>
</p>
</py:when>
<py:otherwise>
<p>
<a href="/account/login/">Login via OpenID</a>
<a href="${h.url_for(controller='user',action='login')}">Login via OpenID</a>
</p>
</py:otherwise>
</py:choose>
Expand All @@ -78,21 +78,11 @@ <h3 class="hidden">Sections:</h3>
<li><a href="/revision/">Recent Changes</a></li>
<li><a href="/api/rest/">API</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/account/">User Accounts</a></li>
</ul>
<h3 class="hidden">In this section:</h3>
<ul id="subnav">
<minornavigation>
<li><a href="/">Home</a></li>
<py:choose>
<py:when test="c.user">
<li><a href="/account/logout/">Logout</a></li>
</py:when>
<py:otherwise>
<li><a href="/account/">Register</a></li>
<li><a href="/account/login/">Login</a></li>
</py:otherwise>
</py:choose>
<li><a href="/package/new/">New Package</a></li>
</minornavigation>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/package/edit_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<label>Author: ${c.author}</label>
<p class="desc">
If you have not signed in this will just be your IP address.<br />
<a href="${h.url_for(controller='account',action='login',id=None)}" target="_blank">Click here to sign in</a> before submitting (opens in new window).
<a href="${h.url_for(controller='user',action='login',id=None)}" target="_blank">Click here to sign in</a> before submitting (opens in new window).
</p>

<input name="preview" type="submit" value="Preview" />
Expand Down
4 changes: 2 additions & 2 deletions ckan/templates/rest/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ <h3>API Keys</h3>
<p>For any action which makes a change to a resource (i.e. all non-GET methods)
you will require an API key. To obtain your API key:</p>
<ol>
<li><a href="${h.url_for(controller='account', action=None)}">Login as a normal user</a>.</li>
<li><a href="${h.url_for(controller='account', action='apikey')}">Visit the API Key page</a>.</li>
<li><a href="${h.url_for(controller='user', action=None)}">Login as a normal user</a>.</li>
<li><a href="${h.url_for(controller='user', action='apikey')}">Visit the API Key page</a>.</li>
</ol>


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h2>My Account</h2>
<p>To logout <a href="${h.url_for('/logout_openid')}">
click here</a>.</p>

<p>To view your API key <a href="${h.url_for(controller='account', action='apikey')}">
<p>To view your API key <a href="${h.url_for(controller='user', action='apikey')}">
click here</a>.</p>

<h3>Your Recent Activity</h3>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
from ckan.tests import *
import ckan.model as model

class TestAccountController(TestController2):
class TestUserController(TestController2):

def test_account_not_logged_in(self):
offset = url_for(controller='account')
def test_user_not_logged_in(self):
offset = url_for(controller='user')
# not logged in, so should redirect to
res = self.app.get(offset, status=302)
res = res.follow()
assert 'Login' in res, res

def test_account_logged_in(self):
offset = url_for(controller='account')
def test_user_logged_in(self):
offset = url_for(controller='user')
username = 'xyz.com'
res = self.app.get(offset, extra_environ={'REMOTE_USER': username})
assert 'My Account' in res, res
assert 'You are logged in as: <strong>%s</strong>' % username in res
assert 'To view your API key' in res
assert 'Your Recent Activity' in res

def test_account_login(self):
offset = url_for(controller='account', action='login')
def test_user_login(self):
offset = url_for(controller='user', action='login')
res = self.app.get(offset, status=200)
assert 'Login' in res, res
assert 'use your OpenID' in res
Expand Down Expand Up @@ -72,7 +72,7 @@ def _login_openid(self, res):
return res

def test_logout(self):
offset = url_for(controller='account', action='logout')
offset = url_for(controller='user', action='logout')
res = self.app.get(offset)
assert 'You have logged out successfully.' in res

Expand All @@ -84,7 +84,7 @@ def test_home_login(self):
res = self.app.get(offset)
# cannot use click because it does not allow a 401 response ...
# could get round this by checking that url is correct and then doing a
# get but then we are back to test_account_login
# get but then we are back to test_user_login
# res = res.click('Login', index=0)
# assert 'Please Sign In' in res

Expand All @@ -100,7 +100,7 @@ def test_apikey(self):
model.Session.commit()
model.Session.remove()

offset = url_for(controller='account', action='apikey')
offset = url_for(controller='user', action='apikey')
res = self.app.get(offset, status=[302])

res = self.app.get(offset, extra_environ=dict(REMOTE_USER='okfntest'))
Expand Down
6 changes: 3 additions & 3 deletions who.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ openid_field = openid
came_from_field = came_from
error_field = error
session_name = beaker.session
login_form_url = /account/login
login_form_url = /user/login
login_handler_path = /login_openid
logout_handler_path = /logout_openid
logged_in_url = /account
logged_out_url = /account/logout
logged_in_url = /user
logged_out_url = /user/logout
rememberer_name = auth_tkt

[general]
Expand Down

0 comments on commit 0a57ae7

Please sign in to comment.