X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/bb380b3d5ca425650bb86c1fef45d4ca9fde3b25..efdbb22873232827398ba7605f8b35c605c043e9:/floof/controllers/relation.py diff --git a/floof/controllers/relation.py b/floof/controllers/relation.py new file mode 100644 index 0000000..48e7a46 --- /dev/null +++ b/floof/controllers/relation.py @@ -0,0 +1,35 @@ +import logging + +from pylons import request, response, session, tmpl_context as c, h, url +from pylons.controllers.util import abort, redirect + +from floof.lib.base import BaseController, render + +log = logging.getLogger(__name__) + +from floof.model import Art, UserRelation +from floof.model.users import User +import elixir + +# TODO!!! Implement adding a related user the same way that it works +# on the "add new art" page + +class RelationController(BaseController): + def create(self, art_id, kind): + art = h.get_object_or_404(Art, id=art_id) + user = h.get_object_or_404(User, name=request.params['username']) + ## TODO: actually, this should act like a form validation. + + prior_relation = UserRelation.get_by(art=art, user=user) + if prior_relation: + abort(404) ## should be a validation error + + relation = UserRelation(user=user, kind=kind, art=art, creator=c.user) + elixir.session.commit() + redirect(url('show_art', id=art_id)) + + def index(self): + # Return a rendered template + #return render('/relation.mako') + # or, return a response + return 'Hello World'