This commit is contained in:
jonaswinkler 2020-12-09 22:16:57 +01:00
parent 8ca97924be
commit 6003122b06

View File

@ -248,7 +248,7 @@ class Consumer(LoggingMixin):
with open(self.path, "rb") as f: with open(self.path, "rb") as f:
document = Document.objects.create( document = Document.objects.create(
correspondent=file_info.correspondent, correspondent=file_info.correspondent,
title=file_info.title, title=(self.override_title or file_info.title)[:127],
content=text, content=text,
mime_type=mime_type, mime_type=mime_type,
checksum=hashlib.md5(f.read()).hexdigest(), checksum=hashlib.md5(f.read()).hexdigest(),
@ -265,12 +265,11 @@ class Consumer(LoggingMixin):
self.apply_overrides(document) self.apply_overrides(document)
document.save()
return document return document
def apply_overrides(self, document): def apply_overrides(self, document):
if self.override_title:
document.title = self.override_title
if self.override_correspondent_id: if self.override_correspondent_id:
document.correspondent = Correspondent.objects.get( document.correspondent = Correspondent.objects.get(
pk=self.override_correspondent_id) pk=self.override_correspondent_id)