def get_context_from_bindings(code, recipient, bindings):
"""Finalizes the bindings and create a Context for templating
"""
if code not in settings.EMAIL_TEMPLATES:
raise ImproperlyConfigured("Mail '%s' cannot be found")
url = settings.EMAIL_TEMPLATES[code]
res = dict(bindings)
res['EMAIL'] = recipient
qs = QueryDict(mutable=True)
qs.update(res)
# We first initialize the LINK_BROWSER variable as "#" (same page)
qs['LINK_BROWSER'] = "#"
# we generate the final browser link and add it to result dictionary
res['LINK_BROWSER'] = f"{url}?{qs.urlencode()}"
return res
评论列表
文章目录