def tweet(): content = request.form['content'] extra_pic= request.form.get("extra",None) content = clean(content) posterid = session['user'].id t = Tweet(content=content,poster=session['user'],extra_pic=extra_pic) t.tweet() new_tweet = render_template('include/show_tweet.html', tweet = t) return jsonify(result="done", newtweet = new_tweet)
def comment(): tweetid = request.form['tweetid'] content = request.form['content'] content = clean(content) c = Comment.add(content, Tweet.get_tweet_byid(tweetid), session['user']) new_comment = render_template('include/show_comment.html', comment = c) return jsonify(result="done", newcomment = new_comment)
def retweet(): comment = request.form['comment'] comment = clean(comment) originalid = request.form['originalid'] poster = session['user'] t = Tweet.retweetit(originalid,comment,poster) new_tweet = render_template('include/show_tweet.html', tweet = t, floor=random_int()) return jsonify(result="done", newtweet = new_tweet)
def main(): if('user' not in session): return redirect(url_for('newest')) page = request.args.get("page", 1, type=int) tweets = Tweet.get_tweets_foruser(session['user'],offset=page-1,limit=15) return render_template('main.html', tweets=tweets, more_url=url_for("main",page=page+1))
def show_single_tweet(tweetid): tweet = Tweet.get_tweet_byid(tweetid) tweet.open = True is_retweet = request.args.get("retweet",None) return render_template("single_tweet.html", tweet=tweet, is_retweet=is_retweet, )
def show_single_tweet(tweetid): tweet = Tweet.get_tweet_byid(tweetid) tweet.open = True is_retweet = request.args.get("retweet", None) return render_template( "single_tweet.html", tweet=tweet, is_retweet=is_retweet, )
def main(): if ('user' not in session): return redirect(url_for('newest')) page = request.args.get("page", 1, type=int) tweets = Tweet.get_tweets_foruser(session['user'], offset=page - 1, limit=15) return render_template('main.html', tweets=tweets, more_url=url_for("main", page=page + 1))
def personal_center(userid=None): theuser = None if userid is None: theuser = session['user'] else: theuser = User.get_user_by_id(userid) page = request.args.get("page", 1, type=int) tweets = Tweet.get_users_tweets(theuser,offset=page-1,limit=15) return render_template("personal_center.html", theuser=theuser, tweets=tweets, more_url = url_for("personal_center",page=page+1,userid=userid) )
def newest(): page = request.args.get("page", 1, type=int) tweets = Tweet.get_newest_tweets(offset=page-1,limit=15) return render_template('newest.html', tweets = tweets, more_url = url_for("newest",page=page+1))
def tearDown(self): Tweet.drop_collection() NotifyMessage.drop_collection()
def test_get_tweet_by_id(self): tweet = Tweet.get_tweet_byid(self.tweet.id) eq_(tweet,self.tweet)
def tearDown(self): Tweet.drop_collection() SearchIndex.drop_collection()
def test_create_comment(self): eq_(Tweet.objects().count(),1)
def tweet_create(content): return Tweet(content=content).save()
def test_get_tweet_by_id(self): tweet = Tweet.get_tweet_byid(self.tweet.id) eq_(tweet, self.tweet)
def newest(): page = request.args.get("page", 1, type=int) tweets = Tweet.get_newest_tweets(offset=page - 1, limit=15) return render_template('newest.html', tweets=tweets, more_url=url_for("newest", page=page + 1))
def tearDown(self): User.drop_collection() Tweet.drop_collection() Comment.drop_collection() NotifyMessage.drop_collection()