diff --git a/portail_citoyen_announces/transports.py b/portail_citoyen_announces/transports.py index bca6744..f160f1f 100644 --- a/portail_citoyen_announces/transports.py +++ b/portail_citoyen_announces/transports.py @@ -56,14 +56,14 @@ def get_transports(): return __TRANSPORTS -def get_template_list(template_list, category): +def get_template_list(template_list, **kwargs): '''Customize a template list given an announce category''' for template in template_list: - yield template.format(category=category.identifier) + yield template.format(**kwargs) -def get_template(template_list, category): - template_list = get_template_list(template_list, category) +def get_template(template_list, **kwargs): + template_list = get_template_list(template_list, **kwargs) return select_template(template_list) @@ -105,8 +105,10 @@ class EmailTransport(object): def send(self, announce): category = announce.category site = category.site - subject_template = get_template(self.subject_template_list, category) - body_template = get_template(self.body_template_list, category) + subject_template = get_template(self.subject_template_list, + category=category.identifier, identifier=self.identifier) + body_template = get_template(self.body_template_list, + category=category.identifier, identifier=self.identifier) ctx = Context({ 'announce': announce, 'site': site, 'category': category }) subject = subject_template.render(ctx).replace('\r', '').replace('\n', '') body = body_template.render(ctx)