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