ITSA Workflow
This commit is contained in:
@@ -10,6 +10,7 @@ from pathlib import Path
|
||||
from urllib.parse import unquote
|
||||
|
||||
from trytond.model import ModelSingleton, ModelSQL, ModelView, fields
|
||||
from trytond.transaction import Transaction
|
||||
|
||||
|
||||
DOCUMENTATION_ROOT = Path(__file__).with_name('process_documentation')
|
||||
@@ -31,6 +32,10 @@ class ProcessDocumentation(ModelSingleton, ModelSQL, ModelView):
|
||||
|
||||
|
||||
def _html_content():
|
||||
html_file = Transaction().context.get('process_documentation_html')
|
||||
if html_file:
|
||||
return _html_file_content(html_file)
|
||||
|
||||
document = HTML_TEMPLATE % {
|
||||
'content': _documentation_content(),
|
||||
}
|
||||
@@ -39,6 +44,28 @@ def _html_content():
|
||||
}
|
||||
|
||||
|
||||
def _html_file_content(filename):
|
||||
path = (DOCUMENTATION_ROOT / Path(*filename.split('/'))).resolve()
|
||||
root = DOCUMENTATION_ROOT.resolve()
|
||||
common_path = os.path.commonpath([str(root), str(path)])
|
||||
if path != root and common_path == str(root):
|
||||
if path.exists() and path.is_file() and path.suffix.lower() == '.html':
|
||||
return IFRAME_TEMPLATE % {
|
||||
'document': html.escape(path.read_text(encoding='utf-8'),
|
||||
quote=True),
|
||||
}
|
||||
return _html_error('Documentation page not found: %s' % filename)
|
||||
|
||||
|
||||
def _html_error(message):
|
||||
document = HTML_TEMPLATE % {
|
||||
'content': '<p>%s</p>' % html.escape(message),
|
||||
}
|
||||
return IFRAME_TEMPLATE % {
|
||||
'document': html.escape(document, quote=True),
|
||||
}
|
||||
|
||||
|
||||
def _documentation_content():
|
||||
sections = []
|
||||
index = DOCUMENTATION_ROOT / 'README.md'
|
||||
|
||||
Reference in New Issue
Block a user