Refactor the model accesors

Refactor the accesors to behave like methods instead of properties.
This means all accesors will be prepended with the string
"get_" and will include a set of parenthesis.

Improve the ModeAttribute class to use the method's
short_description. This commit also adds support for a
new method .help_text attribute has been added.

Move accessors to their own module, named "methods.py".

Remove the PropertyHelper class as the accessors no longer
need it.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-15 04:49:40 -04:00
parent 8c63ef4c69
commit 0e86f2ad8a
42 changed files with 434 additions and 282 deletions
+4 -17
View File
@@ -19,10 +19,11 @@ from mayan.apps.common.widgets import TwoStateWidget
from mayan.apps.navigation import SourceColumn
from mayan.celery import app
from .classes import DocumentStateHelper, WorkflowAction
from .classes import WorkflowAction
from .handlers import (
handler_index_document, handler_trigger_transition, launch_workflow
)
from .methods import method_get_workflow
from .links import (
link_document_workflow_instance_list, link_setup_workflow_create,
link_setup_workflow_delete, link_setup_workflow_document_types,
@@ -84,28 +85,14 @@ class DocumentStatesApp(MayanAppConfig):
)
Document.add_to_class(
name='workflow', value=DocumentStateHelper.constructor
name='get_workflow', value=method_get_workflow
)
ErrorLogEntry.objects.register(model=WorkflowStateAction)
WorkflowAction.initialize()
ModelAttribute(
model=Document,
name='workflow.< workflow internal name >.get_current_state()',
label=_('Current state of a workflow'), description=_(
'Return the current state of the selected workflow'
)
)
ModelAttribute(
model=Document,
name='workflow.< workflow internal name >.get_current_state().completion',
label=_('Current state of a workflow'), description=_(
'Return the completion value of the current state of the '
'selected workflow'
)
)
ModelAttribute(model=Document, name='get_workflow')
ModelPermission.register(
model=Document, permissions=(permission_workflow_view,)