prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Incorrect mandatory validation for qualitative indicators
  The indicator measure for qualitative indicators is hidden, but the code checking for completion of sections doesn't ignore that field, and considers it mandatory.  
  
  </issue>
  <code>
  [start of akvo/iati/checks/fields/results.py]
  1 # -*- coding: utf-8 -*-
  2 
  3 # Akvo RSR is covered by the GNU Affero General Public License.
  4 # See more details in the license.txt file located at the root folder of the Akvo RSR module.
  5 # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
  6 
  7 
  8 def results(project):
  9     """
  10     Check if result has a type, title and at least one indicator.
  11     Check if indicator has a measure and title.
  12     Check if indicator baseline has year and value.
  13     Check if indicator period has a start and end date, and start before end.
  14 
  15     :param project: Project object
  16     :return: All checks passed boolean, [Check results]
  17     """
  18     checks = []
  19     all_checks_passed = True
  20 
  21     for result in project.results.all():
  22         if not result.type:
  23             all_checks_passed = False
  24             checks.append((u'error', u'result (id: %s) has no type specified' % str(result.pk)))
  25 
  26         if not result.title:
  27             all_checks_passed = False
  28             checks.append((u'error', u'result (id: %s) has no title specified' % str(result.pk)))
  29 
  30         if not result.indicators.all():
  31             all_checks_passed = False
  32             checks.append((u'error', u'result (id: %s) has no indicator(s)' % str(result.pk)))
  33 
  34         for indicator in result.indicators.all():
  35             if not indicator.measure:
  36                 all_checks_passed = False
  37                 checks.append((u'error', u'indicator (id: %s) has no measure specified' %
  38                                str(indicator.pk)))
  39 
  40             if not indicator.title:
  41                 all_checks_passed = False
  42                 checks.append((u'error', u'indicator (id: %s) has no title specified' %
  43                                str(indicator.pk)))
  44 
  45             if (indicator.baseline_value and not indicator.baseline_year) or \
  46                     (not indicator.baseline_value and indicator.baseline_year):
  47                 all_checks_passed = False
  48                 checks.append((u'error', u'indicator (id: %s) baseline has no value or year '
  49                                          u'specified' % str(indicator.pk)))
  50 
  51             for reference in indicator.references.all():
  52                 if not reference.reference:
  53                     all_checks_passed = False
  54                     checks.append((u'error', u'indicator reference (id: %s) has no code '
  55                                              u'specified' % str(reference.pk)))
  56 
  57                 if not reference.vocabulary:
  58                     all_checks_passed = False
  59                     checks.append((u'error', u'indicator reference (id: %s) has no vocabulary '
  60                                              u'specified' % str(reference.pk)))
  61 
  62                 if reference.vocabulary == '99' and not reference.vocabulary_uri:
  63                     all_checks_passed = False
  64                     checks.append((u'error', u'indicator reference (id: %s) has vocabulary 99 '
  65                                              u'(reporting organisation) but no vocabulary URI '
  66                                              u'specified' % str(reference.pk)))
  67 
  68             for period in indicator.periods.all():
  69                 if not period.period_start:
  70                     all_checks_passed = False
  71                     checks.append((u'error', u'indicator period (id: %s) has no start date '
  72                                              u'specified' % str(period.pk)))
  73 
  74                 if not period.period_end:
  75                     all_checks_passed = False
  76                     checks.append((u'error', u'indicator period (id: %s) has no end date '
  77                                              u'specified' % str(period.pk)))
  78 
  79                 if period.period_start and period.period_end and \
  80                         period.period_start > period.period_end:
  81                     all_checks_passed = False
  82                     checks.append((u'error', u'indicator period (id: %s) has a start date '
  83                                              u'later than the end date' % str(period.pk)))
  84 
  85                 if not period.target_value and (period.target_comment or
  86                                                 period.target_locations.all() or
  87                                                 period.target_dimensions.all()):
  88                     all_checks_passed = False
  89                     checks.append((u'error', u'indicator period (id: %s) has no target value, but '
  90                                              u'does have a target comment, target location(s) or '
  91                                              u'target dimension(s)' % str(period.pk)))
  92 
  93                 if not period.actual_value and (period.actual_comment or
  94                                                 period.actual_locations.all() or
  95                                                 period.actual_dimensions.all()):
  96                     all_checks_passed = False
  97                     checks.append((u'error', u'indicator period (id: %s) has no actual value, but '
  98                                              u'does have an actual comment, actual location(s) or '
  99                                              u'actual dimension(s)' % str(period.pk)))
  100 
  101     if project.results.all() and all_checks_passed:
  102         checks.append((u'success', u'has valid result(s)'))
  103 
  104     return all_checks_passed, checks
  105
  [end of akvo/iati/checks/fields/results.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/akvo/iati/checks/fields/results.py b/akvo/iati/checks/fields/results.py
  --- a/akvo/iati/checks/fields/results.py
  +++ b/akvo/iati/checks/fields/results.py
  @@ -4,6 +4,8 @@
   # See more details in the license.txt file located at the root folder of the Akvo RSR module.
   # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
   
  +from akvo.rsr.models.result.utils import QUALITATIVE
  +
   
   def results(project):
       """
  @@ -32,7 +34,7 @@
               checks.append((u'error', u'result (id: %s) has no indicator(s)' % str(result.pk)))
   
           for indicator in result.indicators.all():
  -            if not indicator.measure:
  +            if indicator.type != QUALITATIVE and not indicator.measure:
                   all_checks_passed = False
                   checks.append((u'error', u'indicator (id: %s) has no measure specified' %
                                  str(indicator.pk)))
  
verification_info: {"golden_diff": "diff --git a/akvo/iati/checks/fields/results.py b/akvo/iati/checks/fields/results.py\n--- a/akvo/iati/checks/fields/results.py\n+++ b/akvo/iati/checks/fields/results.py\n@@ -4,6 +4,8 @@\n # See more details in the license.txt file located at the root folder of the Akvo RSR module.\n # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n \n+from akvo.rsr.models.result.utils import QUALITATIVE\n+\n \n def results(project):\n     \"\"\"\n@@ -32,7 +34,7 @@\n             checks.append((u'error', u'result (id: %s) has no indicator(s)' % str(result.pk)))\n \n         for indicator in result.indicators.all():\n-            if not indicator.measure:\n+            if indicator.type != QUALITATIVE and not indicator.measure:\n                 all_checks_passed = False\n                 checks.append((u'error', u'indicator (id: %s) has no measure specified' %\n                                str(indicator.pk)))\n", "issue": "Incorrect mandatory validation for qualitative indicators\nThe indicator measure for qualitative indicators is hidden, but the code checking for completion of sections doesn't ignore that field, and considers it mandatory.  \n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Akvo RSR is covered by the GNU Affero General Public License.\n# See more details in the license.txt file located at the root folder of the Akvo RSR module.\n# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\n\ndef results(project):\n    \"\"\"\n    Check if result has a type, title and at least one indicator.\n    Check if indicator has a measure and title.\n    Check if indicator baseline has year and value.\n    Check if indicator period has a start and end date, and start before end.\n\n    :param project: Project object\n    :return: All checks passed boolean, [Check results]\n    \"\"\"\n    checks = []\n    all_checks_passed = True\n\n    for result in project.results.all():\n        if not result.type:\n            all_checks_passed = False\n            checks.append((u'error', u'result (id: %s) has no type specified' % str(result.pk)))\n\n        if not result.title:\n            all_checks_passed = False\n            checks.append((u'error', u'result (id: %s) has no title specified' % str(result.pk)))\n\n        if not result.indicators.all():\n            all_checks_passed = False\n            checks.append((u'error', u'result (id: %s) has no indicator(s)' % str(result.pk)))\n\n        for indicator in result.indicators.all():\n            if not indicator.measure:\n                all_checks_passed = False\n                checks.append((u'error', u'indicator (id: %s) has no measure specified' %\n                               str(indicator.pk)))\n\n            if not indicator.title:\n                all_checks_passed = False\n                checks.append((u'error', u'indicator (id: %s) has no title specified' %\n                               str(indicator.pk)))\n\n            if (indicator.baseline_value and not indicator.baseline_year) or \\\n                    (not indicator.baseline_value and indicator.baseline_year):\n                all_checks_passed = False\n                checks.append((u'error', u'indicator (id: %s) baseline has no value or year '\n                                         u'specified' % str(indicator.pk)))\n\n            for reference in indicator.references.all():\n                if not reference.reference:\n                    all_checks_passed = False\n                    checks.append((u'error', u'indicator reference (id: %s) has no code '\n                                             u'specified' % str(reference.pk)))\n\n                if not reference.vocabulary:\n                    all_checks_passed = False\n                    checks.append((u'error', u'indicator reference (id: %s) has no vocabulary '\n                                             u'specified' % str(reference.pk)))\n\n                if reference.vocabulary == '99' and not reference.vocabulary_uri:\n                    all_checks_passed = False\n                    checks.append((u'error', u'indicator reference (id: %s) has vocabulary 99 '\n                                             u'(reporting organisation) but no vocabulary URI '\n                                             u'specified' % str(reference.pk)))\n\n            for period in indicator.periods.all():\n                if not period.period_start:\n                    all_checks_passed = False\n                    checks.append((u'error', u'indicator period (id: %s) has no start date '\n                                             u'specified' % str(period.pk)))\n\n                if not period.period_end:\n                    all_checks_passed = False\n                    checks.append((u'error', u'indicator period (id: %s) has no end date '\n                                             u'specified' % str(period.pk)))\n\n                if period.period_start and period.period_end and \\\n                        period.period_start > period.period_end:\n                    all_checks_passed = False\n                    checks.append((u'error', u'indicator period (id: %s) has a start date '\n                                             u'later than the end date' % str(period.pk)))\n\n                if not period.target_value and (period.target_comment or\n                                                period.target_locations.all() or\n                                                period.target_dimensions.all()):\n                    all_checks_passed = False\n                    checks.append((u'error', u'indicator period (id: %s) has no target value, but '\n                                             u'does have a target comment, target location(s) or '\n                                             u'target dimension(s)' % str(period.pk)))\n\n                if not period.actual_value and (period.actual_comment or\n                                                period.actual_locations.all() or\n                                                period.actual_dimensions.all()):\n                    all_checks_passed = False\n                    checks.append((u'error', u'indicator period (id: %s) has no actual value, but '\n                                             u'does have an actual comment, actual location(s) or '\n                                             u'actual dimension(s)' % str(period.pk)))\n\n    if project.results.all() and all_checks_passed:\n        checks.append((u'success', u'has valid result(s)'))\n\n    return all_checks_passed, checks\n", "path": "akvo/iati/checks/fields/results.py"}]}