def add_tweet(): new_tweet = Tweet() new_tweet.text = request.form['text'] new_tweet.created_at = request.form['created_at'] db.session.add(new_tweet) db.session.commit() return tweet_schema.jsonify(new_tweet)
def update_tweet(): new_tweet = Tweet() new_tweet.id = request.form['id'] new_tweet.text = request.form['text'] db.session.query(Tweet).filter_by(id=new_tweet.id).update( {"text": new_tweet.text}) db.session.commit() return tweet_schema.jsonify(new_tweet)
def create_tweet(): #import ipdb; ipdb.set_trace() tweet = Tweet() tweet.text = request.json['text'] tweet.created_at = datetime.now().time() db.session.add(tweet) db.session.commit() return tweet_schema.jsonify(tweet), 201
def get_tweet(id): tweet = db.session.query(Tweet).get(int(id)) return tweet_schema.jsonify(tweet)
def update_tweet(id): tweet = db.session.query(Tweet).get(id) tweet.text = request.json['text'] db.session.commit() return tweet_schema.jsonify(tweet), 204
def delete_tweet(id): #import ipdb; ipdb.set_trace() tweet = db.session.query(Tweet).get(id) db.session.delete(tweet) db.session.commit() return tweet_schema.jsonify(tweet), 204
def tweet(id): #import ipdb; ipdb.set_trace() tweet = db.session.query(Tweet).get(id) return tweet_schema.jsonify(tweet)