Exemplo n.º 1
0
    def get(self):

        User_email = self.request.params.get("User_email")
        getUser = User.query(User.email == User_email).fetch(1)[0]
        friends = getUser.friends
        feed_list = []
        feed_list.append(getUser.email)
        for friend in friends:
            if User.query(User.fullname == friend).fetch(1):
                getfriend = User.query(User.fullname == friend).fetch(1)[0]
                feed_list.append(getfriend.email)
        yellers = Yeller.query(Yeller.to_whom == "public").fetch(50)
        for yeller in yellers[:]:
            if yeller.author not in feed_list:
                yellers.remove(yeller)
        yellers = sorted(yellers, key=lambda k: k.date, reverse=True)
        yellers_key_ids = []
        for yeller in yellers:
            yellers_key_ids.append(yeller.key_id)
        dictPassed = {
            'yellers_key_ids': yellers_key_ids,
            "feed_list": feed_list
        }

        jsonObj = json.dumps(dictPassed,
                             sort_keys=True,
                             indent=4,
                             separators=(',', ': '))
        self.response.write(jsonObj)
Exemplo n.º 2
0
 def post(self):
     yeller_id = str(self.request.params.get('yeller_id'))
     User_email = self.request.params.get("User_email")
     comment = self.request.params.get("comment")
     yeller = Yeller.query(Yeller.key_id==yeller_id).fetch(1)[0]
     new_comment = Comment(author = User_email)
     new_comment.content = comment
     new_comment_key = new_comment.put()
     yeller.comment.append(new_comment)
     yeller.put()
Exemplo n.º 3
0
    def get(self):

        latitude = float(self.request.params.get("latitude"))
        longitude = float(self.request.params.get("longitude"))
        yellers = Yeller.query(Yeller.to_whom == "public", Yeller.Anonymity == True ).fetch(50)
        yellers = sorted(yellers, key=lambda  k: ((k.latitude-latitude)**2+(k.longitude-longitude)**2), reverse = False)
        yellers_key_ids = []
        for yeller in yellers:
            yellers_key_ids.append(yeller.key_id)
        dictPassed = {'yellers_key_ids':yellers_key_ids}
        jsonObj = json.dumps(dictPassed, sort_keys=True, indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
Exemplo n.º 4
0
    def get(self):

        User_email = self.request.params.get("User_email")
        yellers = Yeller.query(Yeller.author == User_email).fetch(50)
        yellers = sorted(yellers, key=lambda  k: k.date, reverse = True)
        yellers_key_ids = []
        for yeller in yellers:
            yellers_key_ids.append(yeller.key_id)
        dictPassed = {'yellers_key_ids':yellers_key_ids}

        jsonObj = json.dumps(dictPassed, sort_keys=True, indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
Exemplo n.º 5
0
 def get(self):
     yeller_id = str(self.request.params.get('yeller_id'))
     yeller = Yeller.query(Yeller.key_id==yeller_id).fetch(1)[0]
     authors = []
     comments_content = []
     for comment in yeller.comment:
         getuser = User.query(User.email == comment.author).fetch(1)[0]
         authors.append(getuser.fullname)
         comments_content.append(comment.content)
     dictPassed = {'authors':authors,'comments':comments_content}
     jsonObj = json.dumps(dictPassed,sort_keys=True,indent=4, separators=(',', ': '))
     self.response.write(jsonObj)
Exemplo n.º 6
0
    def get(self):

        User_name = self.request.params.get("User_name")
        user = User.query(User.fullname == User_name).fetch(1)[0]
        yellers = Yeller.query(Yeller.author == user.email, Yeller.Anonymity == False).fetch(50)
        yellers = sorted(yellers, key=lambda  k: k.date, reverse = True)
        yellers_key_ids = []
        for yeller in yellers:
            yellers_key_ids.append(yeller.key_id)
        dictPassed = {'yellers_key_ids':yellers_key_ids}
        jsonObj = json.dumps(dictPassed, sort_keys=True, indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
Exemplo n.º 7
0
    def get(self):

        User_email = self.request.params.get("User_email")
        yellers = Yeller.query(Yeller.author == User_email).fetch(50)
        yellers = sorted(yellers, key=lambda k: k.date, reverse=True)
        yellers_key_ids = []
        for yeller in yellers:
            yellers_key_ids.append(yeller.key_id)
        dictPassed = {'yellers_key_ids': yellers_key_ids}

        jsonObj = json.dumps(dictPassed,
                             sort_keys=True,
                             indent=4,
                             separators=(',', ': '))
        self.response.write(jsonObj)
Exemplo n.º 8
0
    def get(self):

        if self.request.params.get("friend_name") != None:
            friendname = self.request.params.get("friend_name")
        else:
            friendname = self.request.params.get("search_name")

        users = User.query().fetch(50)
        for user in users:
            user_name = user.fullname
            lower_username = user_name.lower()
            friendname = friendname.lower()
            if lower_username == friendname:
                user_email = user.email
                if user.head_portrait != None:
                    portrait_url = get_serving_url(user.head_portrait, size=None, crop=False)
                else:
                    portrait_url = None
                yellers = Yeller.query(Yeller.author == user_email, Yeller.Anonymity == False).fetch(50)
                yellers = sorted(yellers, key=lambda k: k.date, reverse=True)
                content = yellers[0].text
                date = str(yellers[0].date)[:-10]
                dictPassed = {'isVaild': True, 'fullname': friendname, "portrait_url": portrait_url, "timestamp": date
                , "status": content}
                break
            else:
                dictPassed = {'isVaild':False}

        # if User.query(User.fullname == friendname).fetch(1):
        #     user = User.query(User.fullname == friendname).fetch(1)[0]
        #     username = user.fullname
        #     user_name = username.upper()
        #     user_email = user.email
        #     if user.head_portrait != None:
        #         portrait_url = get_serving_url(user.head_portrait, size=None, crop=False)
        #     else:
        #         portrait_url = None
        #     yellers = Yeller.query(Yeller.author == user_email, Yeller.Anonymity == False).fetch(50)
        #     yellers = sorted(yellers, key=lambda  k: k.date, reverse = True)
        #     content = yellers[0].text
        #     date = str(yellers[0].date)[:-10]
        #     dictPassed = {'isVaild':True,'fullname':friendname,"portrait_url":portrait_url,"timestamp":date
        #               ,"status":content,"up":user_name}
        # else:
        #     dictPassed = {'isVaild':False}

        jsonObj = json.dumps(dictPassed, sort_keys=True, indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
Exemplo n.º 9
0
    def get(self):

        User_name = self.request.params.get("User_name")
        user = User.query(User.fullname == User_name).fetch(1)[0]
        yellers = Yeller.query(Yeller.author == user.email,
                               Yeller.Anonymity == False).fetch(50)
        yellers = sorted(yellers, key=lambda k: k.date, reverse=True)
        yellers_key_ids = []
        for yeller in yellers:
            yellers_key_ids.append(yeller.key_id)
        dictPassed = {'yellers_key_ids': yellers_key_ids}
        jsonObj = json.dumps(dictPassed,
                             sort_keys=True,
                             indent=4,
                             separators=(',', ': '))
        self.response.write(jsonObj)
Exemplo n.º 10
0
    def get(self):

        User_email = self.request.params.get("User_email")
        getUser = User.query(User.email == User_email).fetch(1)[0]
        friends = getUser.friends
        feed_list = []
        feed_list.append(getUser.email)
        for friend in friends:
            if User.query(User.fullname == friend).fetch(1):
                getfriend = User.query(User.fullname == friend).fetch(1)[0]
                feed_list.append(getfriend.email)
        yellers = Yeller.query(Yeller.to_whom == "public").fetch(50)
        for yeller in yellers[:]:
            if yeller.author not in feed_list:
                yellers.remove(yeller)
        yellers = sorted(yellers, key=lambda  k: k.date, reverse = True)
        yellers_key_ids = []
        for yeller in yellers:
            yellers_key_ids.append(yeller.key_id)
        dictPassed = {'yellers_key_ids':yellers_key_ids,"feed_list":feed_list}

        jsonObj = json.dumps(dictPassed, sort_keys=True, indent=4, separators=(',', ': '))
        self.response.write(jsonObj)
Exemplo n.º 11
0
 def get(self):
     yeller_id = str(self.request.params.get('yeller_id'))
     yeller = Yeller.query(Yeller.key_id==yeller_id).fetch(1)[0]
     author = yeller.author
     date = str(yeller.date)[:-10]
     content = yeller.text
     picture_urls = []
     for picture in yeller.pictures:
         picture_urls.append(get_serving_url(picture.blob_key, size=None, crop=False))
     user = User.query(User.email==author).fetch(1)[0]
     if yeller.Anonymity == True:
         anonymity = "true"
         fullname = "Anonymous"
     else:
         anonymity = "false"
         fullname = user.fullname
     if user.head_portrait != None:
         portrait_url = get_serving_url(user.head_portrait, size=None, crop=False)
     else:
         portrait_url = None
     dictPassed = {'fullname':fullname,"portrait_url":portrait_url,"date":date
                   ,"content":content,"picture_urls":picture_urls,"anonymity":anonymity}
     jsonObj = json.dumps(dictPassed,sort_keys=True,indent=4, separators=(',', ': '))
     self.response.write(jsonObj)