Attachment filtering by filename (#12807)

* Attachment filtering by filename

* Update API version
This commit is contained in:
Oliver
2026-09-08 09:25:20 +10:00
committed by GitHub
parent 5ffd777f5d
commit ef42a7b309
2 changed files with 9 additions and 2 deletions
@@ -1,11 +1,14 @@
"""InvenTree API version information."""
# InvenTree API version
INVENTREE_API_VERSION = 543
INVENTREE_API_VERSION = 544
"""Increment this API version number whenever there is a significant change to the API that any clients need to know about."""
INVENTREE_API_TEXT = """
v544 -> 2026-09-07 : https://github.com/inventree/InvenTree/pull/12807
- Adds filtering by filename on the Attachment list API endpoint
v543 -> 2026-09-05 : https://github.com/inventree/InvenTree/pull/12762
- Adds admin APIs for managing SSO applications
+5 -1
View File
@@ -873,6 +873,10 @@ class AttachmentFilter(FilterSet):
tag_name = common.filters.TagsFilter()
filename = rest_filters.CharFilter(
field_name='attachment', lookup_expr='icontains', label=_('Filename')
)
def get_viewable_attachment_model_types(user) -> set:
"""Return the set of attachment 'model_type' labels the user has 'view' permission for.
@@ -909,7 +913,7 @@ class AttachmentList(AttachmentMixin, BulkDeleteMixin, ListCreateAPI):
filterset_class = AttachmentFilter
ordering_fields = ['model_id', 'model_type', 'upload_date', 'file_size']
search_fields = ['comment', 'model_id', 'model_type']
search_fields = ['comment', 'model_id', 'model_type', 'attachment']
def get_queryset(self):
"""Restrict the queryset to attachments linked to a model the user can view."""