def add_post_for(self, username, image_url, thumb_url): user = self.db.query(User).filter_by(name=username).first() print(user) post = Post(image_url=image_url, thumb_url=thumb_url, user=user) self.db.add(post) self.db.commit() return post
def id_get_post(self, post_id): """ 根据post_id 获取对应的post :param post_id: :return: """ return Post.id_get_post(post_id=post_id, session=self.db)
def get_post(self): """ 获取用户对应的图片 :return: """ return Post.get_post(username=self.username, session=self.db)
def add_post_for(username, image_url, thumb_url): '''保存图片对应的用户信息和存储信息''' user = session.query(User).filter_by(name=username).first() post = Post(image_url=image_url, user=user, thumb_url=thumb_url) session.add(post) session.commit() return post.id
def add_post_for(username, image_url, thumb_url): """ 保存特定用户的图片 """ user = session.query(User).filter_by(name=username).first() post = Post(image_url=image_url, thumb_url=thumb_url, user=user) session.add(post) session.commit()
def add_post(self, image_url, thumb_url): """ 往数据库里加入图片信息 :param image_url: :param thumb_url: :return: post 实例对象 """ return Post.add_post(username=self.username, image_url=image_url, thumb_url=thumb_url, session=self.db)
def add_post_for(username, image_url, thumb_url): ''' 保存特定用户的图片 :param username:用户名 :param image_url:上传图片的保存地址(static下的) :param thumb_url:缩略图的保存地址(static下的) :return: ''' user = session.query(User).filter_by(name=username).first() post = Post(image_url=image_url, thumb_url=thumb_url, user=user) session.add(post) session.commit() return post.id
def add_post_for(username, img_url, thumb_url): """ posts表增加数据 :param username: :param img_url: :param thumb_url: :return: """ user = User.query(username) post = Post(img_url=img_url, user=user, thumb_url=thumb_url) session.add(post) session.commit() return post
def add_post_for(username, image_url, thumb_url): """ 保存用户上传的图片信息. :param username: :param image_url: :param thumb_url: :return: """ user = session.query(User).filter_by(name=username).first() post = Post(image_url=image_url, thumb_url=thumb_url, user=user) session.add(post) session.commit() return post
def update(post_id): """跟新posts表中数据,标记为用户取消上传的图片""" Post.update(post_id)
def get_all_post(self): """ 按降序获取所有的post :return: """ return Post.get_post_all(session=self.db)
def add_post_for_user(self, image_url, thumb_url): user = self.get_user() post = Post(image_url=image_url, thumb_url=thumb_url, user=user) self.db.add(post) self.db.commit() return post