d8e46f3abf4585d4b18f82d75246d69c861f7b53
[zzz-floof.git] / floof / controllers / tag.py
1 import logging
2
3 from pylons import request, response, session, tmpl_context as c, h
4 from pylons.controllers.util import abort, redirect
5
6 from floof.lib.base import BaseController, render
7 from pylons import url
8
9 log = logging.getLogger(__name__)
10
11 import elixir
12 from floof.model.art import Art, Tag
13
14 class TagController(BaseController):
15
16 # TODO: login required
17 def delete(self, art_id, id):
18 tag = Tag.get(id)
19 if tag:
20 elixir.session.delete(tag)
21 elixir.session.commit()
22 redirect(url('art', id=art_id))
23
24 # TODO: login required
25 def create(self, art_id):
26 c.art = h.get_object_or_404(Art, id=art_id)
27 c.art.add_tags(request.params["tags"], c.user)
28 elixir.session.commit()
29 redirect(url('art', id=c.art.id))
30