Tiny fixes: save a query for by:me, and count() is a method.
[zzz-floof.git] / floof / lib / tags.py
index 9bfdf04..134ba6f 100644 (file)
@@ -2,6 +2,9 @@ from floof.model import Art, ArtUser, ArtUserType, Tag, TagText, User
 import elixir
 from dbhelpers import find_or_create
 import re
+
+from pylons import c
+
 def parse(search_string):
     """Parses a search query, and returns a query object on Art.
 
@@ -25,6 +28,8 @@ def parse(search_string):
             # This is a special tag; at the moment, by/for/of to indicate
             # related users
             prefix, tag = tag.split(':', 1)
+            if tag == 'me':
+                tag = c.user.name
 
             # XXX what to do if this fails?  abort?  return empty query?
             target_user = User.get_by(name=tag)
@@ -93,7 +98,10 @@ def add_tags(art, tag_string, user):
 
         # Do work!
         if prefix:
-            target_user = User.get_by(name=tag_text)
+            if tag_text == 'me':
+                target_user = c.user
+            else:
+                target_user = User.get_by(name=tag_text)
 
             # Special tag; at the moment, just a relationship
             if prefix == 'by':