Update api and templates for note and page
This commit is contained in:
@@ -26,30 +26,6 @@ def note_id(id: int)->dict:
|
||||
return result
|
||||
|
||||
|
||||
@jsonrpc.method('note.update')
|
||||
@login_required
|
||||
def note_update(title: str, body: str)->dict:
|
||||
"""Обновить заметку
|
||||
"""
|
||||
note = models.db_session.query(
|
||||
models.Note
|
||||
).filter(
|
||||
models.Note.id==id
|
||||
).first()
|
||||
if note is None:
|
||||
raise ValueError
|
||||
|
||||
note.title = title
|
||||
note.body = body
|
||||
|
||||
result = note.as_dict()
|
||||
result['user'] = note.user.as_dict()
|
||||
result['tags'] = []
|
||||
for tagLink in note.tags:
|
||||
result['tags'].append(tagLink.tag.as_dict())
|
||||
return result
|
||||
|
||||
|
||||
@jsonrpc.method('note.add')
|
||||
@login_required
|
||||
def note_add(title: str, body: str)->dict:
|
||||
@@ -91,6 +67,30 @@ def note_destroy(id: int)->bool:
|
||||
return True
|
||||
|
||||
|
||||
@jsonrpc.method('note.update')
|
||||
@login_required
|
||||
def note_update(id: int, title: str, body: str)->dict:
|
||||
"""Обновить заметку
|
||||
"""
|
||||
note = models.db_session.query(
|
||||
models.Note
|
||||
).filter(
|
||||
models.Note.id==id
|
||||
).first()
|
||||
if note is None:
|
||||
raise ValueError
|
||||
|
||||
note.title = title
|
||||
note.body = body
|
||||
|
||||
result = note.as_dict()
|
||||
result['user'] = note.user.as_dict()
|
||||
result['tags'] = []
|
||||
for tagLink in note.tags:
|
||||
result['tags'].append(tagLink.tag.as_dict())
|
||||
return result
|
||||
|
||||
|
||||
@jsonrpc.method('notes')
|
||||
def notes_list(page: int)->list:
|
||||
"""Список заметок
|
||||
|
||||
Reference in New Issue
Block a user