3 from pylons
import request
, response
, session
, tmpl_context
as c
, h
4 from pylons
.controllers
.util
import abort
, redirect
7 from floof
.lib
.base
import BaseController
, render
8 from floof
.lib
.search
import parse
10 log
= logging
.getLogger(__name__
)
12 from floof
.model
import Art
, Tag
, TagText
13 from floof
.model
import SavedSearch
, GalleryWidget
16 class SearchController(BaseController
):
19 if request
.params
.get('button') == 'Save':
22 c
.query
= request
.params
.get('query', '')
23 c
.artwork
= parse(c
.query
).all()
24 return render('/index.mako')
26 # TODO: login required
28 c
.query
= request
.params
.get('query', '')
29 saved_search
= SavedSearch(author
=c
.user
, string
=c
.query
)
30 elixir
.session
.commit()
31 redirect(url('saved_searches'))
32 # TODO: do something better than this.
35 # TODO: login required
37 c
.searches
= c
.user
.searches
38 return render('/searches.mako')
40 # TODO: login required
41 def display(self
, id):
42 c
.search
= h
.get_object_or_404(SavedSearch
, id=id)
43 c
.gallery
= GalleryWidget(search
=c
.search
, page
=c
.user
.primary_page
)
44 elixir
.session
.commit()
45 redirect(url(controller
="users", action
="view", name
=c
.user
.name
))