Пример #1
0
def add_new_entry(id):
    message = request.get_json()
    spec_message = message['text']
    email = message['email']
    user = User.get(email)
    spec_time = datetime.now()
    conversation = Conversation.get(id)
    new_message = ConversationEntry(text=spec_message, user=user, time=spec_time)
    conversation.entries.append(new_message)
    score = randint(-8, 20)
    vote = Vote(user=user, score=score, conversation=conversation)
    conversation.votes.append(vote)
    conversation.save()
    return '', 200
Пример #2
0
def get_conversation(id):
    conversation = Conversation.get(id)
    if conversation == None:
        return '', 404
    else:
        return jsonify(conversation.to_json)