def make_rows(self, es_results, with_checkbox): submissions = [ res['_source'] for res in self.es_results.get('hits', {}).get('hits', []) ] for form in submissions: data = calculate_form_data(self, form) try: status_data = McctStatus.objects.get( domain=self.domain, form_id=data.get('form_id')) status, reason, status_date, username = ( status_data.status, status_data.reason, status_data.modified_on, status_data.user) except: status, reason, status_date, username = ('eligible', None, None, None) row = [ status_date.strftime(SERVER_DATETIME_FORMAT_NO_SEC) if status_date is not None else EMPTY_FIELD, self._get_case_name_html(data.get('case'), with_checkbox), self._get_service_type_html(form, data.get('service_type'), with_checkbox), data.get('location_name'), get_property(data.get('case'), "card_number", EMPTY_FIELD), data.get('location_parent_name'), get_property(data.get('case'), "phone_number", EMPTY_FIELD), data.get('amount_due'), status, REJECTION_REASON_DISPLAY_NAMES[reason] if reason is not None else '', username if username else form["form"]["meta"]["username"] ] yield row
def make_rows(self, es_results, with_checkbox): submissions = [res['_source'] for res in self.es_results.get('hits', {}).get('hits', [])] for form in submissions: data = calculate_form_data(self, form) try: status_data = McctStatus.objects.get(domain=self.domain, form_id=data.get('form_id')) reason = status_data.reason except McctStatus.DoesNotExist: reason = None row = [ iso_string_to_datetime(form["form"]["meta"]["timeEnd"]).strftime(SERVER_DATETIME_FORMAT_NO_SEC), self._get_case_name_html(data.get('case'), with_checkbox), self._get_service_type_html(form, data.get('service_type'), with_checkbox), data.get('location_name'), get_property(data.get('case'), "card_number", EMPTY_FIELD), data.get('location_parent_name'), get_property(data.get('case'), "phone_number", EMPTY_FIELD), data.get('amount_due'), REJECTION_REASON_DISPLAY_NAMES[reason] if reason is not None else '', form["form"]["meta"]["username"] ] if with_checkbox: checkbox = mark_safe('<input type="checkbox" class="selected-element" ' 'data-formid="%(form_id)s" ' 'data-caseid="%(case_id)s" data-servicetype="%(service_type)s"/>') row.append(checkbox % dict(form_id=data.get('form_id'), case_id=data.get('case_id'), service_type=data.get('service_type'))) else: row.insert(8, self.display_status) yield row
def make_rows(self, es_results, with_checkbox): submissions = [ res['_source'] for res in self.es_results.get('hits', {}).get('hits', []) ] for form in submissions: data = calculate_form_data(self, form) row = [ json_format_date( iso_string_to_datetime(form["form"]["meta"]["timeEnd"])), self._get_case_name_html(data.get('case'), with_checkbox), self._get_service_type_html(form, data.get('service_type'), with_checkbox), data.get('location_name'), get_property(data.get('case'), "card_number", EMPTY_FIELD), data.get('location_parent_name'), get_property(data.get('case'), "phone_number", EMPTY_FIELD), data.get('amount_due'), get_property(data.get('case'), "visits", EMPTY_FIELD) ] if with_checkbox: checkbox = mark_safe( '<input type="checkbox" class="selected-element" ' 'data-formid="%(form_id)s" ' 'data-caseid="%(case_id)s" data-servicetype="%(service_type)s"/>' ) row.append(checkbox % dict(form_id=data.get('form_id'), case_id=data.get('case_id'), service_type=data.get('service_type'))) else: row.append(self.display_status) yield row
def make_rows(self, es_results, with_checkbox): submissions = [res['_source'] for res in self.es_results.get('hits', {}).get('hits', [])] for form in submissions: data = calculate_form_data(self, form) row = [ DateTimeProperty().wrap(form["form"]["meta"]["timeEnd"]).strftime("%Y-%m-%d"), self._get_case_name_html(data.get('case'), with_checkbox), self._get_service_type_html(form, data.get('service_type'), with_checkbox), data.get('location_name'), get_property(data.get('case'), "card_number", EMPTY_FIELD), data.get('location_parent_name'), get_property(data.get('case'), "phone_number", EMPTY_FIELD), data.get('amount_due') ] if with_checkbox: checkbox = mark_safe('<input type="checkbox" class="selected-element" ' 'data-bind="event: {change: updateSelection}" data-formid="%(form_id)s" ' 'data-caseid="%(case_id)s" data-servicetype="%(service_type)s"/>') row.append(checkbox % dict(form_id=data.get('form_id'), case_id=data.get('case_id'), service_type=data.get('service_type'))) else: row.append(self.display_status) yield row
def make_rows(self, es_results, with_checkbox): submissions = [res['_source'] for res in self.es_results.get('hits', {}).get('hits', [])] for form in submissions: data = calculate_form_data(self, form) try: status_data = McctStatus.objects.get(domain=self.domain, form_id=data.get('form_id')) status, reason = (status_data.status, status_data.reason) except McctStatus.DoesNotExist: status, reason = ('eligible', None) row = [ DateTimeProperty().wrap(form["form"]["meta"]["timeEnd"]).strftime("%Y-%m-%d %H:%M"), self._get_case_name_html(data.get('case'), with_checkbox), self._get_service_type_html(form, data.get('service_type'), with_checkbox), data.get('location_name'), get_property(data.get('case'), "card_number", EMPTY_FIELD), data.get('location_parent_name'), get_property(data.get('case'), "phone_number", EMPTY_FIELD), data.get('amount_due'), status, REJECTION_REASON_DISPLAY_NAMES[reason] if reason is not None else '', form["form"]["meta"]["username"] ] yield row
def make_rows(self, es_results, with_checkbox): submissions = [res['_source'] for res in self.es_results.get('hits', {}).get('hits', [])] for form in submissions: data = calculate_form_data(self, form) try: status_data = McctStatus.objects.get(domain=self.domain, form_id=data.get('form_id')) status, reason, status_date, username = (status_data.status, status_data.reason, status_data.modified_on, status_data.user) except: status, reason, status_date, username = ('eligible', None, None, None) row = [ status_date.strftime(SERVER_DATETIME_FORMAT_NO_SEC) if status_date is not None else EMPTY_FIELD, self._get_case_name_html(data.get('case'), with_checkbox), self._get_service_type_html(form, data.get('service_type'), with_checkbox), data.get('location_name'), get_property(data.get('case'), "card_number", EMPTY_FIELD), data.get('location_parent_name'), get_property(data.get('case'), "phone_number", EMPTY_FIELD), data.get('amount_due'), status, REJECTION_REASON_DISPLAY_NAMES[reason] if reason is not None else '', username if username else form["form"]["meta"]["username"] ] yield row
def _get_case_name_html(self, case, add_link): case_name = get_property(case, "full_name", EMPTY_FIELD) return self._make_link( reverse('case_details', args=[self.domain, case._id]), case_name ) if add_link else case_name