{"action":"created","comment":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/192984176","pull_request_review_id":125862726,"id":192984176,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Mjk4NDE3Ng==","diff_hunk":"@@ -0,0 +1,118 @@\n+from __future__ import absolute_import\n+from __future__ import unicode_literals\n+from corehq.apps.reports.filters.dates import DatespanFilter\n+from corehq.apps.reports.standard import CustomProjectReport, ProjectReportParametersMixin, DatespanMixin\n+from custom.intrahealth.filters import FicheLocationFilter\n+from custom.intrahealth.reports import IntraHealthLocationMixin, IntraHealthReportConfigMixin\n+from custom.intrahealth.sqldata import *\n+\n+\n+class MultiReport(CustomProjectReport, IntraHealthLocationMixin, IntraHealthReportConfigMixin, ProjectReportParametersMixin, DatespanMixin):\n+\n+    title = ''\n+    report_template_path = \"intrahealth/multi_report.html\"\n+    flush_layout = True\n+    export_format_override = 'csv'\n+\n+    @property\n+    @memoized\n+    def rendered_report_title(self):\n+        return self.title\n+\n+    @property\n+    @memoized\n+    def data_providers(self):\n+        return []\n+\n+    @property\n+    def report_context(self):\n+        context = {\n+            'reports': [self.get_report_context(dp) for dp in self.data_providers],\n+            'title': self.title\n+        }\n+\n+        return context\n+\n+    def get_report_context(self, data_provider):\n+\n+        total_row = []\n+        self.data_source = data_provider\n+        if self.needs_filters:\n+            headers = []\n+            rows = []\n+        else:\n+            rows = data_provider.rows\n+            headers = data_provider.headers\n+            total_row = data_provider.total_row\n+\n+        context = dict(\n+            report_table=dict(\n+                title=data_provider.title,\n+                slug=data_provider.slug,\n+                headers=headers,\n+                rows=rows,\n+                total_row=total_row,\n+                default_rows=self.default_rows,\n+                datatables=data_provider.datatables,\n+                fix_column=data_provider.fix_left_col\n+            )\n+        )\n+\n+        return context\n+\n+    @property\n+    def export_table(self):\n+        reports = [r['report_table'] for r in self.report_context['reports']]\n+        return [self._export_table(r['title'], r['headers'], r['rows'], total_row=r['total_row']) for r in reports]\n+\n+    def _export_table(self, export_sheet_name, headers, formatted_rows, total_row=None):\n+        def _unformat_row(row):\n+            return [col.get(\"sort_key\", col) if isinstance(col, dict) else col for col in row]\n+\n+        table = headers.as_export_table\n+        rows = [_unformat_row(row) for row in formatted_rows]\n+        replace = ''\n+\n+        #make headers and subheaders consistent\n+        for k, v in enumerate(table[0]):\n+            if v != ' ':\n+                replace = v\n+            else:\n+                table[0][k] = replace\n+        table.extend(rows)\n+        if total_row:\n+            table.append(_unformat_row(total_row))\n+\n+        return [export_sheet_name, table]\n+\n+\n+class FicheConsommationReport2(MultiReport):\n+    name = \"Fiche Consommation NEW\"\n+    slug = 'fiche_consommation2'\n+    title = \"Fiche Consommation NEW\"\n+    fields = [DatespanFilter, FicheLocationFilter]\n+    export_format_override = 'csv'\n+    default_rows = 10\n+    exportable = True\n+\n+    @property\n+    @memoized\n+    def data_providers(self):\n+        config = self.report_config\n+        locations = []\n+\n+        if 'region_id' in config:\n+            locations = tuple(SQLLocation.objects.get(","path":"custom/intrahealth/reports/fiche_consommation_report_v2.py","position":105,"original_position":105,"commit_id":"1ebea2be82e530b9f79076d065bd690af8e43554","original_commit_id":"1ebea2be82e530b9f79076d065bd690af8e43554","user":{"login":"stickler-ci","id":16011037,"node_id":"MDQ6VXNlcjE2MDExMDM3","avatar_url":"https://avatars3.githubusercontent.com/u/16011037?v=4","gravatar_id":"","url":"https://api.github.com/users/stickler-ci","html_url":"https://github.com/stickler-ci","followers_url":"https://api.github.com/users/stickler-ci/followers","following_url":"https://api.github.com/users/stickler-ci/following{/other_user}","gists_url":"https://api.github.com/users/stickler-ci/gists{/gist_id}","starred_url":"https://api.github.com/users/stickler-ci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stickler-ci/subscriptions","organizations_url":"https://api.github.com/users/stickler-ci/orgs","repos_url":"https://api.github.com/users/stickler-ci/repos","events_url":"https://api.github.com/users/stickler-ci/events{/privacy}","received_events_url":"https://api.github.com/users/stickler-ci/received_events","type":"User","site_admin":false},"body":"F405 'SQLLocation' may be undefined, or defined from star imports: custom.intrahealth.sqldata","created_at":"2018-06-05T08:16:51Z","updated_at":"2018-06-05T08:16:53Z","html_url":"https://github.com/dimagi/commcare-hq/pull/20763#discussion_r192984176","pull_request_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/20763","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments/192984176"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/20763#discussion_r192984176"},"pull_request":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/20763"}}},"pull_request":{"url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/20763","id":192442692,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyNDQyNjky","html_url":"https://github.com/dimagi/commcare-hq/pull/20763","diff_url":"https://github.com/dimagi/commcare-hq/pull/20763.diff","patch_url":"https://github.com/dimagi/commcare-hq/pull/20763.patch","issue_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/20763","number":20763,"state":"open","locked":false,"title":"Create Taux de Satisfaction report based on UCR with tests","user":{"login":"dmydlo","id":22706074,"node_id":"MDQ6VXNlcjIyNzA2MDc0","avatar_url":"https://avatars0.githubusercontent.com/u/22706074?v=4","gravatar_id":"","url":"https://api.github.com/users/dmydlo","html_url":"https://github.com/dmydlo","followers_url":"https://api.github.com/users/dmydlo/followers","following_url":"https://api.github.com/users/dmydlo/following{/other_user}","gists_url":"https://api.github.com/users/dmydlo/gists{/gist_id}","starred_url":"https://api.github.com/users/dmydlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmydlo/subscriptions","organizations_url":"https://api.github.com/users/dmydlo/orgs","repos_url":"https://api.github.com/users/dmydlo/repos","events_url":"https://api.github.com/users/dmydlo/events{/privacy}","received_events_url":"https://api.github.com/users/dmydlo/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-06-04T15:18:17Z","updated_at":"2018-06-05T08:16:54Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3577193e5079131bef9376527edd637390a79213","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/20763/commits","review_comments_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/20763/comments","review_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/20763/comments","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/1ebea2be82e530b9f79076d065bd690af8e43554","head":{"label":"dmydlo:intrahealth_reworking_old_reports","ref":"intrahealth_reworking_old_reports","sha":"1ebea2be82e530b9f79076d065bd690af8e43554","user":{"login":"dmydlo","id":22706074,"node_id":"MDQ6VXNlcjIyNzA2MDc0","avatar_url":"https://avatars0.githubusercontent.com/u/22706074?v=4","gravatar_id":"","url":"https://api.github.com/users/dmydlo","html_url":"https://github.com/dmydlo","followers_url":"https://api.github.com/users/dmydlo/followers","following_url":"https://api.github.com/users/dmydlo/following{/other_user}","gists_url":"https://api.github.com/users/dmydlo/gists{/gist_id}","starred_url":"https://api.github.com/users/dmydlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmydlo/subscriptions","organizations_url":"https://api.github.com/users/dmydlo/orgs","repos_url":"https://api.github.com/users/dmydlo/repos","events_url":"https://api.github.com/users/dmydlo/events{/privacy}","received_events_url":"https://api.github.com/users/dmydlo/received_events","type":"User","site_admin":false},"repo":{"id":118426994,"node_id":"MDEwOlJlcG9zaXRvcnkxMTg0MjY5OTQ=","name":"commcare-hq","full_name":"dmydlo/commcare-hq","owner":{"login":"dmydlo","id":22706074,"node_id":"MDQ6VXNlcjIyNzA2MDc0","avatar_url":"https://avatars0.githubusercontent.com/u/22706074?v=4","gravatar_id":"","url":"https://api.github.com/users/dmydlo","html_url":"https://github.com/dmydlo","followers_url":"https://api.github.com/users/dmydlo/followers","following_url":"https://api.github.com/users/dmydlo/following{/other_user}","gists_url":"https://api.github.com/users/dmydlo/gists{/gist_id}","starred_url":"https://api.github.com/users/dmydlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmydlo/subscriptions","organizations_url":"https://api.github.com/users/dmydlo/orgs","repos_url":"https://api.github.com/users/dmydlo/repos","events_url":"https://api.github.com/users/dmydlo/events{/privacy}","received_events_url":"https://api.github.com/users/dmydlo/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dmydlo/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":true,"url":"https://api.github.com/repos/dmydlo/commcare-hq","forks_url":"https://api.github.com/repos/dmydlo/commcare-hq/forks","keys_url":"https://api.github.com/repos/dmydlo/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dmydlo/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dmydlo/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dmydlo/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dmydlo/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dmydlo/commcare-hq/events","assignees_url":"https://api.github.com/repos/dmydlo/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dmydlo/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dmydlo/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dmydlo/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dmydlo/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dmydlo/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dmydlo/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dmydlo/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dmydlo/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dmydlo/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dmydlo/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dmydlo/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dmydlo/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dmydlo/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dmydlo/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dmydlo/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dmydlo/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dmydlo/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dmydlo/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dmydlo/commcare-hq/merges","archive_url":"https://api.github.com/repos/dmydlo/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dmydlo/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dmydlo/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dmydlo/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dmydlo/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dmydlo/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dmydlo/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dmydlo/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dmydlo/commcare-hq/deployments","created_at":"2018-01-22T08:17:17Z","updated_at":"2018-01-22T08:17:39Z","pushed_at":"2018-06-05T08:15:14Z","git_url":"git://github.com/dmydlo/commcare-hq.git","ssh_url":"git@github.com:dmydlo/commcare-hq.git","clone_url":"https://github.com/dmydlo/commcare-hq.git","svn_url":"https://github.com/dmydlo/commcare-hq","homepage":"http://www.commcarehq.org","size":392301,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dimagi:master","ref":"master","sha":"01dc8998a7250cfb5c51c2f96e26c2c98cbca03a","user":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":247278,"node_id":"MDEwOlJlcG9zaXRvcnkyNDcyNzg=","name":"commcare-hq","full_name":"dimagi/commcare-hq","owner":{"login":"dimagi","id":94514,"node_id":"MDEyOk9yZ2FuaXphdGlvbjk0NTE0","avatar_url":"https://avatars1.githubusercontent.com/u/94514?v=4","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/commcare-hq","description":"A server-side tool to help manage community health workers, written in Django","fork":false,"url":"https://api.github.com/repos/dimagi/commcare-hq","forks_url":"https://api.github.com/repos/dimagi/commcare-hq/forks","keys_url":"https://api.github.com/repos/dimagi/commcare-hq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/commcare-hq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/commcare-hq/teams","hooks_url":"https://api.github.com/repos/dimagi/commcare-hq/hooks","issue_events_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/commcare-hq/events","assignees_url":"https://api.github.com/repos/dimagi/commcare-hq/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/commcare-hq/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/commcare-hq/tags","blobs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/commcare-hq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/commcare-hq/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/commcare-hq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/commcare-hq/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/commcare-hq/languages","stargazers_url":"https://api.github.com/repos/dimagi/commcare-hq/stargazers","contributors_url":"https://api.github.com/repos/dimagi/commcare-hq/contributors","subscribers_url":"https://api.github.com/repos/dimagi/commcare-hq/subscribers","subscription_url":"https://api.github.com/repos/dimagi/commcare-hq/subscription","commits_url":"https://api.github.com/repos/dimagi/commcare-hq/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/commcare-hq/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/commcare-hq/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/commcare-hq/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/commcare-hq/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/commcare-hq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/commcare-hq/merges","archive_url":"https://api.github.com/repos/dimagi/commcare-hq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/commcare-hq/downloads","issues_url":"https://api.github.com/repos/dimagi/commcare-hq/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/commcare-hq/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/commcare-hq/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/commcare-hq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/commcare-hq/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/commcare-hq/releases{/id}","deployments_url":"https://api.github.com/repos/dimagi/commcare-hq/deployments","created_at":"2009-07-09T17:00:07Z","updated_at":"2018-06-05T07:59:30Z","pushed_at":"2018-06-05T08:15:18Z","git_url":"git://github.com/dimagi/commcare-hq.git","ssh_url":"git@github.com:dimagi/commcare-hq.git","clone_url":"https://github.com/dimagi/commcare-hq.git","svn_url":"https://github.com/dimagi/commcare-hq","homepage":"https://www.commcarehq.org","size":439910,"stargazers_count":92,"watchers_count":92,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":105,"mirror_url":null,"archived":false,"open_issues_count":72,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":105,"open_issues":72,"watchers":92,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/20763"},"html":{"href":"https://github.com/dimagi/commcare-hq/pull/20763"},"issue":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/20763"},"comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/issues/20763/comments"},"review_comments":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/20763/comments"},"review_comment":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dimagi/commcare-hq/pulls/20763/commits"},"statuses":{"href":"https://api.github.com/repos/dimagi/commcare-hq/statuses/1ebea2be82e530b9f79076d065bd690af8e43554"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"stickler-ci"}}