Merged add_tags and lib.search into lib.tags.
[zzz-floof.git] / floof / lib / search.py
diff --git a/floof/lib/search.py b/floof/lib/search.py
deleted file mode 100644 (file)
index 8874824..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-from floof.model import Art, ArtUser, ArtUserType, Tag, TagText, User
-
-def parse(search_string):
-    """Parses a search query, and returns a query object on Art.
-
-    Queries can contain:
-    - Regular tags: foo
-    - User relations: by:kalu, of:eevee, for:ootachi
-
-    Later:
-    - Negative versions of anything above: -by:eevee, -dongs
-    """
-
-    # XXX doesn't do negative querying yet.
-    # XXX could use some sane limits.
-
-    # We'll be building this as we go.
-    q = Art.query
-
-    terms = search_string.split()
-    for tag in terms:
-        if ':' in tag:
-            # This is a special tag; at the moment, by/for/of to indicate
-            # related users
-            prefix, tag = tag.split(':', 1)
-
-            # XXX what to do if this fails?  abort?  return empty query?
-            target_user = User.get_by(name=tag)
-
-            if prefix == 'by':
-                rel = ArtUserType.BY
-            elif prefix == 'for':
-                rel = ArtUserType.FOR
-            elif prefix == 'of':
-                rel = ArtUserType.OF
-            else:
-                # Bogus tag.  Not sure what to do here, so for the moment,
-                # ignore it
-                continue
-
-            # Inner join to the ArtUser table
-            q = q.join(ArtUser, aliased=True) \
-                 .filter(ArtUser.user == target_user) \
-                 .filter(ArtUser.type == rel)
-
-        else:
-            # Regular ol' tag
-            q = q.join(Tag, TagText, aliased=True) \
-                 .filter(TagText.text == tag)
-
-    return q