mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-09 22:30:17 +00:00
Attachment filtering by filename (#12807)
* Attachment filtering by filename * Update API version
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user