Files
mayan-edms/mayan/apps/document_parsing/methods.py
Roberto Rosario 456c322c19 Move add_to_class functions to their own module
* The new module is called methods.py and found on each app.
* Add keyword arguments to add_to_class instances.
* Remove catch all exception handling for the check in and
  check out views.
* Improve checkouts tests code reducing redundant code.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2019-04-11 18:03:53 -04:00

29 lines
818 B
Python

from __future__ import unicode_literals
from datetime import timedelta
from django.utils.timezone import now
from mayan.apps.common.settings import settings_db_sync_task_delay
from .events import event_parsing_document_version_submit
from .tasks import task_parse_document_version
def method_document_parsing_submit(self):
latest_version = self.latest_version
# Don't error out if document has no version
if latest_version:
latest_version.submit_for_parsing()
def method_document_version_parsing_submit(self):
event_parsing_document_version_submit.commit(
action_object=self.document, target=self
)
task_parse_document_version.apply_async(
eta=now() + timedelta(seconds=settings_db_sync_task_delay.value),
kwargs={'document_version_pk': self.pk},
)