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