A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Updating Django admin event log on document_consumption_finished
Aleksandr Bogdanov71902d3f5cb7
diff --git a/src/documents/management/commands/document_consumer.py b/src/documents/management/commands/document_consumer.pyindex 0acdaeeb0..5f135fd22 100644--- a/src/documents/management/commands/document_consumer.py+++ b/src/documents/management/commands/document_consumer.py@@ -4,11 +4,16 @@ import osimport timefrom django.conf import settings+from django.contrib.contenttypes.models import ContentTypefrom django.core.management.base import BaseCommand, CommandError+from django.contrib.admin.models import LogEntry, ADDITION+from django.contrib.auth.models import User+from django.dispatch import receiver-from ...models import Log+from ...models import Documentfrom ...consumer import Consumer, ConsumerErrorfrom ...mail import MailFetcher, MailFetcherError+from ...signals import document_consumption_finishedclass Command(BaseCommand):@@ -16,7 +21,7 @@ class Command(BaseCommand):On every iteration of an infinite loop, consume what we can from theconsumption directory, and fetch any mail available."""-+ CONSUME_USER_ID = 1LOOP_TIME = 10 # SecondsMAIL_DELTA = datetime.timedelta(minutes=10)@@ -68,3 +73,17 @@ class Command(BaseCommand):delta = self.mail_fetcher.last_checked + self.MAIL_DELTAif delta < datetime.datetime.now():self.mail_fetcher.pull()++ @receiver(document_consumption_finished)+ def notify_finished(sender, document=None, logging_group=None, **kwargs):+ doctype = ContentType.objects.get_for_model(Document)+ user = User.objects.get(**{'id': Command.CONSUME_USER_ID})++ LogEntry.objects.log_action(+ user_id=user.pk,+ content_type_id=doctype.pk,+ object_id=document.pk,+ object_repr=repr(document),+ action_flag=ADDITION,+ change_message='Document %s consumption finished' % document.title+ )