Esempio n. 1
0
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)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
0
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))
Esempio n. 5
0
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,
                            )
Esempio n. 6
0
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,
    )
Esempio n. 7
0
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))
Esempio n. 8
0
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)
                            )
Esempio n. 9
0
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))
Esempio n. 10
0
 def tearDown(self):
     Tweet.drop_collection()
     NotifyMessage.drop_collection()
Esempio n. 11
0
 def test_get_tweet_by_id(self):
     tweet   = Tweet.get_tweet_byid(self.tweet.id)
     eq_(tweet,self.tweet)
Esempio n. 12
0
 def tearDown(self):
     Tweet.drop_collection()
     SearchIndex.drop_collection()
Esempio n. 13
0
 def test_create_comment(self):
     eq_(Tweet.objects().count(),1)
Esempio n. 14
0
def tweet_create(content):
    return Tweet(content=content).save()
Esempio n. 15
0
 def tearDown(self):
     Tweet.drop_collection()
     NotifyMessage.drop_collection()
Esempio n. 16
0
 def test_get_tweet_by_id(self):
     tweet = Tweet.get_tweet_byid(self.tweet.id)
     eq_(tweet, self.tweet)
Esempio n. 17
0
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))
Esempio n. 18
0
 def tearDown(self):
     User.drop_collection()
     Tweet.drop_collection()
     Comment.drop_collection()
     NotifyMessage.drop_collection()
Esempio n. 19
0
 def tearDown(self):
     Tweet.drop_collection()
     SearchIndex.drop_collection()