Repository: digitalfabrik/integreat-cms

Issue:
Add currently_in_translation to translation coverage
The translation coverage lacks the `currently_in_translation` field, which should also be added.
Add currently_in_translation to translation coverage
The translation coverage lacks the `currently_in_translation` field, which should also be added.


Discussion:

Resolving patch:
diff --git a/backend/cms/models/pages/page_translation.py b/backend/cms/models/pages/page_translation.py
--- a/backend/cms/models/pages/page_translation.py
+++ b/backend/cms/models/pages/page_translation.py
@@ -111,6 +111,9 @@ def previous_revision(self):
 
     @property
     def is_outdated(self):
+        # If the page translation is currently in translation, it is defined as not outdated
+        if self.currently_in_translation:
+            return False
         source_translation = self.source_translation
         # If self.language is the root language, this translation can never be outdated
         if not source_translation:
@@ -125,6 +128,10 @@ def is_outdated(self):
             return False
         return self_revision.last_updated < source_revision.last_updated
 
+    @property
+    def is_up_to_date(self):
+        return not self.currently_in_translation and not self.is_outdated
+
     @property
     def combined_text(self):
         """
@@ -139,12 +146,16 @@ def get_translations(cls, region, language):
         return cls.objects.filter(page__region=region, language=language).distinct('page')
 
     @classmethod
-    def get_outdated_translations(cls, region, language):
-        return [t for t in cls.objects.filter(page__region=region, language=language).distinct('page') if t.is_outdated]
+    def get_up_to_date_translations(cls, region, language):
+        return [t for t in cls.objects.filter(page__region=region, language=language).distinct('page') if t.is_up_to_date]
 
     @classmethod
-    def get_up_to_date_translations(cls, region, language):
-        return [t for t in cls.objects.filter(page__region=region, language=language).distinct('page') if not t.is_outdated]
+    def get_current_translations(cls, region, language):
+        return [t for t in cls.objects.filter(page__region=region, language=language).distinct('page') if t.currently_in_translation]
+
+    @classmethod
+    def get_outdated_translations(cls, region, language):
+        return [t for t in cls.objects.filter(page__region=region, language=language).distinct('page') if t.is_outdated]
 
     def __str__(self):
         if self.id:
diff --git a/backend/cms/views/analytics/translation_coverage_view.py b/backend/cms/views/analytics/translation_coverage_view.py
--- a/backend/cms/views/analytics/translation_coverage_view.py
+++ b/backend/cms/views/analytics/translation_coverage_view.py
@@ -27,7 +27,8 @@ def get(self, request, *args, **kwargs):
             page_translations = PageTranslation.get_translations(region, language)
             languages.append({
                 'translated_name': language.translated_name,
-                'num_page_translations_up_to_date': len([t for t in page_translations if not t.is_outdated]),
+                'num_page_translations_up_to_date': len([t for t in page_translations if t.is_up_to_date]),
+                'num_page_translations_currently_in_translation': len([t for t in page_translations if t.currently_in_translation]),
                 'num_page_translations_outdated': len([t for t in page_translations if t.is_outdated]),
                 'num_page_translations_missing': num_pages - page_translations.count()
             })


Test patch: