3 from pylons
import request
, response
, session
, tmpl_context
as c
, h
4 from pylons
.controllers
.util
import abort
, redirect
6 from floof
.lib
.base
import BaseController
, render
8 log
= logging
.getLogger(__name__
)
11 from floof
.model
.art
import Art
, Rating
13 class ArtController(BaseController
):
14 def __before__(self
, id=None):
15 super(ArtController
, self
).__before__()
16 # Awesome refactoring!
18 c
.art
= h
.get_object_or_404(Art
, id=id)
21 # c.artwork = Art.query.order_by(Art.id.desc()).all()
26 return render("/art/new.mako")
28 # TODO: login required
30 Art(uploaded_by
=c
.user
, **request
.params
)
31 elixir
.session
.commit()
32 redirect_to(controller
="main", action
="index")
35 # c.art = h.get_object_or_404(Art, id=id)
37 c
.your_score
= c
.art
.user_score(c
.user
)
38 return render("/art/show.mako")
40 # # TODO: login required
42 # # c.art = h.get_object_or_404(Art, id=id)
43 # c.art.add_tags(request.params["tags"], c.user)
44 # elixir.session.commit()
45 # redirect_to('show_art', id=c.art.id)
47 # TODO: login required
49 # c.art = h.get_object_or_404(Art, id=id)
50 score
= request
.params
.get("score")
51 if score
and score
.isnumeric():
54 score
= Rating
.reverse_options
.get(score
)
56 c
.art
.rate(score
, c
.user
)
57 elixir
.session
.commit()
59 redirect(url('art', id=c
.art
.id))