Esempio n. 1
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)
Esempio n. 2
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)
    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
            )
Esempio n. 3
0
def notes(datenum=None):
    user_id = get_user_id()
    if datenum is None:
        notes = Note.query_obj.get_notes_by_author(user_id)
        datenum = ''
    else:
        notes = Note.query_obj.get_notes_by_datenum(user_id,datenum)
    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)
Esempio n. 4
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
            )
Esempio n. 5
0
def latest():
    user_id = get_user_id()
    note = Note.query_obj.get_recent_note_by_user(user_id)
    note.weekday = get_local_weekday(note.time)
    note.time = get_local_date(note.time)
    return render_template('note.html', note=note)