mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-02 19:08:47 +00:00
Update note accessors
This commit is contained in:
@@ -707,9 +707,23 @@ class InvenTreeNoteMixin(InvenTreePermissionCheckMixin):
|
|||||||
if len(notes) > 0:
|
if len(notes) > 0:
|
||||||
common.models.Note.objects.bulk_create(notes, batch_size=250)
|
common.models.Note.objects.bulk_create(notes, batch_size=250)
|
||||||
|
|
||||||
def get_note(self, title: str):
|
@property
|
||||||
"""Return a Note instance for the given note title."""
|
def primary_note(self):
|
||||||
return self.notes_list.filter(title=title).first()
|
"""Return the primary note for this model instance, if it exists."""
|
||||||
|
return self.notes_list.all().order_by('-primary').first()
|
||||||
|
|
||||||
|
def get_note(self, title: Optional[str] = None):
|
||||||
|
"""Return a Note instance for the given note title.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
title: Title of the note to retrieve. If None, returns the primary note (if it exists)
|
||||||
|
"""
|
||||||
|
notes = self.notes_list.all().order_by('-primary')
|
||||||
|
|
||||||
|
if title:
|
||||||
|
notes = notes.filter(title=title)
|
||||||
|
|
||||||
|
return notes.first()
|
||||||
|
|
||||||
def check_note_delete(self, note) -> bool:
|
def check_note_delete(self, note) -> bool:
|
||||||
"""Run a check to determine if the provided note can be deleted.
|
"""Run a check to determine if the provided note can be deleted.
|
||||||
|
|||||||
Reference in New Issue
Block a user