def format_impact_table(self): """Breakdown by population. :returns: The population breakdown report. :rtype: list """ message = m.Message(style_class='container') message.add( m.Heading(tr('Evacuated population minimum needs'), **styles.INFO_STYLE)) table = m.Table(style_class='table table-condensed table-striped') table.caption = None for frequency, needs in self.minimum_needs.items(): row = m.Row() row.add( m.Cell(tr('Relief items to be provided %s' % frequency), header=True)) row.add(m.Cell(tr('Total'), header=True, align='right')) table.add(row) for resource in needs: row = m.Row() row.add(m.Cell(tr(resource['table name']))) row.add( m.Cell(tr(format_int(resource['amount'])), align='right')) table.add(row) message.add(table) return message
def format_minimum_needs_breakdown(self): """Breakdown by population. :returns: The population breakdown report. :rtype: list """ message = m.Message(style_class='container') message.add(m.Heading( tr('Evacuated population minimum needs'), **styles.INFO_STYLE)) table = m.Table( style_class='table table-condensed table-striped') table.caption = None for frequency, needs in self.minimum_needs.items(): row = m.Row() row.add(m.Cell( tr('Relief items to be provided %s' % frequency), header=True )) row.add(m.Cell(tr('Total'), header=True, align='right')) table.add(row) for resource in needs: row = m.Row() row.add(m.Cell(tr(resource['table name']))) row.add(m.Cell( tr(format_int(resource['amount'])), align='right' )) table.add(row) message.add(table) return message
def format_impact_table(self): """Impact table. :returns: The impact table. :rtype: safe.messaging.Message """ message = m.Message(style_class='container') table = m.Table( style_class='table table-condensed table-striped') table.caption = None row = m.Row() for attribute in self.breakdown['attributes']: row.add(m.Cell(attribute, header=True, align='right')) table.add(row) affected_area = 0 total_area = 0 affected_people = 0 total_people = 0 for field in self.breakdown['fields']: affected_area += field[1] total_area += field[3] affected_people += field[4] total_people += field[6] table.add(self.impact_row( field[0], field[1], field[2], field[3], field[4], field[5], field[6], )) percent_area = 0 percent_people = 0 if total_area > 0: percent_area = affected_area / total_area * 100.0 if total_people > 0: percent_people = affected_people / total_people * 100.0 table.add(self.impact_row( tr('Total'), affected_area, percent_area, total_area, affected_people, percent_people, total_people) ) message.add(table) return message
def format_impact_table(self): """Breakdown by population. :returns: The population breakdown report. :rtype: list """ message = m.Message(style_class="container") message.add(m.Heading(tr("Evacuated population minimum needs"), **styles.INFO_STYLE)) table = m.Table(style_class="table table-condensed table-striped") table.caption = None for frequency, needs in self.minimum_needs.items(): row = m.Row() row.add(m.Cell(tr("Relief items to be provided %s" % frequency), header=True)) row.add(m.Cell(tr("Total"), header=True, align="right")) table.add(row) for resource in needs: row = m.Row() row.add(m.Cell(tr(resource["table name"]))) row.add(m.Cell(tr(format_int(resource["amount"])), align="right")) table.add(row) message.add(table) return message