示例#1
0
 def compute_row_totals(self,
                        row_config,
                        row_values,
                        is_group_total=False,
                        is_report_total=False):
     total_row = self.get_empty_row_asdict(self.get_fields(),
                                           ReportValue(' '))
     for field in self.get_fields():
         if field in row_config:
             fun = row_config[field]
             value = fun(row_values[field])
             if field in self.get_m2m_field_names():
                 value = ReportValue([
                     value,
                 ])
             value = ReportValue(value)
             value.is_value = False
             value.is_group_total = is_group_total
             value.is_report_total = is_report_total
             # TODO: method should do only one thing.
             # Remove ovveride_field_values from this function.
             if field in self.override_field_values:
                 value.to_value = self.override_field_values[field]
             if field in self.override_field_formats:
                 value.format = self.override_field_formats[field]
             value.is_m2m_value = (field in self.get_m2m_field_names())
             total_row[field] = value
     row = self.reorder_dictrow(total_row)
     row = ReportRow(row)
     row.is_total = True
     return row
示例#2
0
 def compute_row_totals(row_config,
                        row_values,
                        is_group_total=False,
                        is_report_total=False):
     total_row = self.get_empty_row_asdict(self.get_fields(),
                                           ReportValue(' '))
     for k, v in total_row.items():
         if k in row_config:
             fun = row_config[k]
             value = fun(row_values[k])
             if k in self.get_m2m_field_names():
                 value = ReportValue([
                     value,
                 ])
             value = ReportValue(value)
             value.is_value = False
             value.is_group_total = is_group_total
             value.is_report_total = is_report_total
             if k in self.override_field_values:
                 value.to_value = self.override_field_values[k]
             if k in self.override_field_formats:
                 value.format = self.override_field_formats[k]
             value.is_m2m_value = (k in self.get_m2m_field_names())
             total_row[k] = value
     row = self.reorder_dictrow(total_row)
     row = ReportRow(row)
     row.is_total = True
     return row
示例#3
0
 def compute_row_totals(row_config,
                        row_values,
                        is_group_total=False,
                        is_report_total=False):
     total_row = self.get_empty_row_asdict(self.get_fields(),
                                           ReportValue(' '))
     for k, v in total_row.items():
         if k in row_config:
             fun = row_config[k]
             value = fun(row_values[k])
             if k in self.get_m2m_field_names():
                 value = ReportValue([
                     value,
                 ])
             value = ReportValue(value)
             value.is_value = False
             value.is_group_total = is_group_total
             value.is_report_total = is_report_total
             if k in self.override_field_values:
                 value.to_value = self.override_field_values[k]
             if k in self.override_field_formats:
                 value.format = self.override_field_formats[k]
             value.is_m2m_value = (k in self.get_m2m_field_names())
             total_row[k] = value
     row = self.reorder_dictrow(total_row)
     row = ReportRow(row)
     row.is_total = True
     return row
示例#4
0
 def compute_row_totals(self, row_config, row_values, is_group_total=False, is_report_total=False,
                        filter_related_fields={}):
     used_fields = [field for field in self.used_fields() if field not in filter_related_fields]
     total_row = self.get_empty_row_asdict(used_fields, ReportValue(' '))
     for field in used_fields:
         if field in row_config:
             fun = row_config[field]
             value = fun(row_values[field])
             if field in self.get_m2m_field_names():
                 value = ReportValue([value, ])
             value = ReportValue(value)
             value.is_value = False
             value.is_group_total = is_group_total
             value.is_report_total = is_report_total
             # TODO: method should do only one thing.
             # Remove ovveride_field_values from this function.
             if field in self.override_field_values:
                 value.to_value = self.override_field_values[field]
             if field in self.override_field_formats:
                 value.format = self.override_field_formats[field]
             value.is_m2m_value = (field in self.get_m2m_field_names())
             total_row[field] = value
     row = self.reorder_dictrow(total_row)
     row = ReportRow(row)
     row.is_total = True
     return row
示例#5
0
 def compute_row_totals(row_config, row_values, is_group_total=False, is_report_total=False):
     total_row = self.get_empty_row_asdict(self.get_fields(), ReportValue(' '))
     for field_name in total_row.keys():
         if field_name in row_config:
             fun = row_config[field_name]
             cell_value = fun(row_values[field_name])
             if field_name in self.get_m2m_field_names():
                 cell_value = ReportValue([cell_value])
                 # cell_value = [cell_value]
             cell_value = ReportValue(cell_value)
             cell_value.is_value = False
             cell_value.is_group_total = is_group_total
             cell_value.is_report_total = is_report_total
             if field_name in self.override_field_values:
                 cell_value.to_value = self.override_field_values[field_name]
             if field_name in self.override_field_formats:
                 cell_value.format = self.override_field_formats[field_name]
             cell_value.is_m2m_value = field_name in self.get_m2m_field_names()
             total_row[field_name] = cell_value
     totals_row = ReportRow(self.reorder_dictrow(total_row))
     totals_row.is_total = True
     return totals_row