[ckan-changes] [okfn/ckan] 356cd3: Tidying up some template CSS classes.
GitHub
noreply at github.com
Thu Apr 26 10:19:03 UTC 2012
Branch: refs/heads/master
Home: https://github.com/okfn/ckan
Commit: 356cd32fea9af5a1dc17004802e2033d06fc7f2f
https://github.com/okfn/ckan/commit/356cd32fea9af5a1dc17004802e2033d06fc7f2f
Author: Tom Rees <zephod at gmail.com>
Date: 2012-04-19 (Thu, 19 Apr 2012)
Changed paths:
M ckan/templates/tag/index.html
M ckan/templates/user/list.html
M ckan/templates/user/login.html
M ckan/templates/user/logout.html
Log Message:
-----------
Tidying up some template CSS classes.
diff --git a/ckan/templates/tag/index.html b/ckan/templates/tag/index.html
index 9aa3d61..50e44f7 100644
--- a/ckan/templates/tag/index.html
+++ b/ckan/templates/tag/index.html
@@ -8,9 +8,9 @@
<div py:match="content">
<h2>Tags</h2>
- <form id="tag-search" action="" method="GET">
+ <form class="form-inline" id="tag-search" action="" method="GET">
<input type="text" id="q" name="q" value="${c.q}" />
- <input type="submit" name="search" value="Search »" />
+ <input class="btn btn-primary" type="submit" name="search" value="Search »" />
</form>
<hr />
diff --git a/ckan/templates/user/list.html b/ckan/templates/user/list.html
index 2213db8..712b100 100644
--- a/ckan/templates/user/list.html
+++ b/ckan/templates/user/list.html
@@ -8,9 +8,10 @@
<py:match path="primarysidebar">
<li class="widget-container widget_text">
- <form id="user-search" class="user-search" action="" method="GET">
- <input type="text" id="q" name="q" value="${c.q}" />
- <input type="submit" class="btn btn-small" name="" value="Search »" />
+ <h3>Search Users</h3>
+ <form id="user-search" class="form-inline user-search" action="" method="GET">
+ <input type="text" class="input-medium" id="q" name="q" value="${c.q}" />
+ <input type="submit" class="btn btn-small btn-primary" name="" value="Search »" />
</form>
<p py:if="c.q" i18n:msg="item_count">
<strong>${c.page.item_count}</strong> users found.
diff --git a/ckan/templates/user/login.html b/ckan/templates/user/login.html
index 9efdb87..85fcc59 100644
--- a/ckan/templates/user/login.html
+++ b/ckan/templates/user/login.html
@@ -18,25 +18,33 @@
<py:def function="page_title">Login - User</py:def>
<py:def function="page_heading">Login to ${g.site_title}</py:def>
+ <py:def function="body_class">no-sidebar</py:def>
<div py:match="content">
- <form action="${h.url_for('/login_generic')}" method="post" class="simple-form" id="login">
+ <form action="${h.url_for('/login_generic')}" method="post" class="form-horizontal" id="login">
<fieldset>
<!--legend i18n:msg="site_title">Login</legend-->
-
- <label for="login">Login:</label>
- <input type="text" name="login" value="" />
- <br/>
- <label for="password">Password:</label>
- <input type="password" name="password" value="" />
+ <div class="control-group">
+ <label class="control-label" for="login">Login:</label>
+ <div class="controls">
+ <input type="text" name="login" value="" />
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="password">Password:</label>
+ <div class="controls">
+ <input type="password" name="password" value="" />
+ </div>
+ </div>
<!-- 50 year timeout -->
<input type="hidden" name="remember" value="1576800000" />
- <br/>
</fieldset>
- <input name="s" id="s" type="submit" class="btn primary" value="Sign In"/>
- —
- <a href="${h.url_for('reset')}">Forgot your password?</a>
+ <div class="form-actions">
+ <input name="s" id="s" type="submit" class="btn btn-primary" value="Sign In"/>
+ —
+ <a href="${h.url_for('reset')}">Forgot your password?</a>
+ </div>
</form>
<br/>
<!-- Simple OpenID Selector -->
diff --git a/ckan/templates/user/logout.html b/ckan/templates/user/logout.html
index e40ec5c..0f37272 100644
--- a/ckan/templates/user/logout.html
+++ b/ckan/templates/user/logout.html
@@ -6,6 +6,7 @@
<py:def function="page_title">Logout</py:def>
<py:def function="page_heading">Logout from ${g.site_title}</py:def>
+ <py:def function="body_class">no-sidebar</py:def>
<div py:match="content">
<p>You have logged out successfully.</p>
================================================================
Commit: b23b35748ab3bd78cfd841423ccbec53a297331c
https://github.com/okfn/ckan/commit/b23b35748ab3bd78cfd841423ccbec53a297331c
Author: David Read <david.read at okfn.org>
Date: 2012-04-20 (Fri, 20 Apr 2012)
Changed paths:
M ckan/templates/user/login.html
M ckan/tests/functional/test_user.py
Log Message:
-----------
[release-v1.6.1][#2315]: Changed cookie expirt default to 2 years (from 50) and give option to just be session length.
diff --git a/ckan/templates/user/login.html b/ckan/templates/user/login.html
index 9efdb87..7b646b9 100644
--- a/ckan/templates/user/login.html
+++ b/ckan/templates/user/login.html
@@ -20,23 +20,36 @@
<py:def function="page_heading">Login to ${g.site_title}</py:def>
<div py:match="content">
-
- <form action="${h.url_for('/login_generic')}" method="post" class="simple-form" id="login">
+
+ <form action="${h.url_for('/login_generic')}" method="post" class="form-horizontal" id="login">
<fieldset>
<!--legend i18n:msg="site_title">Login</legend-->
+ <div class="control-group">
+ <label class="control-label" for="login">Login:</label>
+ <div class="controls">
+ <input type="text" class="input-xlarge" name="login" id="login" value="" />
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="password">Password:</label>
+ <div class="controls">
+ <input type="password" name="password" id="password" value="" />
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="remember">Remember me:</label>
+ <!-- optional 2 year cookie expiry -->
+ <div class="controls">
+ <input type="checkbox" name="remember" id="remember" value="63072000" checked="checked"/>
+ </div>
+ </div>
- <label for="login">Login:</label>
- <input type="text" name="login" value="" />
- <br/>
- <label for="password">Password:</label>
- <input type="password" name="password" value="" />
- <!-- 50 year timeout -->
- <input type="hidden" name="remember" value="1576800000" />
- <br/>
+ <div class="form-actions">
+ <button name="s" id="s" type="submit" class="btn btn-primary">Sign In</button>
+ —
+ <a href="${h.url_for('reset')}">Forgot your password?</a>
+ </div>
</fieldset>
- <input name="s" id="s" type="submit" class="btn primary" value="Sign In"/>
- —
- <a href="${h.url_for('reset')}">Forgot your password?</a>
</form>
<br/>
<!-- Simple OpenID Selector -->
diff --git a/ckan/tests/functional/test_user.py b/ckan/tests/functional/test_user.py
index 5ab1efc..eb44bd9 100644
--- a/ckan/tests/functional/test_user.py
+++ b/ckan/tests/functional/test_user.py
@@ -168,11 +168,14 @@ def test_login(self):
fv = res.forms['login']
fv['login'] = str(username)
fv['password'] = str(password)
+ fv['remember'] = False
res = fv.submit()
# check cookies set
cookies = self._get_cookie_headers(res)
assert cookies
+ for cookie in cookies:
+ assert not 'max-age' in cookie.lower(), cookie
# first get redirected to user/logged_in
assert_equal(res.status, 302)
@@ -206,6 +209,32 @@ def test_login(self):
print res
assert 'testlogin' in res.body, res.body
+ def test_login_remembered(self):
+ # create test user
+ username = u'testlogin2'
+ password = u'letmein'
+ CreateTestData.create_user(name=username,
+ password=password)
+ user = model.User.by_name(username)
+
+ # do the login
+ offset = url_for(controller='user', action='login')
+ res = self.app.get(offset)
+ fv = res.forms['login']
+ fv['login'] = str(username)
+ fv['password'] = str(password)
+ fv['remember'] = True
+ res = fv.submit()
+
+ # check cookies set
+ cookies = self._get_cookie_headers(res)
+ assert cookies
+ # check cookie is remembered via Max-Age and Expires
+ # (both needed for cross-browser compatibility)
+ for cookie in cookies:
+ assert 'Max-Age=63072000;' in cookie, cookie
+ assert 'Expires=' in cookie, cookie
+
def test_login_wrong_password(self):
# create test user
username = u'testloginwrong'
================================================================
Commit: 879c424f4a879a1e044d523cecf0addcc5cbd75e
https://github.com/okfn/ckan/commit/879c424f4a879a1e044d523cecf0addcc5cbd75e
Author: David Read <david.read at okfn.org>
Date: 2012-04-20 (Fri, 20 Apr 2012)
Changed paths:
M ckan/templates/tag/index.html
M ckan/templates/user/list.html
M ckan/templates/user/login.html
M ckan/templates/user/logout.html
Log Message:
-----------
[merge]
diff --git a/ckan/templates/tag/index.html b/ckan/templates/tag/index.html
index 9aa3d61..50e44f7 100644
--- a/ckan/templates/tag/index.html
+++ b/ckan/templates/tag/index.html
@@ -8,9 +8,9 @@
<div py:match="content">
<h2>Tags</h2>
- <form id="tag-search" action="" method="GET">
+ <form class="form-inline" id="tag-search" action="" method="GET">
<input type="text" id="q" name="q" value="${c.q}" />
- <input type="submit" name="search" value="Search »" />
+ <input class="btn btn-primary" type="submit" name="search" value="Search »" />
</form>
<hr />
diff --git a/ckan/templates/user/list.html b/ckan/templates/user/list.html
index 2213db8..712b100 100644
--- a/ckan/templates/user/list.html
+++ b/ckan/templates/user/list.html
@@ -8,9 +8,10 @@
<py:match path="primarysidebar">
<li class="widget-container widget_text">
- <form id="user-search" class="user-search" action="" method="GET">
- <input type="text" id="q" name="q" value="${c.q}" />
- <input type="submit" class="btn btn-small" name="" value="Search »" />
+ <h3>Search Users</h3>
+ <form id="user-search" class="form-inline user-search" action="" method="GET">
+ <input type="text" class="input-medium" id="q" name="q" value="${c.q}" />
+ <input type="submit" class="btn btn-small btn-primary" name="" value="Search »" />
</form>
<p py:if="c.q" i18n:msg="item_count">
<strong>${c.page.item_count}</strong> users found.
diff --git a/ckan/templates/user/login.html b/ckan/templates/user/login.html
index 7b646b9..9d4c365 100644
--- a/ckan/templates/user/login.html
+++ b/ckan/templates/user/login.html
@@ -18,6 +18,7 @@
<py:def function="page_title">Login - User</py:def>
<py:def function="page_heading">Login to ${g.site_title}</py:def>
+ <py:def function="body_class">no-sidebar</py:def>
<div py:match="content">
diff --git a/ckan/templates/user/logout.html b/ckan/templates/user/logout.html
index e40ec5c..0f37272 100644
--- a/ckan/templates/user/logout.html
+++ b/ckan/templates/user/logout.html
@@ -6,6 +6,7 @@
<py:def function="page_title">Logout</py:def>
<py:def function="page_heading">Logout from ${g.site_title}</py:def>
+ <py:def function="body_class">no-sidebar</py:def>
<div py:match="content">
<p>You have logged out successfully.</p>
================================================================
Commit: 6343a9c86ba3a914702d6f5dabb560db45692915
https://github.com/okfn/ckan/commit/6343a9c86ba3a914702d6f5dabb560db45692915
Author: David Read <david.read at okfn.org>
Date: 2012-04-25 (Wed, 25 Apr 2012)
Changed paths:
M ckan/lib/alphabet_paginate.py
M ckan/public/css/style.css
M ckan/tests/lib/test_alphabet_pagination.py
Log Message:
-----------
[release-v1.6.1][#2325]: Bootstrapify alphabet pager. Cleaned out old non-bootstrap pager CSS.
diff --git a/ckan/lib/alphabet_paginate.py b/ckan/lib/alphabet_paginate.py
index 0afa88f..b75bf27 100644
--- a/ckan/lib/alphabet_paginate.py
+++ b/ckan/lib/alphabet_paginate.py
@@ -1,6 +1,7 @@
'''
-Based on webhelpers.paginator, but each page is for items beginning
- with a particular letter.
+Based on webhelpers.paginator, but:
+ * each page is for items beginning with a particular letter
+ * output is suitable for Bootstrap
Example:
c.page = h.Page(
@@ -43,7 +44,12 @@ def __init__(self, collection, alpha_attribute, page, other_text, paging_thresho
self.other_text = other_text
self.paging_threshold = paging_threshold
self.controller_name = controller_name
- self.available = dict( (c,0,) for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" )
+
+ self.letters = [char for char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'] + [self.other_text]
+
+ # Work out which alphabet letters are 'available' i.e. have some results
+ # because we grey-out those which aren't.
+ self.available = dict( (c,0,) for c in self.letters )
for c in self.collection:
if isinstance(c, unicode):
x = c[0]
@@ -51,35 +57,42 @@ def __init__(self, collection, alpha_attribute, page, other_text, paging_thresho
x = c[self.alpha_attribute][0]
else:
x = getattr(c, self.alpha_attribute)[0]
+ x = x.upper()
+ if x not in self.letters:
+ x = self.other_text
self.available[x] = self.available.get(x, 0) + 1
def pager(self, q=None):
'''Returns pager html - for navigating between the pages.
e.g. Something like this:
- <div class='pager'>
- <span class="pager_curpage">A</span>
- <a class="pager_link" href="/package/list?page=B">B</a>
- <a class="pager_link" href="/package/list?page=C">C</a>
+ <ul class='pagination pagination-alphabet'>
+ <li class="active"><a href="/package/list?page=A">A</a></li>
+ <li><a href="/package/list?page=B">B</a></li>
+ <li><a href="/package/list?page=C">C</a></li>
...
- <a class="pager_link" href="/package/list?page=Z">Z</a
- <a class="pager_link" href="/package/list?page=Other">Other</a
- </div>
+ <li class="disabled"><a href="/package/list?page=Z">Z</a></li>
+ <li><a href="/package/list?page=Other">Other</a></li>
+ </ul>
'''
if self.item_count < self.paging_threshold:
return ''
pages = []
page = q or self.page
- letters = [char for char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'] + [self.other_text]
- for letter in letters:
+ for letter in self.letters:
+ href = url_for(controller=self.controller_name, action='index', page=letter)
+ link = HTML.a(href=href, c=letter)
if letter != page:
if self.available.get(letter, 0):
- page_element = HTML.a(class_='pager_link', href=url_for(controller=self.controller_name, action='index', page=letter),c=letter)
+ li_class = ''
else:
- page_element = HTML.span(class_="pager_empty", c=letter)
+ li_class = 'disabled'
else:
- page_element = HTML.span(class_='pager_curpage', c=letter)
+ li_class = 'active'
+ attributes = {'class_': li_class} if li_class else {}
+ page_element = HTML.li(link, **attributes)
pages.append(page_element)
- div = HTML.tag('div', class_='pager', *pages)
+ ul = HTML.tag('ul', *pages)
+ div = HTML.div(ul, class_='pagination pagination-alphabet')
return div
diff --git a/ckan/public/css/style.css b/ckan/public/css/style.css
index dffb4d6..c0a3e92 100644
--- a/ckan/public/css/style.css
+++ b/ckan/public/css/style.css
@@ -430,28 +430,8 @@ ul.no-break li {
/* ============== */
/* = Pagination = */
/* ============== */
-.pager {
- width: 100%;
- text-align: center;
- margin: 0 0 1.2em 0;
- clear: both;
-}
-.pager span, .pager a {
- text-decoration: none;
- margin: 0em;
- border: none;
- padding: 0.3em 0.1em;
-}
-.pager a:hover, .pager a:active {
- color: #fff;
- background-color: #c22;
-}
-.pager span.pager_dotdot {
- color: #aaa;
-}
-.pager span.pager_curpage {
- font-weight: bold;
- border: 1px solid #ddd;
+.pagination-alphabet a {
+ padding: 0 6px;
}
/* ====== */
diff --git a/ckan/tests/lib/test_alphabet_pagination.py b/ckan/tests/lib/test_alphabet_pagination.py
index a1bf6ae..8afc276 100644
--- a/ckan/tests/lib/test_alphabet_pagination.py
+++ b/ckan/tests/lib/test_alphabet_pagination.py
@@ -1,5 +1,7 @@
import re
+from nose.tools import assert_equal
+
from ckan.tests import *
from ckan.tests import regex_related
from ckan.lib.create_test_data import CreateTestData
@@ -28,6 +30,16 @@ def setup_class(cls):
def teardown_class(cls):
model.repo.rebuild_db()
+ def test_00_model(self):
+ query = model.Session.query(model.Package)
+ page = h.AlphaPage(
+ collection=query,
+ alpha_attribute='title',
+ page='A',
+ other_text=other,
+ )
+ assert_equal(page.available, {'Other': 20, 'A': 10, 'C': 10, 'B': 10, 'E': 0, 'D': 10, 'G': 0, 'F': 0, 'I': 0, 'H': 0, 'K': 0, 'J': 0, 'M': 0, 'L': 0, 'O': 0, 'N': 0, 'Q': 0, 'P': 0, 'S': 0, 'R': 0, 'U': 0, 'T': 0, 'W': 0, 'V': 0, 'Y': 0, 'X': 0, 'Z': 0})
+
def test_01_package_page(self):
query = model.Session.query(model.Package)
page = h.AlphaPage(
@@ -37,11 +49,12 @@ def test_01_package_page(self):
other_text=other,
)
pager = page.pager()
- assert pager.startswith('<div class="pager">'), pager
- assert '<span class="pager_curpage">A</span>' in pager, pager
+ assert pager.startswith('<div class="pagination pagination-alphabet">'), pager
+ assert '<li class="active"><a href="/tag?page=A">A</a></li>' in pager, pager
url_base = '/packages'
- assert re.search('\<span class="pager_empty"\>B\<\/span\>', pager), pager
- assert re.search('\<span class="pager_empty"\>Other\<\/span\>', pager), pager
+ assert re.search(r'\<li\>\<a href="\/tag\?page=B"\>B\<\/a\>\<\/li\>', pager), pager
+ assert re.search(r'\<li class="disabled"\>\<a href="\/tag\?page=E"\>E\<\/a\>\<\/li\>', pager), pager
+ assert re.search(r'\<li\>\<a href="\/tag\?page=Other"\>Other\<\/a\>\<\/li\>', pager), pager
def test_02_package_items(self):
================================================================
Commit: ddba520f9751fe3004a7978c5bdb1b4da3fc7749
https://github.com/okfn/ckan/commit/ddba520f9751fe3004a7978c5bdb1b4da3fc7749
Author: David Read <david.read at okfn.org>
Date: 2012-04-26 (Thu, 26 Apr 2012)
Changed paths:
M ckan/lib/alphabet_paginate.py
M ckan/public/css/style.css
M ckan/templates/tag/index.html
M ckan/templates/user/list.html
M ckan/templates/user/login.html
M ckan/templates/user/logout.html
M ckan/tests/functional/test_user.py
M ckan/tests/lib/test_alphabet_pagination.py
Log Message:
-----------
[merge] from release-v1.6.1.
diff --git a/ckan/lib/alphabet_paginate.py b/ckan/lib/alphabet_paginate.py
index 0afa88f..b75bf27 100644
--- a/ckan/lib/alphabet_paginate.py
+++ b/ckan/lib/alphabet_paginate.py
@@ -1,6 +1,7 @@
'''
-Based on webhelpers.paginator, but each page is for items beginning
- with a particular letter.
+Based on webhelpers.paginator, but:
+ * each page is for items beginning with a particular letter
+ * output is suitable for Bootstrap
Example:
c.page = h.Page(
@@ -43,7 +44,12 @@ def __init__(self, collection, alpha_attribute, page, other_text, paging_thresho
self.other_text = other_text
self.paging_threshold = paging_threshold
self.controller_name = controller_name
- self.available = dict( (c,0,) for c in "ABCDEFGHIJKLMNOPQRSTUVWXYZ" )
+
+ self.letters = [char for char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'] + [self.other_text]
+
+ # Work out which alphabet letters are 'available' i.e. have some results
+ # because we grey-out those which aren't.
+ self.available = dict( (c,0,) for c in self.letters )
for c in self.collection:
if isinstance(c, unicode):
x = c[0]
@@ -51,35 +57,42 @@ def __init__(self, collection, alpha_attribute, page, other_text, paging_thresho
x = c[self.alpha_attribute][0]
else:
x = getattr(c, self.alpha_attribute)[0]
+ x = x.upper()
+ if x not in self.letters:
+ x = self.other_text
self.available[x] = self.available.get(x, 0) + 1
def pager(self, q=None):
'''Returns pager html - for navigating between the pages.
e.g. Something like this:
- <div class='pager'>
- <span class="pager_curpage">A</span>
- <a class="pager_link" href="/package/list?page=B">B</a>
- <a class="pager_link" href="/package/list?page=C">C</a>
+ <ul class='pagination pagination-alphabet'>
+ <li class="active"><a href="/package/list?page=A">A</a></li>
+ <li><a href="/package/list?page=B">B</a></li>
+ <li><a href="/package/list?page=C">C</a></li>
...
- <a class="pager_link" href="/package/list?page=Z">Z</a
- <a class="pager_link" href="/package/list?page=Other">Other</a
- </div>
+ <li class="disabled"><a href="/package/list?page=Z">Z</a></li>
+ <li><a href="/package/list?page=Other">Other</a></li>
+ </ul>
'''
if self.item_count < self.paging_threshold:
return ''
pages = []
page = q or self.page
- letters = [char for char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'] + [self.other_text]
- for letter in letters:
+ for letter in self.letters:
+ href = url_for(controller=self.controller_name, action='index', page=letter)
+ link = HTML.a(href=href, c=letter)
if letter != page:
if self.available.get(letter, 0):
- page_element = HTML.a(class_='pager_link', href=url_for(controller=self.controller_name, action='index', page=letter),c=letter)
+ li_class = ''
else:
- page_element = HTML.span(class_="pager_empty", c=letter)
+ li_class = 'disabled'
else:
- page_element = HTML.span(class_='pager_curpage', c=letter)
+ li_class = 'active'
+ attributes = {'class_': li_class} if li_class else {}
+ page_element = HTML.li(link, **attributes)
pages.append(page_element)
- div = HTML.tag('div', class_='pager', *pages)
+ ul = HTML.tag('ul', *pages)
+ div = HTML.div(ul, class_='pagination pagination-alphabet')
return div
diff --git a/ckan/public/css/style.css b/ckan/public/css/style.css
index 7e9e609..283f5d3 100644
--- a/ckan/public/css/style.css
+++ b/ckan/public/css/style.css
@@ -379,28 +379,8 @@ ul.no-break li {
/* ============== */
/* = Pagination = */
/* ============== */
-.pager {
- width: 100%;
- text-align: center;
- margin: 0 0 1.2em 0;
- clear: both;
-}
-.pager span, .pager a {
- text-decoration: none;
- margin: 0em;
- border: none;
- padding: 0.3em 0.1em;
-}
-.pager a:hover, .pager a:active {
- color: #fff;
- background-color: #c22;
-}
-.pager span.pager_dotdot {
- color: #aaa;
-}
-.pager span.pager_curpage {
- font-weight: bold;
- border: 1px solid #ddd;
+.pagination-alphabet a {
+ padding: 0 6px;
}
/* ====== */
diff --git a/ckan/templates/tag/index.html b/ckan/templates/tag/index.html
index 17292e9..8c383c8 100644
--- a/ckan/templates/tag/index.html
+++ b/ckan/templates/tag/index.html
@@ -8,9 +8,9 @@
<div py:match="content">
<h2>Tags</h2>
- <form id="tag-search" action="" method="GET">
+ <form class="form-inline" id="tag-search" action="" method="GET">
<input type="text" id="q" name="q" value="${c.q}" />
- <input type="submit" name="search" value="${_('Search')} »" />
+ <input class="btn btn-primary" type="submit" name="search" value="${_('Search')} »" />
</form>
<hr />
diff --git a/ckan/templates/user/list.html b/ckan/templates/user/list.html
index 3c736b4..1ef2655 100644
--- a/ckan/templates/user/list.html
+++ b/ckan/templates/user/list.html
@@ -8,9 +8,10 @@
<py:match path="primarysidebar">
<li class="widget-container widget_text">
- <form id="user-search" class="user-search" action="" method="GET">
- <input type="text" id="q" name="q" value="${c.q}" />
- <input type="submit" class="btn btn-small" name="" value="${_('Search')} »" />
+ <h3>Search Users</h3>
+ <form id="user-search" class="form-inline user-search" action="" method="GET">
+ <input type="text" class="input-medium" id="q" name="q" value="${c.q}" />
+ <input type="submit" class="btn btn-small btn-primary" name="" value="${_('Search')} »" />
</form>
<p py:if="c.q" i18n:msg="item_count">
<strong>${c.page.item_count}</strong> users found.
diff --git a/ckan/templates/user/login.html b/ckan/templates/user/login.html
index 6cabb81..9fdf3df 100644
--- a/ckan/templates/user/login.html
+++ b/ckan/templates/user/login.html
@@ -18,25 +18,39 @@
<py:def function="page_title">Login - User</py:def>
<py:def function="page_heading">Login to ${g.site_title}</py:def>
+ <py:def function="body_class">no-sidebar</py:def>
<div py:match="content">
-
- <form action="${h.url_for('/login_generic')}" method="post" class="simple-form" id="login">
+
+ <form action="${h.url_for('/login_generic')}" method="post" class="form-horizontal" id="login">
<fieldset>
<!--legend i18n:msg="site_title">Login</legend-->
+ <div class="control-group">
+ <label class="control-label" for="login">Login:</label>
+ <div class="controls">
+ <input type="text" class="input-xlarge" name="login" id="login" value="" />
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="password">Password:</label>
+ <div class="controls">
+ <input type="password" name="password" id="password" value="" />
+ </div>
+ </div>
+ <div class="control-group">
+ <label class="control-label" for="remember">Remember me:</label>
+ <!-- optional 2 year cookie expiry -->
+ <div class="controls">
+ <input type="checkbox" name="remember" id="remember" value="63072000" checked="checked"/>
+ </div>
+ </div>
- <label for="login">Login:</label>
- <input type="text" name="login" value="" />
- <br/>
- <label for="password">Password:</label>
- <input type="password" name="password" value="" />
- <!-- 50 year timeout -->
- <input type="hidden" name="remember" value="1576800000" />
- <br/>
+ <div class="form-actions">
+ <button name="s" id="s" type="submit" class="btn btn-primary">${_('Sign In')}</button>
+ —
+ <a href="${h.url_for('reset')}">Forgot your password?</a>
+ </div>
</fieldset>
- <input name="s" id="s" type="submit" class="btn primary" value="${_('Sign In')}"/>
- —
- <a href="${h.url_for(controller='user', action='request_reset')}">Forgot your password?</a>
</form>
<br/>
<!-- Simple OpenID Selector -->
diff --git a/ckan/templates/user/logout.html b/ckan/templates/user/logout.html
index e40ec5c..0f37272 100644
--- a/ckan/templates/user/logout.html
+++ b/ckan/templates/user/logout.html
@@ -6,6 +6,7 @@
<py:def function="page_title">Logout</py:def>
<py:def function="page_heading">Logout from ${g.site_title}</py:def>
+ <py:def function="body_class">no-sidebar</py:def>
<div py:match="content">
<p>You have logged out successfully.</p>
diff --git a/ckan/tests/functional/test_user.py b/ckan/tests/functional/test_user.py
index 5ab1efc..eb44bd9 100644
--- a/ckan/tests/functional/test_user.py
+++ b/ckan/tests/functional/test_user.py
@@ -168,11 +168,14 @@ def test_login(self):
fv = res.forms['login']
fv['login'] = str(username)
fv['password'] = str(password)
+ fv['remember'] = False
res = fv.submit()
# check cookies set
cookies = self._get_cookie_headers(res)
assert cookies
+ for cookie in cookies:
+ assert not 'max-age' in cookie.lower(), cookie
# first get redirected to user/logged_in
assert_equal(res.status, 302)
@@ -206,6 +209,32 @@ def test_login(self):
print res
assert 'testlogin' in res.body, res.body
+ def test_login_remembered(self):
+ # create test user
+ username = u'testlogin2'
+ password = u'letmein'
+ CreateTestData.create_user(name=username,
+ password=password)
+ user = model.User.by_name(username)
+
+ # do the login
+ offset = url_for(controller='user', action='login')
+ res = self.app.get(offset)
+ fv = res.forms['login']
+ fv['login'] = str(username)
+ fv['password'] = str(password)
+ fv['remember'] = True
+ res = fv.submit()
+
+ # check cookies set
+ cookies = self._get_cookie_headers(res)
+ assert cookies
+ # check cookie is remembered via Max-Age and Expires
+ # (both needed for cross-browser compatibility)
+ for cookie in cookies:
+ assert 'Max-Age=63072000;' in cookie, cookie
+ assert 'Expires=' in cookie, cookie
+
def test_login_wrong_password(self):
# create test user
username = u'testloginwrong'
diff --git a/ckan/tests/lib/test_alphabet_pagination.py b/ckan/tests/lib/test_alphabet_pagination.py
index a1bf6ae..8afc276 100644
--- a/ckan/tests/lib/test_alphabet_pagination.py
+++ b/ckan/tests/lib/test_alphabet_pagination.py
@@ -1,5 +1,7 @@
import re
+from nose.tools import assert_equal
+
from ckan.tests import *
from ckan.tests import regex_related
from ckan.lib.create_test_data import CreateTestData
@@ -28,6 +30,16 @@ def setup_class(cls):
def teardown_class(cls):
model.repo.rebuild_db()
+ def test_00_model(self):
+ query = model.Session.query(model.Package)
+ page = h.AlphaPage(
+ collection=query,
+ alpha_attribute='title',
+ page='A',
+ other_text=other,
+ )
+ assert_equal(page.available, {'Other': 20, 'A': 10, 'C': 10, 'B': 10, 'E': 0, 'D': 10, 'G': 0, 'F': 0, 'I': 0, 'H': 0, 'K': 0, 'J': 0, 'M': 0, 'L': 0, 'O': 0, 'N': 0, 'Q': 0, 'P': 0, 'S': 0, 'R': 0, 'U': 0, 'T': 0, 'W': 0, 'V': 0, 'Y': 0, 'X': 0, 'Z': 0})
+
def test_01_package_page(self):
query = model.Session.query(model.Package)
page = h.AlphaPage(
@@ -37,11 +49,12 @@ def test_01_package_page(self):
other_text=other,
)
pager = page.pager()
- assert pager.startswith('<div class="pager">'), pager
- assert '<span class="pager_curpage">A</span>' in pager, pager
+ assert pager.startswith('<div class="pagination pagination-alphabet">'), pager
+ assert '<li class="active"><a href="/tag?page=A">A</a></li>' in pager, pager
url_base = '/packages'
- assert re.search('\<span class="pager_empty"\>B\<\/span\>', pager), pager
- assert re.search('\<span class="pager_empty"\>Other\<\/span\>', pager), pager
+ assert re.search(r'\<li\>\<a href="\/tag\?page=B"\>B\<\/a\>\<\/li\>', pager), pager
+ assert re.search(r'\<li class="disabled"\>\<a href="\/tag\?page=E"\>E\<\/a\>\<\/li\>', pager), pager
+ assert re.search(r'\<li\>\<a href="\/tag\?page=Other"\>Other\<\/a\>\<\/li\>', pager), pager
def test_02_package_items(self):
================================================================
Compare: https://github.com/okfn/ckan/compare/37bf214...ddba520
More information about the ckan-changes
mailing list