3 from pylons
import request
, response
, session
, tmpl_context
as c
, h
, url
4 from pylons
.controllers
.util
import abort
, redirect
6 from floof
.lib
.base
import BaseController
, render
8 log
= logging
.getLogger(__name__
)
10 from floof
.model
import Art
, UserRelation
11 from floof
.model
.users
import User
14 # TODO!!! Implement adding a related user the same way that it works
15 # on the "add new art" page
17 class RelationController(BaseController
):
18 def create(self
, art_id
, kind
):
19 art
= h
.get_object_or_404(Art
, id=art_id
)
20 user
= h
.get_object_or_404(User
, name
=request
.params
['username'])
21 ## TODO: actually, this should act like a form validation.
23 prior_relation
= UserRelation
.get_by(art
=art
, user
=user
)
25 abort(404) ## should be a validation error
27 relation
= UserRelation(user
=user
, kind
=kind
, art
=art
, creator
=c
.user
)
28 elixir
.session
.commit()
29 redirect(url('show_art', id=art_id
))
32 # Return a rendered template
33 #return render('/relation.mako')
34 # or, return a response