Пример #1
0
def request_poem():
    form = PoetryRequest(request.form)
    if request.method == 'POST':
        victim_list = User.objects(username = form.username_request.data)
        traverse = form.friends.data
        if victim_list:
            victim = victim_list[0]
        else:
            victim = random.choice(User.objects)
        if form.haiku.data:
            poem = make_haiku(victim, traverse)
        else:
            poem = make_stanza(victim, traverse)
        return redirect("/poems/{0}".format(poem.poem_id))
    return render_template('request.html', form=form)
Пример #2
0
def get_friend(user):
    """Returns a random user object from a list of friends."""
    friend = random.choice(user.friends)
    return User.objects(username=friend)[0]
Пример #3
0
def get_friend(user):
    """Returns a random user object from a list of friends."""
    friend = random.choice(user.friends)
    return User.objects(username = friend)[0]