diff options
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 22 | 
1 files changed, 15 insertions, 7 deletions
| diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index bb1f2a256..3b06bc449 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -1666,7 +1666,7 @@ class OperationDashboard:                          .annotate(number=Sum('surface')).all()                      val = 0                      if area_res: -                        val = area_res[0].number +                        val = (area_res[0].number or 0) / 10000.0                      dct_res[res_key].append(val)              # TODO...              res_keys = [('manday_realised', current_realisation_year_ope)] @@ -1701,7 +1701,11 @@ class OperationDashboard:                      .annotate(area=Sum('surface'))\                      .order_by('scientist__attached_to__name').all()                  # TODO: man-days, man-days/hectare -                dct_res[res_key] = org_res + +                dct_res[res_key] = [] +                for vals in org_res: +                    vals['area'] = (vals['area'] or 0) / 10000.0 +                    dct_res[res_key].append(vals)              year_ope = Operation.objects.filter(**operation_type)              res_keys = ['org_by_year'] @@ -1736,7 +1740,7 @@ class OperationDashboard:                                                 cost=Sum('cost'))                      years_dct = {}                      for yr in org_res.all(): -                        area = yr['area'] if yr['area'] else 0 +                        area = (yr['area'] if yr['area'] else 0) / 10000.0                          cost = yr['cost'] if yr['cost'] else 0                          years_dct[yr[key_date]] = (area, cost)                      r_years = [] @@ -1767,7 +1771,8 @@ class OperationDashboard:                  self.survey['effective'] = []                  for yr in self.years:                      year_res = Operation.objects\ -                        .filter(scientist__isnull=False, year=yr)\ +                        .filter(scientist__isnull=False, year=yr, +                                operation_type__txt_idx__in=ope_types)\                          .annotate(number=Sum('surface'), mean=Avg('surface'))                      nb = year_res[0].number if year_res.count() else 0                      nb = nb if nb else 0 @@ -1839,9 +1844,12 @@ class OperationDashboard:                  dct_years = {}                  for v in vals:                      values = [] -                    for value in (v['number'], v['area'], v['cost'], -                                  v['fnap']): -                        values.append(value if value else 0) +                    for k in ('number', 'area', 'cost', 'fnap'): +                        value = v[k] or 0 +                        if k == 'area': +                            value /= 10000.0 +                        values.append(value) +                      dct_years[v['operation__year']] = values                  years = []                  for y in self.years: | 
