Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Winkler committed Nov 13, 2020
2 parents ace6051 + d398030 commit 4553320
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
Expand Down
20 changes: 15 additions & 5 deletions src/documents/views.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -140,17 +140,27 @@ def post_document(self, request, pk=None):

@action(methods=['get'], detail=True)
def preview(self, request, pk=None):
response = self.file_response(pk, "inline")
return response
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):
return HttpResponse(Document.objects.get(id=pk).thumbnail_file, content_type='image/png')
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):
return self.file_response(pk, "attachment")
try:
return self.file_response(pk, "attachment")
except FileNotFoundError:
raise Http404("Document source file does not exist")



class LogViewSet(ReadOnlyModelViewSet):
Expand Down

0 comments on commit 4553320

Please sign in to comment.