Exemplo n.º 1
0
def new_tweet():
	word = request.form.get('word')
	tweet = request.form.get('tweet')
	user = session['user']
	user_name_pts = "user_%s_pts"%user
	points = model.get_string_num(user_name_pts)
	num_tagged = model.get_num_tagged(user)
	num_final_tagged = model.get_num_final_tagged(user)
	keen.add_event('more_tweets', {
		"user":user,
		'word':word,
		'original tweet':tweet,
		'num_tagged':num_tagged,
		'num_final_tagged':num_final_tagged,
		'points':points
		})
	tweet_list = model.get_another_tweet(word, tweet)
	tweets_gotten = request.form.get('tweets_gotten')
	if tweets_gotten > 0:
		if len(tweet_list) >= tweets_gotten:
			new_tweet = tweet_list[-tweets_gotten]
			if new_tweet == tweet:
				return "There are no more tweets with \"%s\" in them."%word
			else:
				new_tweet = unicode(new_tweet, 'utf-8', errors='replace')
				return render_template('moretweets.html', tweet=Markup(new_tweet).unescape())
		else:
			new_tweet = "There are no more tweets with \"%s\" in them."%word
			return render_template('moretweets.html', tweet=new_tweet)
	else:
		new_tweet = "There are no more tweets with \"%s\" in them."%word
		return render_template('moretweets.html', tweet=new_tweet)
Exemplo n.º 2
0
def game():
	if not session:
		return render_template('login_tt.html')
	if session['user']:
		game_info = model.get_words_tweets_game()
		word_for_game = game_info[0]
		tweet_for_game = game_info[1]
		tweet_list = game_info[2]
		user = session['user']
		user_name_pts = "user_%s_pts"%user
		user_points = model.get_string_num(user_name_pts)

		tweet_for_game = unicode(tweet_for_game, 'utf-8', errors='replace')

		for tweet in tweet_list:
			tweet = unicode(tweet, 'utf-8', errors='replace')

		pos_sents_tags = model.break_pos_sents(model.get_pos_sentences())
		first_half = pos_sents_tags[:len(pos_sents_tags)/2]
		second_half = pos_sents_tags[len(pos_sents_tags)/2:]

		logged_in = 'Logged in as: %s.'%user
		not_you = 'Not %s?'%session['user']

		num_tagged = model.get_num_tagged(user)
		num_final_tagged = model.get_num_final_tagged(user)

		keen.add_event('game_play', {
			"user":user,
			"points":user_points,
			"num_tagged":num_tagged,
			"num_final_tagged":num_final_tagged
			})

		return render_template('game.html', word = word_for_game, tweet = Markup(tweet_for_game).unescape(), user_points=user_points, tweet_list=tweet_list, first_half=first_half, second_half=second_half, logged_in=logged_in, user=user, not_you=not_you)
Exemplo n.º 3
0
def new_tweet():
    word = request.form.get('word')
    tweet = request.form.get('tweet')
    user = session['user']
    user_name_pts = "user_%s_pts" % user
    points = model.get_string_num(user_name_pts)
    num_tagged = model.get_num_tagged(user)
    num_final_tagged = model.get_num_final_tagged(user)
    keen.add_event(
        'more_tweets', {
            "user": user,
            'word': word,
            'original tweet': tweet,
            'num_tagged': num_tagged,
            'num_final_tagged': num_final_tagged,
            'points': points
        })
    tweet_list = model.get_another_tweet(word, tweet)
    tweets_gotten = request.form.get('tweets_gotten')
    if tweets_gotten > 0:
        if len(tweet_list) >= tweets_gotten:
            new_tweet = tweet_list[-tweets_gotten]
            if new_tweet == tweet:
                return "There are no more tweets with \"%s\" in them." % word
            else:
                new_tweet = unicode(new_tweet, 'utf-8', errors='replace')
                return render_template('moretweets.html',
                                       tweet=Markup(new_tweet).unescape())
        else:
            new_tweet = "There are no more tweets with \"%s\" in them." % word
            return render_template('moretweets.html', tweet=new_tweet)
    else:
        new_tweet = "There are no more tweets with \"%s\" in them." % word
        return render_template('moretweets.html', tweet=new_tweet)
Exemplo n.º 4
0
def play_game():
    tag = request.form.get('tag')
    word = request.form.get('word')
    tweet = request.form.get('tweet')
    user = session['user']
    num_tagged = model.get_num_tagged(user)
    num_final_tagged = model.get_num_final_tagged(user)
    if tag and word:
        # set the tag for the user and the tweet
        model.tag_word_game(word, tag, user, tweet)
        # add points and set final tag if needed
        model.add_pts_game(word, tag, user)
        # retrieve how many points user has
        user_name_pts = "user_%s_pts" % user
        num_points = model.get_string_num(user_name_pts)
        keen.add_event(
            "button_press", {
                "tag": tag,
                "word": word,
                "user": user,
                "num_tagged": num_tagged,
                "num_final_tagged": num_final_tagged,
                "points": num_points
            })
        return str(num_points)
Exemplo n.º 5
0
def show_points():
	if not session:
		scores = model.get_top_scores()
		return render_template("top_points.html", scores=scores )
	if session['user']:
		user = session['user']
		scores = model.get_top_scores()
		user_name_pts = "user_%s_pts"%user
		user_score = model.get_string_num(user_name_pts)
		logged_in = 'Logged in as: %s.'%user
		not_you = 'Not %s?'%session['user']
		return render_template("user_and_top_points.html", scores=scores, user_score=user_score, user=user, logged_in=logged_in, not_you=not_you)
Exemplo n.º 6
0
def play_game():
	tag = request.form.get('tag')
	word = request.form.get('word')
	tweet = request.form.get('tweet')
	user = session['user']
	if tag and word:
		# set the tag for the user and the tweet
		model.tag_word_game(word, tag, user, tweet)
		# add points and set final tag if needed
		model.add_pts_game(word, tag, user)
		# retrieve how many points user has
		user_name_pts = "user_%s_pts"%user
		num_points = model.get_string_num(user_name_pts)
		return str(num_points)
Exemplo n.º 7
0
def show_points():
    if not session:
        scores = model.get_top_scores()
        return render_template("top_points.html", scores=scores)
    if session['user']:
        user = session['user']
        scores = model.get_top_scores()
        user_name_pts = "user_%s_pts" % user
        user_score = model.get_string_num(user_name_pts)
        logged_in = 'Logged in as: %s.' % user
        not_you = 'Not %s?' % session['user']
        return render_template("user_and_top_points.html",
                               scores=scores,
                               user_score=user_score,
                               user=user,
                               logged_in=logged_in,
                               not_you=not_you)
Exemplo n.º 8
0
def game():
    if not session:
        return render_template('login_tt.html')
    if session['user']:
        game_info = model.get_words_tweets_game()
        word_for_game = game_info[0]
        tweet_for_game = game_info[1]
        tweet_list = game_info[2]
        user = session['user']
        user_name_pts = "user_%s_pts" % user
        user_points = model.get_string_num(user_name_pts)

        tweet_for_game = unicode(tweet_for_game, 'utf-8', errors='replace')

        for tweet in tweet_list:
            tweet = unicode(tweet, 'utf-8', errors='replace')

        pos_sents_tags = model.break_pos_sents(model.get_pos_sentences())
        first_half = pos_sents_tags[:len(pos_sents_tags) / 2]
        second_half = pos_sents_tags[len(pos_sents_tags) / 2:]

        logged_in = 'Logged in as: %s.' % user
        not_you = 'Not %s?' % session['user']

        num_tagged = model.get_num_tagged(user)
        num_final_tagged = model.get_num_final_tagged(user)

        keen.add_event(
            'game_play', {
                "user": user,
                "points": user_points,
                "num_tagged": num_tagged,
                "num_final_tagged": num_final_tagged
            })

        return render_template('game.html',
                               word=word_for_game,
                               tweet=Markup(tweet_for_game).unescape(),
                               user_points=user_points,
                               tweet_list=tweet_list,
                               first_half=first_half,
                               second_half=second_half,
                               logged_in=logged_in,
                               user=user,
                               not_you=not_you)
Exemplo n.º 9
0
def play_game():
	tag = request.form.get('tag')
	word = request.form.get('word')
	tweet = request.form.get('tweet')
	user = session['user']
	num_tagged = model.get_num_tagged(user)
	num_final_tagged = model.get_num_final_tagged(user)
	if tag and word:
		# set the tag for the user and the tweet
		model.tag_word_game(word, tag, user, tweet)
		# add points and set final tag if needed
		model.add_pts_game(word, tag, user)
		# retrieve how many points user has
		user_name_pts = "user_%s_pts"%user
		num_points = model.get_string_num(user_name_pts)
		keen.add_event("button_press", {
		"tag":tag,
		"word":word,
		"user":user,
		"num_tagged":num_tagged,
		"num_final_tagged":num_final_tagged,
		"points":num_points
		})
		return str(num_points)