b1d415dbccc39c2f18cadb52d9bae85b724e5f7b
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 class RelationController(BaseController
):
15 def create(self
, art_id
, kind
):
16 art
= h
.get_object_or_404(Art
, id=art_id
)
17 user
= h
.get_object_or_404(User
, name
=request
.params
['username'])
18 ## TODO: actually, this should act like a form validation.
20 prior_relation
= UserRelation
.get_by(art
=art
, user
=user
)
22 abort(404) ## should be a validation error
24 relation
= UserRelation(user
=user
, kind
=kind
, art
=art
, creator
=c
.user
)
25 elixir
.session
.commit()
26 redirect(url('show_art', id=art_id
))
29 # Return a rendered template
30 #return render('/relation.mako')
31 # or, return a response