# Self-admin
map.connect('/users/{id};{name}/edit', controller='users', action='profile_edit')
- # Public per-user pages
+ # Public user pages
+ map.connect('/users', controller='users', action='list')
map.connect('/users/{id};{name}', controller='users', action='profile')
map.connect('/users/{id}', controller='users', action='profile')
class UsersController(BaseController):
- def index(self):
- # Return a rendered template
- # return render('/template.mako')
- # or, Return a response
- return 'stub'
+ def list(self):
+ c.users = meta.Session.query(model.User).order_by(model.User.id.asc())
+ return render('/users/list.mako')
def profile(self, id, name=None):
"""Main user profile.
--- /dev/null
+<%inherit file="/base.mako" />
+<%namespace name="userlib" file="/users/lib.mako" />
+
+<%def name="title()">Users</%def>
+
+<h1>Users</h1>
+
+<ul class="classic-list">
+ % for user in c.users:
+ <li>
+ <a href="${url(controller='users', action='profile', id=user.id, name=user.name)}">
+ ${userlib.color_bar(user)} ${user.name}
+ </a>
+ </li>
+ % endfor
+</ul>