Beispiel #1
0
def write():
    if request.method == 'GET':
        return render_template('write.html')
    elif request.method == 'POST':
        note_date = request.form["note_date"]
        note_content = request.form["note_content"]
        note_content = cgi.escape(note_content)
        note_content = format_textarea(note_content)
        try:
            note_date = datetime.datetime.strptime(note_date, '%Y-%m-%d')
        except ValueError:
            note_date = datetime.datetime.now()

        user_id = get_user_id()
        Note.create(user_id,  note_content, note_date)
        return redirect(url_for("notes"))
Beispiel #2
0
def add_notes():
    print 'add notes......'
    liaofeng = User.query_obj.get_by_email('*****@*****.**')
    huangxin = User.query_obj.get_by_email('*****@*****.**')
    date1 = datetime(2013, 03, 01)
    date2 = datetime(2013, 04, 01)
    for user in [liaofeng, huangxin]:
        content = '''
            寻寻觅觅,
            冷冷清清,
            凄凄惨惨戚戚。
            乍暖还寒时候,
            最难将息。
            三杯两盏淡酒,
            怎敌他、晚来风急?
            雁过也,
            正伤心,
            却是旧时相识。

            满地黄花堆积。
            憔悴损,
            如今有谁堪摘?
            守著窗儿,
            独自怎生得黑?
            梧桐更兼细雨,
            到黄昏、点点滴滴。
            这次第,
            怎一个、愁字了得!'''
        Note.create(user.id, content, date1)

        content = '''
            常记溪亭日暮,
            沉醉不知归路。
            兴尽晚回舟,
            误入藕花深处。
            争渡,争渡,
            惊起一滩鸥鹭。 '''
        Note.create(user.id, content, date2)
Beispiel #3
0
def notes():
    users = User.query.all()
    user = users[0]
    notes = Note.gets_by_author(user.id)
    return render_template('note_list.html', notes=notes, user=user)
Beispiel #4
0
def note(note_id):
    note = Note.get(note_id)
    return render_template('note.html', note=note)