Repository: akvo/akvo-rsr

Issue:
Indicator reordering and description update are not reflected in children.



Discussion:

Resolving patch:
diff --git a/akvo/rsr/models/project.py b/akvo/rsr/models/project.py
--- a/akvo/rsr/models/project.py
+++ b/akvo/rsr/models/project.py
@@ -1360,6 +1360,7 @@ def copy_indicator(self, result, source_indicator, set_parent=True):
         Indicator = apps.get_model('rsr', 'Indicator')
         data = dict(
             title=source_indicator.title,
+            description=source_indicator.description,
             measure=source_indicator.measure,
             ascending=source_indicator.ascending,
             type=source_indicator.type,
@@ -1375,7 +1376,7 @@ def copy_indicator(self, result, source_indicator, set_parent=True):
             indicator = Indicator.objects.create(result=result, **data)
             created = True
 
-        fields = ['description', 'baseline_year', 'baseline_value', 'baseline_comment']
+        fields = ['baseline_year', 'baseline_value', 'baseline_comment']
         self._update_fields_if_not_child_updated(source_indicator, indicator, fields)
 
         if not created:
@@ -1408,12 +1409,12 @@ def update_indicator(self, result, parent_indicator):
         except Indicator.DoesNotExist:
             return
 
-        update_fields = ['title', 'measure', 'ascending', 'type', 'export_to_iati']
+        update_fields = ['title', 'measure', 'ascending', 'type', 'export_to_iati', 'description', 'order']
         for field in update_fields:
             setattr(child_indicator, field, getattr(parent_indicator, field))
         child_indicator.save(update_fields=update_fields)
 
-        fields = ['description', 'baseline_year', 'baseline_value', 'baseline_comment']
+        fields = ['baseline_year', 'baseline_value', 'baseline_comment']
         self._update_fields_if_not_child_updated(parent_indicator, child_indicator, fields)
 
     def copy_period(self, indicator, source_period, set_parent=True):


Test patch:
diff --git a/akvo/rsr/tests/results_framework/test_results_framework.py b/akvo/rsr/tests/results_framework/test_results_framework.py
--- a/akvo/rsr/tests/results_framework/test_results_framework.py
+++ b/akvo/rsr/tests/results_framework/test_results_framework.py
@@ -248,14 +248,12 @@ def test_child_indicator_state_not_overwritten_after_change(self):
         child_indicator.baseline_value = new_value
         child_indicator.baseline_comment = new_value
         child_indicator.baseline_year = 2002
-        child_indicator.description = new_value
         child_indicator.save()
 
         # When
         self.indicator.baseline_year = 2010
         self.indicator.baseline_value = 'value',
         self.indicator.baseline_comment = 'comment'
-        self.indicator.description = 'description'
         self.indicator.save()
 
         # Then
@@ -265,7 +263,6 @@ def test_child_indicator_state_not_overwritten_after_change(self):
         self.assertEqual(child_indicator.title, parent_indicator.title)
         self.assertEqual(child_indicator.measure, parent_indicator.measure)
         self.assertEqual(child_indicator.ascending, parent_indicator.ascending)
-        self.assertEqual(child_indicator.description, new_value)
         self.assertEqual(child_indicator.baseline_year, 2002)
         self.assertEqual(child_indicator.baseline_value, new_value)
         self.assertEqual(child_indicator.baseline_comment, new_value)