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>
This commit is contained in:
Roberto Rosario
2019-04-11 18:00:41 -04:00
parent a12c90268f
commit 456c322c19
33 changed files with 375 additions and 338 deletions

View File

@@ -0,0 +1,28 @@
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},
)