def list_incidents(self, request): #set_response_header(request, HeaderName.etag, "*") # FIXME set_response_header(request, HeaderName.contentType, ContentType.JSON) return to_json_text(sorted( incidents_from_query(self, request), cmp=lambda a, b: cmp(a[0], b[0]), reverse=True, ))
def queue(self, request, tag): return tag(incidents_as_table( ( self.ims.storage.read_incident_with_number(number) for number, etag in incidents_from_query(self.ims, request) ), caption="Dispatch Queue", id="dispatch_queue", ))
def data(self, request, tag): def format_date(d): if d is None: return "" else: return d.strftime("%a.%H:%M") data = [] for number, etag in incidents_from_query(self.ims, request): incident = self.ims.storage.read_incident_with_number(number) if incident.summary: summary = incident.summary elif incident.report_entries: for entry in incident.report_entries: if not entry.system_entry: summary = entry.text break else: summary = "" data.append([ incident.number, incident.priority, format_date(incident.created), format_date(incident.dispatched), format_date(incident.on_scene), format_date(incident.closed), ", ".join(ranger.handle for ranger in incident.rangers), str(incident.location), ", ".join(incident.incident_types), summary, ]) return to_json_text(data)
def list_incidents(self, request): #set_response_header(request, HeaderName.etag, "*") # FIXME set_response_header(request, HeaderName.contentType, ContentType.JSON) return to_json_text(tuple(incidents_from_query(self, request)))