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:
28
mayan/apps/document_parsing/methods.py
Normal file
28
mayan/apps/document_parsing/methods.py
Normal 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},
|
||||
)
|
||||
Reference in New Issue
Block a user