Compare commits

...

8 Commits

Author SHA1 Message Date
jonaswinkler
eaf11ea134 changelog and versions 2020-12-16 22:39:13 +01:00
jonaswinkler
a59f8cd1b1 Merge branch 'master' into dev 2020-12-16 22:33:11 +01:00
jonaswinkler
e9affbc1cf revert the changes that caused issues in the admin. 2020-12-16 22:33:03 +01:00
jonaswinkler
aa8789ae31 fix up the migration for encrypted documents and a couple other associated issues. 2020-12-16 21:53:11 +01:00
jonaswinkler
5c310c51d4 fix up the migration for encrypted documents. 2020-12-16 21:08:41 +01:00
jonaswinkler
cf3fa50b55 these changes shouldn't have been commited at all. my bad. 2020-12-16 21:08:03 +01:00
jonaswinkler
7f933d373f fixes the decryption command not working. 2020-12-16 19:50:38 +01:00
jonaswinkler
ece94379d8 fixes #143 2020-12-16 19:35:21 +01:00
12 changed files with 81 additions and 21 deletions

View File

@@ -15,7 +15,7 @@ services:
POSTGRES_PASSWORD: paperless
webserver:
image: jonaswinkler/paperless-ng:0.9.7
image: jonaswinkler/paperless-ng:0.9.8
restart: always
depends_on:
- db

View File

@@ -5,7 +5,7 @@ services:
restart: always
webserver:
image: jonaswinkler/paperless-ng:0.9.7
image: jonaswinkler/paperless-ng:0.9.8
restart: always
depends_on:
- broker

View File

@@ -6,6 +6,15 @@ Changelog
*********
paperless-ng 0.9.8
##################
This release addresses two severe issues with the previous release.
* The delete buttons for document types, correspondents and tags were not working.
* The document section in the admin was causing internal server errors (500).
paperless-ng 0.9.7
##################

View File

@@ -95,7 +95,7 @@ export abstract class GenericListComponent<T extends ObjectWithId> implements On
activeModal.componentInstance.message = "Associated documents will not be deleted."
activeModal.componentInstance.btnClass = "btn-danger"
activeModal.componentInstance.btnCaption = "Delete"
activeModal.componentInstance.confirmPressed.subscribe(() => {
activeModal.componentInstance.confirmClicked.subscribe(() => {
this.service.delete(object).subscribe(_ => {
activeModal.close()
this.reloadData()

View File

@@ -2,5 +2,5 @@ export const environment = {
production: true,
apiBaseUrl: "/api/",
appTitle: "Paperless-ng",
version: "0.9.7"
version: "0.9.8"
};

View File

@@ -69,7 +69,7 @@ class DocumentAdmin(admin.ModelAdmin):
filter_horizontal = ("tags",)
ordering = ["-created", "correspondent"]
ordering = ["-created"]
date_hierarchy = "created"

View File

@@ -2,7 +2,6 @@ import os
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from termcolor import colored as coloured
from documents.models import Document
from paperless.db import GnuPG
@@ -26,16 +25,14 @@ class Command(BaseCommand):
def handle(self, *args, **options):
try:
print(coloured(
print(
"\n\nWARNING: This script is going to work directly on your "
"document originals, so\nWARNING: you probably shouldn't run "
"this unless you've got a recent backup\nWARNING: handy. It "
"*should* work without a hitch, but be safe and backup your\n"
"WARNING: stuff first.\n\nHit Ctrl+C to exit now, or Enter to "
"continue.\n\n",
"yellow",
attrs=("bold",)
))
"continue.\n\n"
)
__ = input()
except KeyboardInterrupt:
return
@@ -57,8 +54,8 @@ class Command(BaseCommand):
for document in encrypted_files:
print(coloured("Decrypting {}".format(
document).encode('utf-8'), "green"))
print("Decrypting {}".format(
document).encode('utf-8'))
old_paths = [document.source_path, document.thumbnail_path]

View File

@@ -6,13 +6,17 @@ import magic
from django.conf import settings
from django.db import migrations, models
from paperless.db import GnuPG
STORAGE_TYPE_UNENCRYPTED = "unencrypted"
STORAGE_TYPE_GPG = "gpg"
def source_path(self):
if self.filename:
fname = str(self.filename)
else:
fname = "{:07}.{}".format(self.pk, self.file_type)
if self.storage_type == self.STORAGE_TYPE_GPG:
if self.storage_type == STORAGE_TYPE_GPG:
fname += ".gpg"
return os.path.join(
@@ -26,9 +30,18 @@ def add_mime_types(apps, schema_editor):
documents = Document.objects.all()
for d in documents:
d.mime_type = magic.from_file(source_path(d), mime=True)
f = open(source_path(d), "rb")
if d.storage_type == STORAGE_TYPE_GPG:
data = GnuPG.decrypted(f)
else:
data = f.read(1024)
d.mime_type = magic.from_buffer(data, mime=True)
d.save()
f.close()
def add_file_extensions(apps, schema_editor):
Document = apps.get_model("documents", "Document")

View File

@@ -0,0 +1,29 @@
# Generated by Django 3.1.4 on 2020-12-16 20:05
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('documents', '1008_auto_20201216_1736'),
]
operations = [
migrations.AlterModelOptions(
name='correspondent',
options={'ordering': ('name',)},
),
migrations.AlterModelOptions(
name='documenttype',
options={'ordering': ('name',)},
),
migrations.AlterModelOptions(
name='savedview',
options={'ordering': ('name',)},
),
migrations.AlterModelOptions(
name='tag',
options={'ordering': ('name',)},
),
]

View File

@@ -11,7 +11,6 @@ import dateutil.parser
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from django.db.models.functions import Lower
from django.utils import timezone
from documents.file_handling import archive_name_from_filename
@@ -61,7 +60,7 @@ class MatchingModel(models.Model):
class Meta:
abstract = True
ordering = (Lower("name"),)
ordering = ("name",)
def __str__(self):
return self.name
@@ -79,6 +78,9 @@ class Correspondent(MatchingModel):
# better safe than sorry.
SAFE_REGEX = re.compile(r"^[\w\- ,.']+$")
class Meta:
ordering = ("name",)
class Tag(MatchingModel):
@@ -307,7 +309,7 @@ class SavedView(models.Model):
class Meta:
ordering = (Lower("name"),)
ordering = ("name",)
user = models.ForeignKey(User, on_delete=models.CASCADE)
name = models.CharField(max_length=128)

View File

@@ -169,7 +169,12 @@ class DocumentViewSet(RetrieveModelMixin,
parser_class = get_parser_class_for_mime_type(mime_type)
if parser_class:
parser = parser_class(logging_group=None)
return parser.extract_metadata(file, mime_type)
try:
return parser.extract_metadata(file, mime_type)
except Exception as e:
# TODO: cover GPG errors, remove later.
return []
else:
return []
@@ -215,7 +220,12 @@ class DocumentViewSet(RetrieveModelMixin,
@cache_control(public=False, max_age=315360000)
def thumb(self, request, pk=None):
try:
return HttpResponse(Document.objects.get(id=pk).thumbnail_file,
doc = Document.objects.get(id=pk)
if doc.storage_type == Document.STORAGE_TYPE_GPG:
handle = GnuPG.decrypted(doc.thumbnail_file)
else:
handle = doc.thumbnail_file
return HttpResponse(handle,
content_type='image/png')
except (FileNotFoundError, Document.DoesNotExist):
raise Http404()

View File

@@ -1 +1 @@
__version__ = (0, 9, 7)
__version__ = (0, 9, 8)