class StockOnHandTable(MonthTable): code = Column(value=lambda cell: cell.object.code, name="MSD Code", sort_key_fn=lambda obj: obj.code, titleized=False, css_class=_msd_class) name = Column(name="Facility Name", value=lambda cell: cell.object.name, sort_key_fn=lambda obj: obj.name, link=supply_point_link, css_class=_fac_name_class) delivery_group = Column(css_class=_dg_class, value=lambda cell: _dg(cell.object), sort_key_fn=_dg, name="D G") last_reported = Column( css_class=_ontime_class, value=lambda cell: last_report_span(cell.object, cell.row.table.year, cell.row.table.month, format=False)) response_rate = Column(name="Hist. Resp. Rate", safe=True, value=lambda cell: _hrr_soh(cell.object), sort_key_fn=lambda sp: historical_response_rate( sp, SupplyPointStatusTypes.SOH_FACILITY)) class Meta: per_page = 9999 order_by = ["D G", "Facility Name"]
class AggregateSupervisionTable(MonthTable): name = Column(value=lambda cell: cell.object.name, sort_key_fn=lambda object: object.name, link=lambda cell: reports_link(cell, 'supervision')) percent_received = Column(sortable=False, value=lambda cell: cell.object.breakdown. percent_supervision_received(), name="% Supervision Received", safe=True) percent_not_received = Column(sortable=False, value=lambda cell: cell.object.breakdown. percent_supervision_not_received(), name="% Supervision Not Received", safe=True) percent_not_responding = Column(sortable=False, value=lambda cell: cell.object.breakdown. percent_supervision_not_responding(), name="% Supervision Not Responding", safe=True) historical_response_rate = Column( sortable=False, value=lambda cell: cell.object.breakdown.supervision_response_rate(), name="Historical Response Rate", safe=True) class Meta: per_page = 9999
class RandRReportingHistoryTable(MonthTable): code = Column() name = Column(name="Facility Name", value=lambda cell: cell.object.name, sort_key_fn=lambda obj: obj.name, link=supply_point_link) submitted = RandRSubmittedColumn(name="R&R Status", value=_randr_value, format="d M Y", css_class=_randr_css_class, sortable=False) contact = Column(name="Contact", value=lambda cell: _default_contact(cell.object), sort_key_fn=_default_contact) response_rate = Column(name="Historical Response Rate", safe=True, value=lambda cell: _hrr_randr(cell.object), sort_key_fn=lambda sp: historical_response_rate( sp, SupplyPointStatusTypes.R_AND_R_FACILITY)) @property def submitting_group(self): return DeliveryGroups(self.month).current_submitting_group() class Meta: per_page = 9999 order_by = ["Facility Name"]
class SupervisionTable(MonthTable): code = Column(value=lambda cell: cell.object.code, name="MSD Code", sort_key_fn=lambda obj: obj.code, titleized=False) name = Column(name="Facility Name", value=lambda cell: cell.object.name, sort_key_fn=lambda obj: obj.name, link=supply_point_link) supervision_this_quarter = Column( sortable=False, name="Supervision This Quarter", value=lambda cell: _latest_status_or_none( cell, SupplyPointStatusTypes.SUPERVISION_FACILITY, "name")) date = DateColumn( sortable=False, value=lambda cell: _latest_status_or_none( cell, SupplyPointStatusTypes.SUPERVISION_FACILITY, "status_date")) response_rate = Column( name="Historical Response Rate", safe=True, value=lambda cell: _hrr_super(cell.object), sort_key_fn=lambda sp: historical_response_rate( sp, SupplyPointStatusTypes.SUPERVISION_FACILITY)) class Meta: per_page = 9999 order_by = ["Facility Name"]
class FullMessageTable(Table): contact = Column(value=lambda cell:cell.object.contact.name) direction = Column(sortable=False) role = Column(value=lambda cell:cell.object.contact.role.name) number = Column(value=lambda cell:cell.object.contact.phone) date = DateColumn(format="H:i d/m/Y", sortable=False) text = Column(css_class="message", sortable=False)
class DeliveryStatusTable(MonthTable): """ Same as above but includes a column for the HSA """ code = Column() name = Column(name="Facility Name", value=lambda cell: cell.object.name, sort_key_fn=lambda obj: obj.name, link=supply_point_link) delivery_status = Column( sortable=False, name="Delivery Status", value=lambda cell: _latest_status_or_none( cell, SupplyPointStatusTypes.DELIVERY_FACILITY, "name")) delivery_date = DateColumn( sortable=False, name="Delivery Date", value=lambda cell: _latest_status_or_none( cell, SupplyPointStatusTypes.DELIVERY_FACILITY, "status_date")) last_lead_time = Column( sortable=False, name="Last Lead Time", value=lambda cell: calc_lead_time( cell.object, month=cell.row.table.month, year=cell.row.table.year)) average_lead_time = Column( sortable=False, name="Average Lead Time", value=lambda cell: avg_past_lead_time(cell.object)) class Meta: per_page = 9999 order_by = ["Facility Name"]
class MalawiLocationTable(Table): name = Column() type = Column() code = Column() class Meta: order_by = 'type'
class FacilityTable(Table): name = Column(link=_edit_facility_link) location = Column(value=_location) class Meta: order_by = 'location' per_page = 30
class CommodityTable(Table): name = Column(link=_edit_commodity_link) sms_code = Column(value=_code) type = Column(value=_type) class Meta: order_by = 'name'
class CategoryTable(Table): name = Column(link=_edit_link) keywords = Column(value=lambda c: c.row.keywords) class Meta: order_by = "name" per_page = 50
class AggregateSOHTable(MonthTable): name = Column(value=lambda cell: cell.object.name, sort_key_fn=lambda object: object.name, link=lambda cell: reports_link(cell, 'soh')) percent_on_time = Column( sortable=False, value=lambda cell: cell.object.breakdown.percent_soh_on_time(), name="% Facilities Submitting SOH On Time", safe=True) percent_late = Column( sortable=False, value=lambda cell: cell.object.breakdown.percent_soh_late(), name="% Facilities Submitting SOH Late", safe=True) percent_not_responding = Column( sortable=False, value=lambda cell: cell.object.breakdown.percent_soh_not_responding(), name="% Facilities Not Responding to SOH", safe=True) percent_with_stockouts = Column( sortable=False, value=lambda cell: cell.object.breakdown.percent_stockouts_in_month(), name="% Facilities with 1 or More Stockouts This Month", safe=True) class Meta: per_page = 9999
class MyTable(Table): name = Column(link=lambda cell: reverse("edit", args=[cell.row.pk])) gender = Column(value=lambda cell: cell.object.get_gender_display()) phone = Column(sortable=False, css_class="phone") class Meta: per_page = 4 order_by = "name"
class MessageHistoryTable(Table): contact = Column(value=lambda u: u.object.contact.name) direction = Column(value=_get_direction) role = Column(value=_get_role, sortable=False) phone = Column(value=lambda u: _(u.object.contact.contactdetail.phone()), sortable=False) date = DateColumn(format="H:m:s d/m/Y") text = Column()
class ContactTable(Table): name = Column(link=contact_edit_link) supply_point = Column(value=render_supply_point, name="Supply Point", sortable=False) phone = Column(value=lambda cell: cell.object.phone, sortable=False) class Meta: order_by = 'supply_point' per_page = 30
class CurrentMOSTable(Table): msd_code = ILSGatewayColumn(head_verbose="MSD Code") delivery_group = Column() name = Column(link=lambda cell: reverse( "ilsgateway.views.facilities_detail", args=[cell.row.pk])) for product in Product.objects.all(): exec( "%s = ILSGatewayColumn(name='%s', value=_get_mos_value, head_verbose='%s', sortable=False, is_product=True)" % (product.sms_code, product.sms_code, product.name))
class ContactDetailTable(Table): name = Column(link=_edit_link) language = Column() #role = Column() service_delivery_point = Column() primary = Column(value=_get_yes_no) class Meta: order_by = 'service_delivery_point__name'
class MalawiProductTable(Table): name = Column() sms_code = Column() average_monthly_consumption = Column() emergency_order_level = Column() type = Column() class Meta: order_by = 'name'
class MessageTable(Table): # this is temporary, until i fix ModelTable! text = Column() direction = Column() connection = Column(link=lambda cell: "javascript:reply('%s')" % cell.row.connection.identity) status = Column() date = DateColumn(format="m/d/Y H:i:s") class Meta: order_by = '-date'
class DistrictTable(Table): name = Column(link=lambda cell: "%s?place=%s" % (reverse("malawi_facilities"), cell.object.code)) code = Column() facilities = Column(name="Number of Facilities", value=lambda cell: len(cell.object.get_children()), sortable=False) class Meta: order_by = 'code'
class HSATable(Table): facility = Column(value=lambda cell: cell.object.supply_point.supplied_by, sortable=False) name = Column(link=lambda cell: reverse("malawi_hsa", args=[cell.object.supply_point.code])) id = Column(value=lambda cell: cell.object.hsa_id, sortable=False) commodities = Column(name="Responsible For These Commodities", value=list_commodities, sortable=False) stocked_out = Column(name="Products stocked out", value=lambda cell: cell.object.supply_point.stockout_count()) emergency = Column(name="Products in emergency", value=lambda cell: cell.object.supply_point.emergency_stock_count(), sortable=False) ok = Column(name="Products in adequate supply", value=lambda cell: cell.object.supply_point.adequate_supply_count(), sortable=False) overstocked = Column(name="Products overstocked", value=lambda cell: cell.object.supply_point.overstocked_count(), sortable=False) last_seen = Column(name="Last message", value=lambda cell: cell.object.last_message.date.strftime("%b-%d-%Y") if cell.object.last_message else "n/a", sortable=False) class Meta: order_by = 'supply_point__code'
class FacilityTable(Table): name = Column(link=lambda cell: reverse("malawi_facility", args=[cell.object.code])) code = Column() district = Column(value=lambda cell: cell.object.parent.name, sortable=False) hsas = Column(name="Active HSAs", value=lambda cell: len(cell.object.get_children()), sortable=False) class Meta: order_by = 'code'
class HQFormDataTable(Table): # instanceID = Column() xmlns = Column() received_on = DateColumn() timeStart = DateColumn() timeEnd = DateColumn() userID = Column() username = Column() class Meta: order_by = '-received_on'
class UnrecognizedMessagesTable(Table): code = Column(value=lambda cell: cell.object.contact.supply_point.code, name="MSD Code", sort_key_fn=lambda obj: obj.supply_point.code, titleized=False, css_class=_msd_class) facility = Column(value=lambda cell: cell.object.contact.supply_point.name, link=msg_supply_point_link) contact = Column(sortable=False, value=lambda cell: cell.object.contact.name) date = DateColumn(format="H:i M d") text = Column()
class AggregateDeliveryTable(MonthTable): name = Column(value=lambda cell: cell.object.name, sort_key_fn=lambda object: object.name, link=lambda cell: reports_link(cell, 'delivery')) average_lead_time = Column( sortable=False, value=lambda cell: cell.object.breakdown.avg_lead_time, name="Average Lead Time", safe=True) class Meta: per_page = 9999
class NotesTable(Table): name = Column(sortable=False, value=lambda cell: cell.object.user.username) role = Column(sortable=False, value=lambda cell: _contact_or_none(cell, 'role')) date = DateColumn(format="d M Y P") phone = Column(sortable=False, value=lambda cell: _contact_or_none(cell, 'phone')) text = Column() class Meta: per_page = 5 order_by = "-date"
class StockRequestTable(Table): product = Column() is_emergency = EmergencyColumn() balance = Column() amount_requested = Column() amount_received = Column() requested_on = DateColumn() responded_on = DateColumn() received_on = DateColumn() status = StatusColumn() class Meta: order_by = '-requested_on'
class MessageTable(Table): # this is temporary, until i fix ModelTable! contact = Column() connection = Column() direction = Column() date = DateColumn(format="H:i d/m/Y") text = Column() class Meta: #model = Message #exclude = ['id'] order_by = '-date'
class MessageTable(Table): # this is temporary, until i fix ModelTable! contact = Column() connection = Column() direction = Column() date = DateColumn(format="H:i d/m/Y") text = Column(css_class="message") tags = Column(sortable=False, value=lambda cell: cell.object.get_tags_for_display()) class Meta: #model = Message #exclude = ['id'] order_by = '-date'
class SOHReportingTable(MonthTable): name = Column(sortable=False, link=_facility_link) last_reported = DateColumn(name="Last Stock Report Received", value=lambda cell: cell.object.last_soh_before(datetime(cell.row.table.year, cell.row.table.month, cell.row.table.day)) \ if cell.object.last_soh_before(datetime(cell.row.table.year, cell.row.table.month, cell.row.table.day)) else "never", format="M d, h:i A", sortable=False, css_class="tabledate") class Meta: order_by = '-last_reported'
class AuditLogTable(Table): date = DateColumn(format="H:i d/m/Y") user = Column() access_type = Column() designation = Column() organization = Column() facility = Column() location = Column() first_name = Column() last_name = Column() class Meta: order_by = '-date'