Exemplo n.º 1
0
 def get_like_value(self,branch):
     userinfo = UserInfo.get_by_username(self.username)    
     if userinfo and self.is_user_info_current(userinfo):
         like_key = Like.create_key(branch.key,self.username)
         like = like_key.get();
         if like:
             return like.value
     return 0
Exemplo n.º 2
0
 def set_like(self,branch_urlsafe_key,like_value):
     
     if branch_urlsafe_key is None or branch_urlsafe_key == '':
         return False, ['invalid_parameters']
     
     userinfo = self.current_user_info()
     if userinfo is None:
         return False, ['unauthenticated']
     
     branch_key = ndb.Key(urlsafe=branch_urlsafe_key)
     
     like_key = Like.create_key(branch_key,userinfo.username)
     like = like_key.get()
     
     if like is None:
         branch = branch_key.get()
         like = Like(key=like_key,username=userinfo.username,branch=branch_key,branchauthorname=branch.authorname)
     
     like.value = int(like_value)
     
     like.put()
     
     return True, like