Example #1
0
def process_new_achievement():
	connection = pymongo.Connection(connection_string, safe=True)

	name = bottle.request.forms.get("name")
	description = bottle.request.forms.get("description")
	tags = bottle.request.forms.get("tags")

	my_username = login_check()
	try:
		username = bottle.request.query['to_user']
	except:
		username = my_username
	
	# set these up in case we have an error case
	errors = {'name':cgi.escape(name)}
	if (achievement.validate_new_achievement(name, errors)):
		id = achievement.new_achievement(connection, name, description, tags)
		if(username == my_username):
			print "to me"
			print id
			achievement.add_challenge_to_me(connection, my_username, id)
		else:
			print "to friend"
			achievement.add_challenge_to_friend(connection, username, my_username, id)
		bottle.redirect("/main")
	else:
		print "user did not validate"
		return bottle.template("new_achievement", errors)
Example #2
0
def process_new_achievement():
    connection = pymongo.Connection(connection_string, safe=True)

    name = bottle.request.forms.get("name")
    description = bottle.request.forms.get("description")
    tags = bottle.request.forms.get("tags")

    my_username = login_check()
    try:
        username = bottle.request.query['to_user']
    except:
        username = my_username

    # set these up in case we have an error case
    errors = {'name': cgi.escape(name)}
    if (achievement.validate_new_achievement(name, errors)):
        id = achievement.new_achievement(connection, name, description, tags)
        if (username == my_username):
            print "to me"
            print id
            achievement.add_challenge_to_me(connection, my_username, id)
        else:
            print "to friend"
            achievement.add_challenge_to_friend(connection, username,
                                                my_username, id)
        bottle.redirect("/main")
    else:
        print "user did not validate"
        return bottle.template("new_achievement", errors)
Example #3
0
def new_achievement():
    connection = pymongo.Connection(connection_string, safe=True)

    name = request.forms.get("name")
    description = request.forms.get("description")
    tags = request.forms.get("tags")
    username = request.forms.get("friend")
    my_username = login_check()

    # set these up in case we have an error case
    errors = {'name': cgi.escape(name)}
    if achievement.validate_new_achievement(name, errors):
        id = achievement.new_achievement(connection, name, description, tags)
        if len(username) is 0:
            achievement.add_challenge_to_me(connection, my_username, id)
        else:
            achievement.add_challenge_to_friend(connection, username, my_username, id)
        redirect("/main")
    else:
        print "user did not validate"
        return template("new_achievement", errors)
Example #4
0
def new_achievement():
    connection = pymongo.Connection(connection_string, safe=True)

    name = request.forms.get("name")
    description = request.forms.get("description")
    tags = request.forms.get("tags")
    username = request.forms.get("friend")
    my_username = login_check()

    # set these up in case we have an error case
    errors = {'name': cgi.escape(name)}
    if achievement.validate_new_achievement(name, errors):
        id = achievement.new_achievement(connection, name, description, tags)
        if len(username) is 0:
            achievement.add_challenge_to_me(connection, my_username, id)
        else:
            achievement.add_challenge_to_friend(connection, username,
                                                my_username, id)
        redirect("/main")
    else:
        print "user did not validate"
        return template("new_achievement", errors)