api.v1.views.AttachmentViewSet module¶
Module with the AttachmentViewSet viewset.
- class api.v1.views.AttachmentViewSet.AttachmentViewSet(**kwargs)[source]¶
Bases:
ReadOnlyModelViewSet,DestroyModelMixin,ToggleFavoriteMixinViewset for the
core.models.Attachment.Provides every read-only and a destroy action.
- BASENAME = 'attachment'¶
- serializer_class¶
alias of
BaseAttachmentSerializer
- filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>, <class 'rest_framework.filters.OrderingFilter'>]¶
- filterset_class¶
alias of
AttachmentFilterSet
- permission_classes = [<class 'rest_framework.permissions.IsAuthenticated'>]¶
- ordering_fields: Final[list[str]] = ['file_name', 'datasize', 'email__datetime', 'is_favorite', 'created', 'updated']¶
- get_queryset()[source]¶
Filters the data for entries connected to the request user.
- Return type:
- Returns:
The attachment entries matching the request user.
- URL_PATH_DOWNLOAD = 'download'¶
- URL_NAME_DOWNLOAD = 'download'¶
- download(request, pk=None)[source]¶
Action method downloading the attachment.
- Parameters:
- Raises:
Http404 – If the filepath is not in the database or it doesn’t exist.
- Return type:
- Returns:
A fileresponse containing the requested file.
- URL_PATH_DOWNLOAD_BATCH = 'download'¶
- URL_NAME_DOWNLOAD_BATCH = 'download-batch'¶
- download_batch(request)[source]¶
Action method downloading a batch of attachments.
- Parameters:
request (
Request) – The request triggering the action.- Raises:
Http404 – If no downloadable attachment has been requested.
ValidationError – If id param is missing or in invalid format.
- Return type:
Response|FileResponse- Returns:
A fileresponse containing the requested file.
- URL_PATH_THUMBNAIL = 'thumbnail'¶
- URL_NAME_THUMBNAIL = 'thumbnail'¶
- download_thumbnail(request, pk=None)[source]¶
Action method downloading the attachment thumbnail.
Returns the same filedata as ‘download’, but as inline.
- Parameters:
- Raises:
Http404 – If the filepath is not in the database or it doesn’t exist.
- Return type:
- Returns:
A fileresponse containing the requested file.
- URL_PATH_SHARE_TO_PAPERLESS = 'share/paperless'¶
- URL_NAME_SHARE_TO_PAPERLESS = 'share-to-paperless'¶
Action method sending the attachment to the users Paperless server.
- Parameters:
- Raises:
Http404 – If the filepath is not in the database or it doesn’t exist.
- Return type:
Response- Returns:
A fileresponse containing the requested file.
- URL_PATH_SHARE_TO_IMMICH = 'share/immich'¶
- URL_NAME_SHARE_TO_IMMICH = 'share-to-immich'¶
Action method sending the attachment to the users Immich server.
- Parameters:
- Raises:
Http404 – If the filepath is not in the database or it doesn’t exist.
- Return type:
Response- Returns:
A fileresponse containing the requested file.
- basename = None¶
- description = None¶
- destroy(request, *args, **kwargs)¶
- detail = None¶
- list(request, *args, **kwargs)¶
- name = None¶
- retrieve(request, *args, **kwargs)¶
- suffix = None¶