summaryrefslogtreecommitdiff
path: root/talermerchantdemos/survey
diff options
context:
space:
mode:
Diffstat (limited to 'talermerchantdemos/survey')
-rw-r--r--talermerchantdemos/survey/survey.py36
1 files changed, 10 insertions, 26 deletions
diff --git a/talermerchantdemos/survey/survey.py b/talermerchantdemos/survey/survey.py
index 1b06218..466c14d 100644
--- a/talermerchantdemos/survey/survey.py
+++ b/talermerchantdemos/survey/survey.py
@@ -30,7 +30,13 @@ from flask_babel import force_locale
from flask_babel import gettext
import traceback
from taler.util.talerconfig import TalerConfig, ConfigurationError
-from ..httpcommon import backend_get, backend_post, self_localized, BackendException
+from ..httpcommon import (
+ backend_get,
+ backend_post,
+ self_localized,
+ BackendException,
+ make_utility_processor,
+)
import sys
if not sys.version_info.major == 3 and sys.version_info.minor >= 6:
@@ -85,31 +91,9 @@ def get_locale():
return "en"
-##
-# Make the environment available into templates.
-#
-# @return the environment-reading function.
-@app.context_processor
-def utility_processor():
- def env(name, default=None):
- return os.environ.get(name, default)
-
- def prettydate(talerdate):
- parsed_time = re.search(r"/Date\(([0-9]+)\)/", talerdate)
- if not parsed_time:
- return "malformed date given"
- parsed_time = int(parsed_time.group(1))
- timestamp = datetime.datetime.fromtimestamp(parsed_time)
- # returns the YYYY-MM-DD date format.
- return timestamp.strftime("%Y-%b-%d")
-
- def getactive():
- return "survey"
-
- def getlang():
- return get_locale()
-
- return dict(env=env, prettydate=prettydate, getactive=getactive, getlang=getlang)
+# Add context processor that will make additional variables
+# and functions available in the template.
+app.context_processor(make_utility_processor("survey"))
##