Skip to content

Commit

Permalink
Optimize calculation of translations states
Browse files Browse the repository at this point in the history
  • Loading branch information
timobrembeck committed Jan 7, 2022
1 parent 44fbba6 commit fa07116
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions integreat_cms/cms/models/pages/abstract_base_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ def best_translation(self):
"""
return self.backend_translation or self.default_translation

def translation_states(self):
"""
This function calculates all translations states of the page
:return: The page translation in the requested :class:`~integreat_cms.cms.models.languages.language.Language` or :obj:`None`
if no translation exists
:rtype: ~integreat_cms.cms.models.pages.page_translation.PageTranslation
"""
try:
# Try to get the prefetched translations (which are already distinct per language)
language_tree = self.language_tree
except AttributeError:
# If the translations were not prefetched or the latest version was not public, query it from the database
language_tree = self.region.language_tree

def __str__(self):
"""
This overwrites the default Django :meth:`~django.db.models.Model.__str__` method which would return ``AbstractBasePage object (id)``.
Expand Down
6 changes: 3 additions & 3 deletions integreat_cms/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 1.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-01-07 18:43+0000\n"
"POT-Creation-Date: 2022-01-07 18:44+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Integreat <info@integreat-app.de>\n"
"Language-Team: Integreat <info@integreat-app.de>\n"
Expand Down Expand Up @@ -2450,12 +2450,12 @@ msgstr "explizit archiviert"
msgid "Whether or not the page is explicitly archived"
msgstr "Ob die Seite explizit archiviert ist oder nicht"

#: cms/models/pages/abstract_base_page.py:170 cms/models/pages/page.py:273
#: cms/models/pages/abstract_base_page.py:185 cms/models/pages/page.py:273
#: cms/models/pages/page_translation.py:48
msgid "page"
msgstr "Seite"

#: cms/models/pages/abstract_base_page.py:172 cms/models/pages/page.py:275
#: cms/models/pages/abstract_base_page.py:187 cms/models/pages/page.py:275
msgid "pages"
msgstr "Seiten"

Expand Down

0 comments on commit fa07116

Please sign in to comment.