Exemplo n.º 1
0
    def render_templates(self, content_diff, meta_diff):
        """ Render both plain text and HTML templates by providing all the
        necessary arguments

        :return: tuple consisting of plain text and HTML notification message
         """
        meta_diff_txt = list(make_text_diff(meta_diff))
        domain = self.app.cfg.interwiki_map[self.app.cfg.interwikiname]
        unsubscribe_url = urljoin(
            domain, url_for('frontend.subscribe_item', item_name=self.fqname))
        diff_url = self.generate_diff_url(domain)
        item_url = urljoin(
            domain, url_for('frontend.show_item', item_name=self.fqname))
        if self.comment is not None:
            comment = self.meta["comment"]
        else:
            comment = self.revs[0].meta["comment"]
        txt_template = render_template(
            Notification.txt_template,
            wiki_name=self.wiki_name,
            notification_sentence=self.notification_sentence,
            diff_url=diff_url,
            item_url=item_url,
            comment=comment,
            content_diff_=content_diff,
            meta_diff_=meta_diff_txt,
            unsubscribe_url=unsubscribe_url,
        )
        html_template = render_template(
            Notification.html_template,
            wiki_name=self.wiki_name,
            notification_sentence=self.notification_sentence,
            diff_url=diff_url,
            item_url=item_url,
            comment=comment,
            content_diff_=content_diff,
            meta_diff_=meta_diff,
            unsubscribe_url=unsubscribe_url,
        )
        return txt_template, html_template
Exemplo n.º 2
0
    def render_templates(self, content_diff, meta_diff):
        """ Render both plain text and HTML templates by providing all the
        necessary arguments

        :return: tuple consisting of plain text and HTML notification message
         """
        meta_diff_txt = list(make_text_diff(meta_diff))
        domain = self.app.cfg.interwiki_map[self.app.cfg.interwikiname]
        unsubscribe_url = urljoin(domain, url_for('frontend.subscribe_item',
                                                  item_name=self.item_name))
        diff_url = self.generate_diff_url(domain)
        item_url = urljoin(domain, url_for('frontend.show_item', item_name=self.item_name))
        if self.comment is not None:
            comment = self.meta["comment"]
        else:
            comment = self.revs[0].meta["comment"]
        txt_template = render_template(Notification.txt_template,
                                       wiki_name=self.wiki_name,
                                       notification_sentence=self.notification_sentence,
                                       diff_url=diff_url,
                                       item_url=item_url,
                                       comment=comment,
                                       content_diff_=content_diff,
                                       meta_diff_=meta_diff_txt,
                                       unsubscribe_url=unsubscribe_url,
                                       )
        html_template = render_template(Notification.html_template,
                                        wiki_name=self.wiki_name,
                                        notification_sentence=self.notification_sentence,
                                        diff_url=diff_url,
                                        item_url=item_url,
                                        comment=comment,
                                        content_diff_=content_diff,
                                        meta_diff_=meta_diff,
                                        unsubscribe_url=unsubscribe_url,
        )
        return txt_template, html_template
 def _test_make_text_diff(self, tests):
     for changes, expected in tests:
         for got in make_text_diff(changes):
             assert got == expected
 def test_make_text_diff_empty(self):
     for got in make_text_diff([]):
         assert got == u""
Exemplo n.º 5
0
 def _test_make_text_diff(self, tests):
     for changes, expected in tests:
         for got in make_text_diff(changes):
             assert got == expected
Exemplo n.º 6
0
 def test_make_text_diff_empty(self):
     for got in make_text_diff([]):
         assert got == u""