Exemple #1
0
 def clean_html(self, ids):
     entries = Entry.query.filter(Entry.id.in_(ids)).all()
     app.logger.info(u"Admin Cleaning HTML for Entries: {0}".format(u", ".join(map(str, entries))))
     for entry in entries:
         entry.content = Entry.clean_images(entry.content)
         entry.summary = Entry.clean_images(entry.summary)
         entry.title = Entry.clean_title(entry.title)
         db.session.add(entry)
     db.session.commit()
Exemple #2
0
    def title(self, item):
        """
        Gets the title of an item.

        :param item: Feedparser entry
        :type item: dict
        :return: str
        """
        title = item.get('title', None)
        return Entry.clean_title(title)
Exemple #3
0
    def title(self, item):
        """
        Gets the title of an item.

        :param item: deserialized JSON item
        :type item: dict
        :return: str
        """
        title = item.get('title', None)
        return Entry.clean_title(title)
    def title(self, item: Dict) -> str:
        """
        Gets the title of an item.

        :param item: Feedparser entry
        :type item: Dict
        :return: str
        """
        title = item.get("title", "")
        return Entry.clean_title(title)
    def title(self, item: Dict) -> str:
        """
        Gets the title of an item.

        :param item: deserialized JSON item
        :type item: Dict
        :return: str
        """
        title = item.get("title", "")
        if title:
            title = Entry.clean_title(title)
        return title
 def clean_html(self, ids):
     try:
         entries = Entry.query.filter(Entry.id.in_(ids)).all()
         app.logger.info(
             "Admin Cleaning HTML for Entries: %s", stringify_list(entries)
         )
         for entry in entries:
             entry.content = Entry.clean_content(entry.content)
             entry.summary = Entry.clean_content(entry.summary)
             entry.title = Entry.clean_title(entry.title)
             entry.create_summary()
             db.session.add(entry)
         db.session.commit()
         flash(f"HTML was successfully cleaned for {len(ids)} Entries.", "success")
     except Exception as ex:
         if not self.handle_view_exception(ex):
             raise
         flash(f"Failed to clean Entry HTML. {ex}", "error")
Exemple #7
0
 def test_entry_clean_title(self):
     string = "\u2019 Test Title"
     title = Entry.clean_title(string)
     self.assertEqual(title, '\u2019 Test Title')
Exemple #8
0
def test_entry_clean_title(client):
    string = "\u2019 Test Title"
    title = Entry.clean_title(string)
    assert title == "\u2019 Test Title"