Use Jinja2 as the template engine

Use Jinja2 to render the templates of the indexing,
workflows, smart links, user mailer and metadata apps.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-11-25 02:13:26 -04:00
parent 42d434f7bb
commit 6a7cd09bc1
9 changed files with 31 additions and 28 deletions
+2 -2
View File
@@ -91,14 +91,14 @@ class DocumentStatesApp(MayanAppConfig):
ModelAttribute(
model=Document,
name='workflow.< workflow internal name >.get_current_state',
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',
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'
+1 -1
View File
@@ -15,6 +15,6 @@ TEST_WORKFLOW_TRANSITION_LABEL = 'test transition label'
TEST_WORKFLOW_TRANSITION_LABEL_2 = 'test transition label 2'
TEST_WORKFLOW_TRANSITION_LABEL_EDITED = 'test transition label edited'
TEST_INDEX_TEMPLATE_METADATA_EXPRESSION = '{{{{ document.workflow.{}.get_current_state }}}}'.format(
TEST_INDEX_TEMPLATE_METADATA_EXPRESSION = '{{{{ document.workflow.{}.get_current_state() }}}}'.format(
TEST_WORKFLOW_INTERNAL_NAME
)
@@ -3,9 +3,9 @@ from __future__ import absolute_import, unicode_literals
import logging
import json
from jinja2 import Template
import requests
from django.template import Template, Context
from django.utils.translation import ugettext_lazy as _
from .classes import WorkflowAction
@@ -55,7 +55,7 @@ class DocumentPropertiesEditAction(WorkflowAction):
if self.document_label:
try:
new_label = Template(self.document_label).render(
context=Context(context)
**context
)
except Exception as exception:
raise WorkflowStateActionError(
@@ -67,7 +67,7 @@ class DocumentPropertiesEditAction(WorkflowAction):
if self.document_description:
try:
new_description = Template(self.document_description or '{}').render(
context=Context(context)
**context
)
except Exception as exception:
raise WorkflowStateActionError(
@@ -137,7 +137,7 @@ class HTTPPostAction(WorkflowAction):
try:
url = Template(self.url).render(
context=Context(context)
**context
)
except Exception as exception:
raise WorkflowStateActionError(
@@ -148,7 +148,7 @@ class HTTPPostAction(WorkflowAction):
try:
result = Template(self.payload or '{}').render(
context=Context(context)
**context
)
except Exception as exception:
raise WorkflowStateActionError(