Add support to update the document indexes from workflow state changes.

Add a new workflow field called internal_name for easier workflow
reference in document index templates.
Generalize the PropertyHelper class.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-06-06 20:07:15 -04:00
parent f7f0d27a05
commit 5798cabd7c
30 changed files with 497 additions and 102 deletions
+26 -1
View File
@@ -103,7 +103,7 @@ class ModelAttribute(object):
)
return ' '.join(
[ugettext('Available attributes: '), ', '.join(result)]
[ugettext('Available attributes: \n'), ', \n'.join(result)]
)
def get_display(self, show_name=False):
@@ -208,3 +208,28 @@ class Package(object):
self.label = label
self.license_text = license_text
self.__class__._registry.append(self)
class PropertyHelper(object):
"""
Makes adding fields using __class__.add_to_class easier.
Each subclass must implement the `constructor` and the `get_result`
method.
"""
@staticmethod
@property
def constructor(source_object):
return PropertyHelper(source_object)
def __init__(self, instance):
self.instance = instance
def __getattr__(self, name):
return self.get_result(name=name)
def get_result(self, name):
"""
The method that produces the actual result. Must be implemented
by each subclass.
"""
raise NotImplementedError