示例#1
0
 def test_post_find_by_id(self):
   user = User.create(self.params['username'],self.params['password'])
   Post.create(user,self.params['post'])
   post_found = Post.find_by_id(1)
   self.assertEqual(1,post_found.id)
   self.assertEqual(user.id,int(post_found.user_id)) #shouldn't need int()
   self.assertEqual(self.params['username'],post_found.user.username)
示例#2
0
文件: app.py 项目: aiqier/retwis-py
def status(name,id):
  post = Post.find_by_id(id)
  if post:
    if post.user.username == name:
      return bottle.template('single',username=post.user.username,tweet=post,page='single',
                                    logged=user_is_logged())
  return bottle.HTTPError(code=404,message='tweet not found')
示例#3
0
 def test_post_find_by_id(self):
   user = User.create(self.params['username'],self.params['password'])
   Post.create(user,self.params['post'])
   post_found = Post.find_by_id(1)
   self.assertEqual(1,post_found.id)
   self.assertEqual(user.id,int(post_found.user_id)) #shouldn't need int()
   self.assertEqual(self.params['username'],post_found.user.username)
示例#4
0
def status(name, id):
    post = Post.find_by_id(id)
    if post:
        if post.user.username == name:
            return bottle.template('single',
                                   username=post.user.username,
                                   tweet=post,
                                   page='single',
                                   logged=user_is_logged())
    return bottle.HTTPError(code=404, message='tweet not found')
示例#5
0
文件: app.py 项目: wightman/speakeasy
def status(auth, name,id):
  post = Post.find_by_id(id)
  if post:
    if post.user.username == name:
      if auth != None:
        return bottle.template('single',username=post.user.username,tweet=post,page='single',
                                      logged=user_is_logged(),viewer=auth.username)
      else:
        return bottle.template('single',username=post.user.username,tweet=post,page='single',
                                      logged=user_is_logged(),viewer="")
  return bottle.HTTPError(code=404,message='tweet not found')  
示例#6
0
def status(name, id):
    user = User.find_by_username(name)
    if user:
        post = Post.find_by_id(user.id + ':' + id)
    else:
        post = None
    if post:
        if post.user.username == name:
            return bottle.template('single',
                                   username=post.user.username,
                                   tweet=post,
                                   page='single',
                                   logged=user_is_logged())
    return bottle.HTTPError(code=404, message='tweet not found')
示例#7
0
def status(auth, name, id):
    post = Post.find_by_id(id)
    if post:
        if post.user.username == name:
            if auth != None:
                return bottle.template('single',
                                       username=post.user.username,
                                       tweet=post,
                                       page='single',
                                       logged=user_is_logged(),
                                       viewer=auth.username)
            else:
                return bottle.template('single',
                                       username=post.user.username,
                                       tweet=post,
                                       page='single',
                                       logged=user_is_logged(),
                                       viewer="")
    return bottle.HTTPError(code=404, message='tweet not found')