コード例 #1
0
    def _export_table(self,
                      export_sheet_name,
                      headers,
                      formatted_rows,
                      total_row=None):
        def _unformat_row(row):
            return [
                col.get("sort_key", col) if isinstance(col, dict) else col
                for col in row
            ]

        table = headers.as_export_table
        table.insert(0, [
            SQLLocation.objects.get(
                location_id=self.report_config['location_id']).name
        ])
        rows = [_unformat_row(row) for row in formatted_rows]
        # Removing html icon tag from MOS column
        for row in rows:
            row[1] = GenericTabularReport._strip_tags(row[1])
        replace = ''

        for k, v in enumerate(table[1]):
            if v != ' ':
                replace = v
            else:
                table[1][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, self._report_info + table]
コード例 #2
0
 def test_strip_tags_expected_fail(self):
     """
     _strip_tags should not strip strings inside angle brackets, but does
     """
     value = '1 < 8 > 2'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, '1 < 8 > 2')
コード例 #3
0
 def test_strip_tags_html_bytestring(self):
     """
     _strip_tags should strip HTML tags
     """
     value = '<blink>182</blink>'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, '182')
コード例 #4
0
 def test_strip_tags_html_unicode(self):
     """
     _strip_tags should strip HTML tags from Unicode
     """
     value = u'<blink>182</blink>'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, u'182')
コード例 #5
0
 def test_strip_tags_passthru(self):
     """
     _strip_tags should allow non-basestring values to pass through
     """
     value = {'blink': 182}
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, {'blink': 182})
コード例 #6
0
 def test_strip_tags_expected_fail(self):
     """
     _strip_tags should not strip strings inside angle brackets, but does
     """
     value = '1 < 8 > 2'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, '1 < 8 > 2')
コード例 #7
0
ファイル: __init__.py プロジェクト: zbidi/commcare-hq
    def _export_table(self,
                      export_sheet_name,
                      headers,
                      formatted_rows,
                      total_row=None):
        def _unformat_row(row):
            return [
                col.get("sort_key", col) if isinstance(col, dict) else col
                for col in row
            ]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        replace = ''

        for row in rows:
            for index, value in enumerate(row):
                row[index] = GenericTabularReport._strip_tags(value)

        # make headers and subheaders consistent
        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, table]
コード例 #8
0
 def test_strip_tags_html_bytestring(self):
     """
     _strip_tags should strip HTML tags
     """
     value = '<blink>182</blink>'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, '182')
コード例 #9
0
 def test_strip_tags_passthru(self):
     """
     _strip_tags should allow non-basestring values to pass through
     """
     value = {'blink': 182}
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, {'blink': 182})
コード例 #10
0
    def _export(self,
                export_sheet_name,
                headers,
                formatted_rows,
                total_row=None):
        def _unformat_row(row):
            return [
                col.get("sort_key", col) if isinstance(col, dict) else col
                for col in row
            ]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        for row in rows:
            row[0] = GenericTabularReport._strip_tags(row[0])
        replace = ''

        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, self._report_info + table]
コード例 #11
0
 def test_strip_tags_html_unicode(self):
     """
     _strip_tags should strip HTML tags from Unicode
     """
     value = u'<blink>182</blink>'
     value = GenericTabularReport._strip_tags(value)
     self.assertEqual(value, u'182')
コード例 #12
0
    def _export(self, export_sheet_name, headers, formatted_rows, total_row=None):
        def _unformat_row(row):
            return [col.get("sort_key", col) if isinstance(col, dict) else col for col in row]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        for row in rows:
            row[0] = GenericTabularReport._strip_tags(row[0])
        replace = ''

        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)

        return [export_sheet_name, self._report_info + table]
コード例 #13
0
ファイル: __init__.py プロジェクト: jmaina/commcare-hq
    def _export_table(self, export_sheet_name, headers, formatted_rows, total_row=None):
        def _unformat_row(row):
            return [col.get("sort_key", col) if isinstance(col, dict) else col for col in row]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        # Removing html icon tag from MOS column
        for row in rows:
            row[1] = GenericTabularReport._strip_tags(row[1])
        replace = ''

        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, table]
コード例 #14
0
ファイル: __init__.py プロジェクト: saketkanth/commcare-hq
    def _export_table(self, export_sheet_name, headers, formatted_rows, total_row=None):
        def _unformat_row(row):
            return [col.get("sort_key", col) if isinstance(col, dict) else col for col in row]

        table = headers.as_export_table
        table.insert(0, [SQLLocation.objects.get(location_id=self.report_config['location_id']).name])
        rows = [_unformat_row(row) for row in formatted_rows]
        # Removing html icon tag from MOS column
        for row in rows:
            row[1] = GenericTabularReport._strip_tags(row[1])
        replace = ''

        for k, v in enumerate(table[1]):
            if v != ' ':
                replace = v
            else:
                table[1][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, self._report_info + table]
コード例 #15
0
ファイル: __init__.py プロジェクト: puttarajubr/commcare-hq
    def _export_table(self, export_sheet_name, headers, formatted_rows, total_row=None):
        def _unformat_row(row):
            return [col.get("sort_key", col) if isinstance(col, dict) else col for col in row]

        table = headers.as_export_table
        rows = [_unformat_row(row) for row in formatted_rows]
        replace = ''

        for row in rows:
            for index, value in enumerate(row):
                row[index] = GenericTabularReport._strip_tags(value)

        # make headers and subheaders consistent
        for k, v in enumerate(table[0]):
            if v != ' ':
                replace = v
            else:
                table[0][k] = replace
        table.extend(rows)
        if total_row:
            table.append(_unformat_row(total_row))

        return [export_sheet_name, table]