2020from sqlalchemy import or_
2121from sqlalchemy .exc import IntegrityError
2222from datetime import datetime
23+ from flask_sqlalchemy .pagination import Pagination
2324
2425from app import db
2526from app .datamgmt .persistence_error import PersistenceError
2627from app .blueprints .iris_user import iris_current_user
2728from app .datamgmt .manage .manage_attribute_db import get_default_custom_attributes
2829from app .datamgmt .states import update_notes_state
29- from app .models .comments import Comments , NotesComments
30+ from app .models .comments import Comments
31+ from app .models .comments import NotesComments
3032from app .models .models import NoteDirectory
3133from app .models .models import NoteRevisions
3234from app .models .models import Notes
3537from app .models .authorization import User
3638from app .models .cases import Cases
3739from app .models .models import Client
40+ from app .models .pagination_parameters import PaginationParameters
41+ from app .datamgmt .filtering import paginate
3842
3943
4044def get_note (note_id ):
@@ -164,7 +168,7 @@ def update_note_revision(note: Notes) -> bool:
164168 raise PersistenceError (e )
165169
166170
167- def add_note (note_title , creation_date , user_id , caseid , directory_id , note_content = "" ):
171+ def add_note (note_title , creation_date , user_id , caseid , directory_id , note_content = '' ):
168172 note = Notes ()
169173 note .note_title = note_title
170174 note .note_creationdate = note .note_lastupdate = creation_date
@@ -279,7 +283,7 @@ def add_note_group(group_title, caseid, userid, creationdate):
279283 db .session .commit ()
280284
281285 if group_title == '' :
282- ng .group_title = " New notes group"
286+ ng .group_title = ' New notes group'
283287
284288 db .session .commit ()
285289
@@ -420,7 +424,7 @@ def delete_note_comment(note_id, comment_id):
420424 Comments .comment_user_id == iris_current_user .id
421425 ).first ()
422426 if not comment :
423- return False , " You are not allowed to delete this comment"
427+ return False , ' You are not allowed to delete this comment'
424428
425429 NotesComments .query .filter (
426430 NotesComments .comment_note_id == note_id ,
@@ -430,7 +434,7 @@ def delete_note_comment(note_id, comment_id):
430434 db .session .delete (comment )
431435 db .session .commit ()
432436
433- return True , " Comment deleted"
437+ return True , ' Comment deleted'
434438
435439
436440def get_directories_with_note_count (case_id ):
@@ -454,16 +458,10 @@ def get_directories_with_note_count(case_id):
454458 return directories_with_note_count
455459
456460
457- def paginate_notes_directories (case_id ):
458- query = NoteDirectory .query .filter_by (case_id = case_id ).order_by (
459- NoteDirectory .name .asc ()
460- )
461+ def paginate_notes_directories (case_id , pagination_parameters : PaginationParameters ) -> Pagination :
462+ query = NoteDirectory .query .filter_by (case_id = case_id )
461463
462- return query .paginate (
463- #page=pagination_parameters.get_page(),
464- #per_page=pagination_parameters.get_per_page(),
465- error_out = False
466- )
464+ return paginate (NoteDirectory , pagination_parameters , query )
467465
468466def get_directory_with_note_count (directory ):
469467 note_count = Notes .query .filter_by (directory_id = directory .id ).count ()
0 commit comments