7e04ae71565f095d962a405c7c5593fceac82e8b
2 # from users import User
5 class SavedSearch(Entity
):
6 string
= Field(Unicode
) # I tried calling this query, but it broke elixir
7 author
= ManyToOne('User')
8 fork
= ManyToOne("SavedSearch")
10 def __unicode__(self
):
15 class GalleryWidget(Entity
):
16 page
= ManyToOne('UserPage')
17 search
= ManyToOne(SavedSearch
)
19 def __init__(self
, string
=None, **kwargs
):
20 owner
= kwargs
.get('owner', None)
22 self
.search
= SavedSearch(author
=owner
, string
=string
)
24 page
= kwargs
.get('page', None)
25 if owner
and not page
:
26 page
= author
.primary_page
28 super(GalleryWidget
, self
).__init__(**kwargs
)
31 # NOTE: no longer needed now that we have pages, I guess.
32 # displayer = ManyToOne('User') # determines whose page should it should show up on
33 # # Could be no-ones, if it's just a template.
35 # Needs some fields for position on your page
39 return self
.search
.string
42 def string(self
, value
):
43 # TODO: should we delete the possibly orphaned saved search?
44 # if not self.displayer:
45 # # TODO: may have to refactor this into an init if the key ordering is inconvenienc
46 # raise "Oh no! This gallery needs a displayer to set on the saved search."
48 self
.search
= SavedSearch(author
=getattr(self
,"author",None), string
=value
)