def test_admin_delete(self, client, fake_auth, mock_coe_advising_note): """Admin can delete another user's note.""" original_count_per_sid = len(Note.get_notes_by_sid(mock_coe_advising_note.sid)) fake_auth.login(admin_uid) note_id = mock_coe_advising_note.id response = client.delete(f'/api/notes/delete/{note_id}') assert response.status_code == 200 assert not Note.find_by_id(note_id) assert 1 == original_count_per_sid - len(Note.get_notes_by_sid(mock_coe_advising_note.sid)) assert not Note.update(note_id=note_id, subject='Deleted note cannot be updated')
def get_non_legacy_advising_notes(sid): notes_by_id = {} for note in [n.to_api_json() for n in Note.get_notes_by_sid(sid)]: note_id = note['id'] notes_by_id[str(note_id)] = note_to_compatible_json( note=note, attachments=note.get('attachments'), topics=note.get('topics'), ) return notes_by_id
def get_non_legacy_advising_notes(sid): notes_by_id = {} for row in Note.get_notes_by_sid(sid): note = row.__dict__ note_id = note['id'] notes_by_id[str(note_id)] = note_to_compatible_json( note=note, attachments=[ a.to_api_json() for a in row.attachments if not a.deleted_at ], topics=[t.to_api_json() for t in row.topics if not t.deleted_at], ) return notes_by_id
def _asc_note_with_attachment(): for note in Note.get_notes_by_sid('11667051'): if len(note.attachments): return note return None