Stubby user page. #70
authorEevee <git@veekun.com>
Fri, 23 Apr 2010 05:21:10 +0000 (22:21 -0700)
committerEevee <git@veekun.com>
Fri, 23 Apr 2010 05:21:10 +0000 (22:21 -0700)
spline/plugins/users/__init__.py
spline/plugins/users/controllers/users.py [new file with mode: 0644]
spline/plugins/users/templates/users/view.mako [new file with mode: 0644]

index 5173931..5e006cf 100644 (file)
@@ -8,6 +8,7 @@ import spline.model as model
 import spline.model.meta as meta
 
 import spline.plugins.users.controllers.accounts
+import spline.plugins.users.controllers.users
 import spline.plugins.users.model
 
 def add_routes_hook(map, *args, **kwargs):
@@ -16,6 +17,9 @@ def add_routes_hook(map, *args, **kwargs):
     map.connect('/accounts/login_finish', controller='accounts', action='login_finish')
     map.connect('/accounts/logout', controller='accounts', action='logout')
 
+    map.connect('/users/{id};{name}', controller='users', action='view')
+    map.connect('/users/{id}', controller='users', action='view')
+
 def check_userid_hook(action, **params):
     """Hook to see if a user is logged in and, if so, stick a user object in
     c.
@@ -40,6 +44,7 @@ class UsersPlugin(PluginBase):
     def controllers(self):
         return dict(
             accounts = spline.plugins.users.controllers.accounts.AccountsController,
+            users = spline.plugins.users.controllers.users.UsersController,
         )
 
     def model(self):
diff --git a/spline/plugins/users/controllers/users.py b/spline/plugins/users/controllers/users.py
new file mode 100644 (file)
index 0000000..d64d39f
--- /dev/null
@@ -0,0 +1,34 @@
+import logging
+
+from pylons import config, request, response, session, tmpl_context as c, url
+from pylons.controllers.util import abort, redirect_to
+from routes import request_config
+from sqlalchemy.orm.exc import NoResultFound
+
+from spline import model
+from spline.model import meta
+from spline.lib import helpers as h
+from spline.lib.base import BaseController, render
+
+log = logging.getLogger(__name__)
+
+class UsersController(BaseController):
+
+    def index(self):
+        # Return a rendered template
+        #   return render('/template.mako')
+        # or, Return a response
+        return 'stub'
+
+    def view(self, id, name=None):
+        """User page.
+
+        URL is /users/id:name, where 'name' only exists for readability and is
+        entirely optional and ignored.
+        """
+
+        c.page_user = meta.Session.query(model.User).get(id)
+        if not c.page_user:
+            abort(404)
+
+        return render('/users/view.mako')
diff --git a/spline/plugins/users/templates/users/view.mako b/spline/plugins/users/templates/users/view.mako
new file mode 100644 (file)
index 0000000..6462646
--- /dev/null
@@ -0,0 +1,7 @@
+<%inherit file="/base.mako" />
+<%def name="title()">${c.page_user.name} - Users</%def>
+<%def name="title_in_page()">User: ${c.page_user.name}</%def>
+
+<h1>${c.page_user.name}</h1>
+
+A user!