mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	fixes the docker build. also: proper 404 for missing documents/thumbnails
This commit is contained in:
		| @@ -10,7 +10,7 @@ COPY src-ui/package* ./ | ||||
| RUN npm install | ||||
|  | ||||
| COPY src-ui . | ||||
| RUN node_modules/.bin/ng build --prod --output-hashing none --sourceMap=false | ||||
| RUN node_modules/.bin/ng build --prod --output-hashing none --sourceMap=false --output-path dist/paperless-ui | ||||
|  | ||||
| ############################################################################### | ||||
| ### Back end                                                                ### | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| from django.db.models import Count, Max | ||||
| from django.http import HttpResponse, HttpResponseBadRequest | ||||
| from django.http import HttpResponse, HttpResponseBadRequest, Http404 | ||||
| from django.views.decorators.cache import cache_control | ||||
| from django.views.generic import TemplateView | ||||
| from django_filters.rest_framework import DjangoFilterBackend | ||||
| @@ -140,17 +140,27 @@ class DocumentViewSet(RetrieveModelMixin, | ||||
|  | ||||
|     @action(methods=['get'], detail=True) | ||||
|     def preview(self, request, pk=None): | ||||
|         try: | ||||
|             response = self.file_response(pk, "inline") | ||||
|             return response | ||||
|         except FileNotFoundError: | ||||
|             raise Http404("Document source file does not exist") | ||||
|  | ||||
|     @action(methods=['get'], detail=True) | ||||
|     @cache_control(public=False, max_age=315360000) | ||||
|     def thumb(self, request, pk=None): | ||||
|         try: | ||||
|             return HttpResponse(Document.objects.get(id=pk).thumbnail_file, content_type='image/png') | ||||
|         except FileNotFoundError: | ||||
|             raise Http404("Document thumbnail does not exist") | ||||
|  | ||||
|     @action(methods=['get'], detail=True) | ||||
|     def download(self, request, pk=None): | ||||
|         try: | ||||
|             return self.file_response(pk, "attachment") | ||||
|         except FileNotFoundError: | ||||
|             raise Http404("Document source file does not exist") | ||||
|  | ||||
|  | ||||
|  | ||||
| class LogViewSet(ReadOnlyModelViewSet): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler