Users namespace index and a quick userlist.
authorEevee <git@veekun.com>
Mon, 5 Oct 2009 04:14:44 +0000 (21:14 -0700)
committerEevee <git@veekun.com>
Mon, 5 Oct 2009 04:14:44 +0000 (21:14 -0700)
floof/config/routing.py
floof/controllers/users.py [new file with mode: 0644]
floof/templates/users/index.mako [new file with mode: 0644]
floof/tests/functional/test_users.py [new file with mode: 0644]

index c8f9e4e..37be4c2 100644 (file)
@@ -29,6 +29,9 @@ def make_map():
     map.connect('/account/register', controller='account', action='register')
     map.connect('/account/register_finish', controller='account', action='register_finish', **require_POST)
 
     map.connect('/account/register', controller='account', action='register')
     map.connect('/account/register_finish', controller='account', action='register_finish', **require_POST)
 
+    map.connect('/users', controller='users', action='list')
+    map.connect('/users/{name}', controller='users', action='view')
+
     map.connect('/search', controller='search', action='index')
 
     return map
     map.connect('/search', controller='search', action='index')
 
     return map
diff --git a/floof/controllers/users.py b/floof/controllers/users.py
new file mode 100644 (file)
index 0000000..1758653
--- /dev/null
@@ -0,0 +1,19 @@
+import logging
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+
+from floof.lib.base import BaseController, render
+from floof.model.users import User
+
+log = logging.getLogger(__name__)
+
+class UsersController(BaseController):
+
+    def list(self):
+        """List of all users."""
+
+        # TODO paging!
+        c.users = User.query.all()
+
+        return render('/users/index.mako')
diff --git a/floof/templates/users/index.mako b/floof/templates/users/index.mako
new file mode 100644 (file)
index 0000000..b16bbaf
--- /dev/null
@@ -0,0 +1,8 @@
+<%inherit file="/base.mako" />
+
+<ul>
+% for user in c.users:
+## TODO normalize URL names better perhaps
+    <li><a href="${url.current(action='view', name=user.name.lower())}">${user.name}</a></li>
+% endfor
+</ul>
diff --git a/floof/tests/functional/test_users.py b/floof/tests/functional/test_users.py
new file mode 100644 (file)
index 0000000..cc1aeb1
--- /dev/null
@@ -0,0 +1,7 @@
+from floof.tests import *
+
+class TestUsersController(TestController):
+
+    def test_index(self):
+        response = self.app.get(url(controller='users', action='index'))
+        # Test response...