def update_aboutMe(username, row): record = tasks.find_user(username) record.city = row.get('city', None) record.website = row.get('website', None) record.about_me = row.get('about_me', None) dao.save(record)
def update_password(data): user = User().find_by_email(data['email']) if user: user.password = data['password'] dao.save(user) else: return '請再試一次'
def read_count(restaurant): res = {'status': False} try: submit = services.submit_click(restaurant, current_user) dao.save(submit) res.update({'status': True}) return jsonify(res) except Exception as e: logger.error(e) return jsonify(res)
def user_register(**kwargs): isError = check_captcha(kwargs['image_code_id'], kwargs['image_code']) if isError: return isError isError = check_register_info(**kwargs) if isError: return isError isError = check_double_register(**kwargs) if isError: return isError user = User(username=kwargs['username'], email=kwargs['email'], cellphone=kwargs['cellphone'], password=kwargs['password']) dao.save(user)
def submit_comments(id, user, row): tripadvisor = TripAdvisor() restaurant = tripadvisor.find_by_id(id) c = Comment() c.rating = row.get('rating', None) c.friend = row.get('friend', None) c.review_title = row.get('review_title', None) c.review_content = row.get('review_content', None) c.booking_date = row.get('booking_date', None) c.takeout = row.get('takeout', None) c.vegetable = row.get('vegetable', None) c.disabled = row.get('disabled', None) c.star1 = row.get('star1', None) c.star2 = row.get('star2', None) c.star3 = row.get('star3', None) c.recommend_dish = row.get('recommend_dish', None) c.author = user._get_current_object() c.restaurant = restaurant dao.save(c)
def reserve(data): order_id = "%s-%s" % (int(round( time.time() * 1000)), random.randint(0, 99999999)) tripAdvisor = TripAdvisor() store = tripAdvisor.find_by_name(data['restaurant']) result = Reservation(order_id=order_id, title_name=data['restaurant'], people=data['people'], booking_date=data['booking_date'], booking_time=data['booking_time'], user=current_user._get_current_object(), restaurant_id=store.id) result = dao.save(result) return order_id
def follow(self, user): if not self.is_following(user): f = Follow(follower=self, followed=user) dao.save(f)
def like_comment(id, current_user): comment = db.session.query(Comment).filter_by(id=id).first() comment = Comment_like(user_id=current_user.id, comment_id=comment.id) return dao.save(comment)
def follow_restaurant(user, restaurant): restaurant = db.session.query(TripAdvisor).filter( TripAdvisor.title == restaurant).first() row = Love(store=restaurant, author=user._get_current_object()) dao.save(row)