A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
replaced usages of .id with .pk, fixed filename issue in exporter
Jonas Winkler68df1cf4ee10
diff --git a/src/documents/classifier.py b/src/documents/classifier.pyindex 52c508655..851a75899 100755--- a/src/documents/classifier.py+++ b/src/documents/classifier.py@@ -75,16 +75,16 @@ class DocumentClassifier(object):y = -1if doc.document_type:if doc.document_type.matching_algorithm == MatchingModel.MATCH_AUTO:- y = doc.document_type.id+ y = doc.document_type.pklabels_document_type.append(y)y = -1if doc.correspondent:if doc.correspondent.matching_algorithm == MatchingModel.MATCH_AUTO:- y = doc.correspondent.id+ y = doc.correspondent.pklabels_correspondent.append(y)- tags = [tag.id for tag in doc.tags.filter(+ tags = [tag.pk for tag in doc.tags.filter(matching_algorithm=MatchingModel.MATCH_AUTO)]labels_tags.append(tags)diff --git a/src/documents/index.py b/src/documents/index.pyindex 33a745701..eb1a9c739 100644--- a/src/documents/index.py+++ b/src/documents/index.py@@ -69,7 +69,7 @@ def open_index(recreate=False):def update_document(writer, doc):logging.getLogger(__name__).debug("Updating index with document{}".format(str(doc)))writer.update_document(- id=doc.id,+ id=doc.pk,title=doc.title,content=doc.content)@@ -87,7 +87,7 @@ def remove_document_from_index(sender, instance, **kwargs):logging.getLogger(__name__).debug("Removing document {} from index".format(str(instance)))ix = open_index()with AsyncWriter(ix) as writer:- writer.delete_by_term('id', instance.id)+ writer.delete_by_term('id', instance.pk)def autocomplete(ix, term, limit=10):diff --git a/src/documents/management/commands/document_exporter.py b/src/documents/management/commands/document_exporter.pyindex 502bec0c1..43582a619 100644--- a/src/documents/management/commands/document_exporter.py+++ b/src/documents/management/commands/document_exporter.py@@ -64,12 +64,14 @@ class Command(Renderable, BaseCommand):document = document_map[document_dict["pk"]]- file_target = os.path.join(self.target, document.file_name)+ unique_filename = "{:07}_{}".format(document.pk, document.file_name)- thumbnail_name = document.file_name + "-thumbnail.png"+ file_target = os.path.join(self.target, unique_filename)++ thumbnail_name = unique_filename + "-thumbnail.png"thumbnail_target = os.path.join(self.target, thumbnail_name)- document_dict[EXPORTER_FILE_NAME] = document.file_name+ document_dict[EXPORTER_FILE_NAME] = unique_filenamedocument_dict[EXPORTER_THUMBNAIL_NAME] = thumbnail_nameprint("Exporting: {}".format(file_target))diff --git a/src/documents/matching.py b/src/documents/matching.pyindex a52f06a06..045e2863a 100644--- a/src/documents/matching.py+++ b/src/documents/matching.py@@ -9,7 +9,7 @@ def match_correspondents(document_content, classifier):correspondents = Correspondent.objects.all()predicted_correspondent_id = classifier.predict_correspondent(document_content) if classifier else None- matched_correspondents = [o for o in correspondents if matches(o, document_content) or o.id == predicted_correspondent_id]+ matched_correspondents = [o for o in correspondents if matches(o, document_content) or o.pk == predicted_correspondent_id]return matched_correspondents@@ -17,7 +17,7 @@ def match_document_types(document_content, classifier):document_types = DocumentType.objects.all()predicted_document_type_id = classifier.predict_document_type(document_content) if classifier else None- matched_document_types = [o for o in document_types if matches(o, document_content) or o.id == predicted_document_type_id]+ matched_document_types = [o for o in document_types if matches(o, document_content) or o.pk == predicted_document_type_id]return matched_document_types@@ -25,7 +25,7 @@ def match_tags(document_content, classifier):objects = Tag.objects.all()predicted_tag_ids = classifier.predict_tags(document_content) if classifier else []- matched_tags = [o for o in objects if matches(o, document_content) or o.id in predicted_tag_ids]+ matched_tags = [o for o in objects if matches(o, document_content) or o.pk in predicted_tag_ids]return matched_tagsdiff --git a/src/documents/signals/handlers.py b/src/documents/signals/handlers.pyindex def1d5a5f..edabfe0aa 100755--- a/src/documents/signals/handlers.py+++ b/src/documents/signals/handlers.py@@ -134,7 +134,7 @@ def run_post_consume_script(sender, document, **kwargs):Popen((settings.POST_CONSUME_SCRIPT,- str(document.id),+ str(document.pk),document.file_name,document.source_path,document.thumbnail_path,@@ -166,7 +166,7 @@ def set_log_entry(sender, document=None, logging_group=None, **kwargs):action_flag=ADDITION,action_time=timezone.now(),content_type=ct,- object_id=document.id,+ object_id=document.pk,user=user,object_repr=document.__str__(),)