Skip to content

Commit

Permalink
FollowHandler fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dgnydn committed Apr 15, 2012
1 parent 065e388 commit 66a23bf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app.py
Expand Up @@ -32,6 +32,9 @@
# my profile page
(r"/profile", handlers.ProfileHandler),

#follow & followers
(r"/follow",handlers.FollowHandler),

# other users profile page
(r"/(?P<username>.*)", handlers.UserHandler)
]
Expand Down
16 changes: 14 additions & 2 deletions handlers.py
Expand Up @@ -244,10 +244,22 @@ def get(self):
who = self.get_argument("who",False)
_type = self.get_argument("type","followers")
if who:
_f = {}
if _type == "followers":
f = self.db.users.find({"followed":who})
_f = {"followers":[]}
f = self.db.follow.find({"followed":who},{"_id":0})
for i in f:
_f["followers"].append(i["follower"])
_f["count"] = len(_f["followers"])

if _type == "following":
f = self.db.users.find({"follower":who})
_f = {"following":[]}
f = self.db.follow.find({"follower":who},{"_id":0})
for i in f:
_f["following"].append(i["followed"])
_f["count"] = len(_f["following"])

self.write(tornado.escape.json_encode(_f))

@tornado.web.authenticated
def post(self):
Expand Down

0 comments on commit 66a23bf

Please sign in to comment.