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:
34
mayan/apps/checkouts/methods.py
Normal file
34
mayan/apps/checkouts/methods.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import apps
|
||||
|
||||
|
||||
def method_check_in(self, user=None):
|
||||
DocumentCheckout = apps.get_model(
|
||||
app_label='checkouts', model_name='DocumentCheckout'
|
||||
)
|
||||
|
||||
return DocumentCheckout.objects.check_in_document(
|
||||
document=self, user=user
|
||||
)
|
||||
|
||||
|
||||
def method_get_check_out_info(self):
|
||||
DocumentCheckout = apps.get_model(
|
||||
app_label='checkouts', model_name='DocumentCheckout'
|
||||
)
|
||||
return DocumentCheckout.objects.get_check_out_info(document=self)
|
||||
|
||||
|
||||
def method_get_check_out_state(self):
|
||||
DocumentCheckout = apps.get_model(
|
||||
app_label='checkouts', model_name='DocumentCheckout'
|
||||
)
|
||||
return DocumentCheckout.objects.get_check_out_state(document=self)
|
||||
|
||||
|
||||
def method_is_checked_out(self):
|
||||
DocumentCheckout = apps.get_model(
|
||||
app_label='checkouts', model_name='DocumentCheckout'
|
||||
)
|
||||
return DocumentCheckout.objects.is_checked_out(document=self)
|
||||
Reference in New Issue
Block a user