displaying galleries on your page works
[zzz-floof.git] / floof / model / search.py
1 from elixir import *
2 # from users import User
3
4 from floof.lib.search import do_search
5
6 class SavedSearch(Entity):
7 string = Field(Unicode) # I tried calling this query, but it broke elixir
8 author = ManyToOne('User')
9
10 def __unicode__(self):
11 return self.string
12
13 @property
14 def results(self):
15 return do_search(self.string)
16
17
18
19 class GalleryWidget(Entity):
20 search = ManyToOne(SavedSearch)
21 displayer = ManyToOne('User') # determines whose page should it should show up on
22 # Could be no-ones, if it's just a template.
23
24 # Needs some fields for position on your page
25
26 @property
27 def string(self):
28 return self.search
29
30 @string.setter
31 def string(self, value):
32 # TODO: should we delete the possibly orphaned saved search?
33 if not self.displayer:
34 # TODO: may have to refactor this into an init if the key ordering is inconvenienc
35 raise "Oh no! This gallery needs a displayer to set on the saved search."
36
37 self.search = SavedSearch(author=self.displayer, string=value)
38
39
40 # class UserPage(Entity):
41 # owner = ManyToOne('User')
42 # visible = Field(Boolean)