X-Git-Url: http://git.veekun.com/zzz-floof.git/blobdiff_plain/f263f51648eef9739caa92e19ec45b32d7a1e49e..fe7afb91d071aaf21034561840588e82425f3d8a:/floof/model/search.py?ds=sidebyside diff --git a/floof/model/search.py b/floof/model/search.py index fb86f35..7e04ae7 100644 --- a/floof/model/search.py +++ b/floof/model/search.py @@ -10,18 +10,23 @@ class SavedSearch(Entity): def __unicode__(self): return self.string - @property - def results(self): - # This caused some cyclic dependencies when I tried importing it - # at the module level. I wonder why that is... - from floof.lib.search import do_search - return do_search(self.string) - class GalleryWidget(Entity): page = ManyToOne('UserPage') search = ManyToOne(SavedSearch) + + def __init__(self, string=None, **kwargs): + owner = kwargs.get('owner', None) + if string: + self.search = SavedSearch(author=owner, string=string) + + page = kwargs.get('page', None) + if owner and not page: + page = author.primary_page + + super(GalleryWidget, self).__init__(**kwargs) + # NOTE: no longer needed now that we have pages, I guess. # displayer = ManyToOne('User') # determines whose page should it should show up on @@ -31,7 +36,7 @@ class GalleryWidget(Entity): @property def string(self): - return self.search + return self.search.string @string.setter def string(self, value):