makes default user pages full of by/for/of. duct-taped, doesn't really clone something
[zzz-floof.git] / floof / controllers / users.py
index 1758653..7c24c0f 100644 (file)
@@ -2,9 +2,10 @@ import logging
 
 from pylons import request, response, session, tmpl_context as c
 from pylons.controllers.util import abort, redirect_to
 
 from pylons import request, response, session, tmpl_context as c
 from pylons.controllers.util import abort, redirect_to
+from sqlalchemy.orm.exc import NoResultFound
 
 from floof.lib.base import BaseController, render
 
 from floof.lib.base import BaseController, render
-from floof.model.users import User
+from floof.model.users import User, UserRelationship
 
 log = logging.getLogger(__name__)
 
 
 log = logging.getLogger(__name__)
 
@@ -17,3 +18,20 @@ class UsersController(BaseController):
         c.users = User.query.all()
 
         return render('/users/index.mako')
         c.users = User.query.all()
 
         return render('/users/index.mako')
+
+    def view(self, name):
+        """Userpage."""
+
+        try:
+            c.this_user = User.get_by(name=name)
+        except NoResultFound:
+            abort(404)
+
+        rels = UserRelationship.query.filter_by(
+            user_id=c.user.id,
+            target_user_id=c.this_user.id,
+        ).all()
+
+        c.relationships = [_.type for _ in rels]
+
+        return render('/users/view.mako')