def __export_html(self, template_filename): template = get_template(template_filename, self.params.application.lang) if not template: return False data = parser(self.params) # Create context context = Context({ "title": _("Rescue Bag Inventory"), "vessel": self.params.vessel, "allowance_list": self.params.allowances, "data": data, "now": datetime.datetime.utcnow(), "expiry_date": self.params.today, "generator": "Pharmaship [proof-of-concept]" }) html_string = template.render(context) return html_string
def __export_html(self, template_filename): template = get_template( template_filename, self.params.application.lang ) if not template: return False # Get data result = { "molecules": [], "equipment": [], "telemedical": {}, "laboratory": {}, "first_aid_kit": {}, } # self.data data = {} items = parsers.medicines.parser(self.params) for group in items: subgroup = [] for item in items[group]: if item["has_date_expired"]: subgroup.append(item) if len(subgroup) > 0: data[group] = subgroup result["molecules"] = data data = {} items = parsers.equipment.parser(self.params) for group in items: subgroup = [] for item in items[group]: if item["has_date_expired"]: subgroup.append(item) if len(subgroup) > 0: data[group] = subgroup result["equipment"] = data data = {} kits = parsers.first_aid.parser(self.params) for kit in kits: for item in kit["elements"]: if not item["has_date_expired"]: continue id = "{type:03d}-{id:03d}".format(**item["parent"]) if id not in data: data[id] = [] for subitem in item["contents"]: if not subitem["expired"]: continue data[id].append(subitem) result["first_aid_kit"] = data if self.params.setting.has_laboratory: data = [] items = parsers.laboratory.parser(self.params) for item in items: if item["has_date_expired"]: data.append(item) result["laboratory"] = data if self.params.setting.has_telemedical: data = [] items = parsers.telemedical.parser(self.params) for item in items: if item["has_date_expired"]: data.append(item) result["telemedical"] = data # Create context context = Context({ "title": _("Perished Items"), "vessel": self.params.vessel, "allowance_list": self.params.allowances, "data": result, "laboratory": self.params.setting.has_laboratory, "telemedical": self.params.setting.has_telemedical, "now": datetime.datetime.utcnow(), "expiry_date": self.params.today, "generator": "Pharmaship [proof-of-concept]" }) html_string = template.render(context) return html_string