mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-03 19:17:13 -05:00 
			
		
		
		
	Merge branch 'jat255-ENH_config_inline_or_attach'
This commit is contained in:
		
						commit
						66db06590d
					
				@ -117,6 +117,10 @@ PAPERLESS_EMAIL_SECRET=""
 | 
			
		||||
# http://paperless.readthedocs.org/en/latest/consumption.html#hooking-into-the-consumption-process
 | 
			
		||||
#PAPERLESS_POST_CONSUME_SCRIPT="/path/to/an/arbitrary/script.sh"
 | 
			
		||||
 | 
			
		||||
# By default, when clicking on a document within the web interface, the
 | 
			
		||||
# browser will prompt the user to save the document to disk. By setting this to
 | 
			
		||||
# "true", the document will instead be opened in the browser, if possible.
 | 
			
		||||
#PAPERLESS_INLINE_DOC="false"
 | 
			
		||||
 | 
			
		||||
#
 | 
			
		||||
# The following values use sensible defaults for modern systems, but if you're
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,8 @@
 | 
			
		||||
from django.http import HttpResponse, HttpResponseBadRequest
 | 
			
		||||
from django.views.generic import DetailView, FormView, TemplateView
 | 
			
		||||
from django_filters.rest_framework import DjangoFilterBackend
 | 
			
		||||
from django.conf import settings
 | 
			
		||||
 | 
			
		||||
from paperless.db import GnuPG
 | 
			
		||||
from paperless.mixins import SessionOrBasicAuthMixin
 | 
			
		||||
from paperless.views import StandardPagination
 | 
			
		||||
@ -63,8 +65,11 @@ class FetchView(SessionOrBasicAuthMixin, DetailView):
 | 
			
		||||
            self._get_raw_data(self.object.source_file),
 | 
			
		||||
            content_type=content_types[self.object.file_type]
 | 
			
		||||
        )
 | 
			
		||||
        response["Content-Disposition"] = 'attachment; filename="{}"'.format(
 | 
			
		||||
            self.object.file_name)
 | 
			
		||||
 | 
			
		||||
        DISPOSITION = 'inline' if settings.INLINE_DOC else 'attachment'
 | 
			
		||||
 | 
			
		||||
        response["Content-Disposition"] = '{}; filename="{}"'.format(
 | 
			
		||||
            DISPOSITION, self.object.file_name)
 | 
			
		||||
 | 
			
		||||
        return response
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -22,6 +22,14 @@ elif os.path.exists("/usr/local/etc/paperless.conf"):
 | 
			
		||||
    load_dotenv("/usr/local/etc/paperless.conf")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def __get_boolean(key):
 | 
			
		||||
    """
 | 
			
		||||
    Return a boolean value based on whatever the user has supplied in the
 | 
			
		||||
    environment based on whether the value "looks like" it's True or not.
 | 
			
		||||
    """
 | 
			
		||||
    return bool(os.getenv(key, "NO").lower() in ("yes", "y", "1", "t", "true"))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
 | 
			
		||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 | 
			
		||||
 | 
			
		||||
@ -222,12 +230,12 @@ OCR_LANGUAGE = os.getenv("PAPERLESS_OCR_LANGUAGE", "eng")
 | 
			
		||||
OCR_THREADS = os.getenv("PAPERLESS_OCR_THREADS")
 | 
			
		||||
 | 
			
		||||
# OCR all documents?
 | 
			
		||||
OCR_ALWAYS = bool(os.getenv("PAPERLESS_OCR_ALWAYS", "NO").lower() in ("yes", "y", "1", "t", "true"))  # NOQA
 | 
			
		||||
OCR_ALWAYS = __get_boolean("PAPERLESS_OCR_ALWAYS")
 | 
			
		||||
 | 
			
		||||
# If this is true, any failed attempts to OCR a PDF will result in the PDF
 | 
			
		||||
# being indexed anyway, with whatever we could get.  If it's False, the file
 | 
			
		||||
# will simply be left in the CONSUMPTION_DIR.
 | 
			
		||||
FORGIVING_OCR = bool(os.getenv("PAPERLESS_FORGIVING_OCR", "YES").lower() in ("yes", "y", "1", "t", "true"))  # NOQA
 | 
			
		||||
FORGIVING_OCR = __get_boolean("PAPERLESS_FORGIVING_OCR")
 | 
			
		||||
 | 
			
		||||
# GNUPG needs a home directory for some reason
 | 
			
		||||
GNUPG_HOME = os.getenv("HOME", "/tmp")
 | 
			
		||||
@ -271,6 +279,9 @@ PASSPHRASE = os.getenv("PAPERLESS_PASSPHRASE")
 | 
			
		||||
PRE_CONSUME_SCRIPT = os.getenv("PAPERLESS_PRE_CONSUME_SCRIPT")
 | 
			
		||||
POST_CONSUME_SCRIPT = os.getenv("PAPERLESS_POST_CONSUME_SCRIPT")
 | 
			
		||||
 | 
			
		||||
# Whether to display a selected document inline, or download it as attachment:
 | 
			
		||||
INLINE_DOC = __get_boolean("PAPERLESS_INLINE_DOC")
 | 
			
		||||
 | 
			
		||||
# The number of items on each page in the web UI.  This value must be a
 | 
			
		||||
# positive integer, but if you don't define one in paperless.conf, a default of
 | 
			
		||||
# 100 will be used.
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user