Repository: ddionrails/ddionrails

Issue:
Refactor concepts.Period fields
- add label_de
- add description_de
- remove unused field: defintion


Discussion:

Resolving patch:
diff --git a/ddionrails/concepts/forms.py b/ddionrails/concepts/forms.py
--- a/ddionrails/concepts/forms.py
+++ b/ddionrails/concepts/forms.py
@@ -43,7 +43,7 @@ def __init__(self, *args, **kwargs):
 class PeriodForm(forms.ModelForm):
     class Meta:
         model = Period
-        fields = ("study", "name", "label", "description", "definition")
+        fields = ("study", "name", "label", "label_de", "description", "description_de")
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
diff --git a/ddionrails/concepts/models.py b/ddionrails/concepts/models.py
--- a/ddionrails/concepts/models.py
+++ b/ddionrails/concepts/models.py
@@ -252,13 +252,21 @@ class Period(models.Model, ModelMixin):
         verbose_name="Label (English)",
         help_text="Label of the period (English)",
     )
+    label_de = models.CharField(
+        max_length=255,
+        blank=True,
+        verbose_name="Label (German)",
+        help_text="Label of the period (German)",
+    )
     description = models.TextField(
         blank=True,
-        verbose_name="Description (Markdown)",
-        help_text="Description of the period (Markdown)",
+        verbose_name="Description (Markdown, English)",
+        help_text="Description of the period (Markdown, English)",
     )
-    definition = models.CharField(
-        max_length=255, blank=True, help_text="Definition of the period"
+    description_de = models.TextField(
+        blank=True,
+        verbose_name="Description (Markdown, German)",
+        help_text="Description of the period (Markdown, German)",
     )
 
     #############
@@ -294,10 +302,6 @@ def save(
             update_fields=update_fields,
         )
 
-    def is_range(self) -> bool:
-        """ Returns if "definition" defines a range """
-        return ":" in self.definition
-
 
 class AnalysisUnit(models.Model, ModelMixin):
     """


Test patch:
diff --git a/tests/concepts/conftest.py b/tests/concepts/conftest.py
--- a/tests/concepts/conftest.py
+++ b/tests/concepts/conftest.py
@@ -39,11 +39,7 @@ def analysis_unit_without_label(db):  # pylint: disable=invalid-name,unused-argu
 @pytest.fixture
 def period_with_range_definition(db):  # pylint: disable=invalid-name,unused-argument
     """ A period with a range period definition in the database """
-    return PeriodFactory(
-        name="some-period",
-        description="This is some period",
-        definition="2010-01:2018-12",
-    )
+    return PeriodFactory(name="some-period", description="This is some period")
 
 
 @pytest.fixture
@@ -90,7 +86,6 @@ def valid_period_data(study):
         period_name="some-period",
         label="Some Period",
         description="This is some period",
-        definition="2018",
     )
 
 
diff --git a/tests/concepts/test_models.py b/tests/concepts/test_models.py
--- a/tests/concepts/test_models.py
+++ b/tests/concepts/test_models.py
@@ -56,12 +56,6 @@ class TestPeriodModel:
     def test_string_method(self, period):
         assert str(period) == "/period/" + period.name
 
-    def test_is_range_method_with_range(self, period_with_range_definition):
-        assert period_with_range_definition.is_range() is True
-
-    def test_is_range_method_without_range(self, period):
-        assert period.is_range() is False
-
 
 class TestTopicModel:
     def test_get_children_method(self, topic):
diff --git a/tests/conftest.py b/tests/conftest.py
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -101,10 +101,7 @@ def instrument(db):
 def period(db):
     """ A period in the database """
     return PeriodFactory(
-        name="some-period",
-        label="Some period",
-        description="This is some period",
-        definition="2018",
+        name="some-period", label="Some period", description="This is some period"
     )