示例#1
0
def latest():
    user_id = get_user_id()
    note = Note.query_obj.get_recent_note_by_user(user_id)
    if not note:
        return redirect(url_for('no_notes'))
    note.weekday = get_local_weekday(note.time)
    note.time = get_local_date(note.time)
    return render_template('note.html', note=note)
示例#2
0
def get_notes_by_date():
    user_id = get_user_id()
    datenum = int(request.args.get('datenum'))
    notes = Note.query_obj.get_notes_by_datenum(user_id,datenum)
    json_note_list = []
    for note in notes:
        note.weekday = get_local_weekday(note.time)
        note.time = get_local_date(note.time)
        json_note_list = json.dumps(new(note),cls=MyEncoder)
    return json.dumps(json_note_list)
示例#3
0
def get_random_note():
    note_id = int(request.args.get('note_id'))
    user_id = get_user_id()
    note_list = Note.query_obj.get_notes_by_author(user_id)
    note = note_list[randint(0, len(note_list)-1)]
    note_id = note.id
    note_content = note.content
    note_weekday = get_local_weekday(note.time)
    note_time = get_local_date(note.time)
    return jsonify(
                id = note_id,
                weekday = note_weekday,
                time = note_time,
                content = note_content
            )
示例#4
0
def get_newer_note():
    note_id = int(request.args.get('note_id'))
    user_id = get_user_id()
    note = Note.query_obj.get_newer_note(user_id,note_id)
    if not note:
        note = Note.query_obj.get_note_by_id(note_id)
    note_id = note.id
    note_content = note.content
    note_weekday = get_local_weekday(note.time)
    note_time = get_local_date(note.time)
    return jsonify(
                id = note_id,
                weekday = note_weekday,
                time = note_time,
                content = note_content
            )
示例#5
0
def notes(datenum=None):
    user_id = get_user_id()
    notes = Note.query_obj.get_notes_by_author(user_id)
    if datenum is None:
        datenum = ''
    else:
        notes = [note for note in notes if str(note.datenum) == datenum]
    if not notes:
        return redirect(url_for('no_notes'))
    for note in notes:
        note.weekday = get_local_weekday(note.time)
        note.time = get_local_date(note.time)

    date_list = [str(d) for d, in Note.query_obj.get_datenum_by_user(user_id)]
    date_list = sorted(date_list,reverse=True)
    return render_template('note_list.html', notes=notes, date_list=date_list, datenum=datenum)