{"action":"created","comment":{"url":"https://api.github.com/repos/eHealthAfrica/aether/pulls/comments/214815960","pull_request_review_id":151946141,"id":214815960,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNDgxNTk2MA==","diff_hunk":"@@ -0,0 +1,37 @@\n+# Copyright (C) 2018 by eHealth Africa : http://www.eHealthAfrica.org\n+#\n+# See the NOTICE file distributed with this work for additional information\n+# regarding copyright ownership.\n+#\n+# Licensed under the Apache License, Version 2.0 (the \"License\");\n+# you may not use this file except in compliance with\n+# the License.  You may obtain a copy of the License at\n+#\n+#   http://www.apache.org/licenses/LICENSE-2.0\n+#\n+# Unless required by applicable law or agreed to in writing,\n+# software distributed under the License is distributed on an\n+# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+# KIND, either express or implied.  See the License for the\n+# specific language governing permissions and limitations\n+# under the License.\n+\n+from django.conf import settings\n+\n+\n+def resolve_file_url(url):\n+    '''\n+    Make all file urls absolute.\n+    '''\n+    if url.startswith('/'):\n+        # For local development, the environment variable DJANGO_REMOTE_STORAGE is\n+        # set to \"filesytem\" and files (attachments, media files etc.) are stored on\n+        # the filesystem and served via nginx. Example URL:\n+        # http://odk.aether.local/media/<path-to-file>.\n+        ssl_header = settings.SECURE_PROXY_SSL_HEADER\n+        scheme = ssl_header[1] if ssl_header else 'http'\n+        return f'{scheme}://{settings.HOSTNAME}{url}'","path":"aether-common-module/aether/common/utils.py","position":33,"original_position":33,"commit_id":"f471f91258d25550b239c34f2272c1fafcdade53","original_commit_id":"f471f91258d25550b239c34f2272c1fafcdade53","user":{"login":"obdulia-losantos","id":8459537,"node_id":"MDQ6VXNlcjg0NTk1Mzc=","avatar_url":"https://avatars1.githubusercontent.com/u/8459537?v=4","gravatar_id":"","url":"https://api.github.com/users/obdulia-losantos","html_url":"https://github.com/obdulia-losantos","followers_url":"https://api.github.com/users/obdulia-losantos/followers","following_url":"https://api.github.com/users/obdulia-losantos/following{/other_user}","gists_url":"https://api.github.com/users/obdulia-losantos/gists{/gist_id}","starred_url":"https://api.github.com/users/obdulia-losantos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obdulia-losantos/subscriptions","organizations_url":"https://api.github.com/users/obdulia-losantos/orgs","repos_url":"https://api.github.com/users/obdulia-losantos/repos","events_url":"https://api.github.com/users/obdulia-losantos/events{/privacy}","received_events_url":"https://api.github.com/users/obdulia-losantos/received_events","type":"User","site_admin":false},"body":"Now that the `HOSTNAME` is needed for this, could you mention it in the README?","created_at":"2018-09-04T07:49:20Z","updated_at":"2018-09-04T07:49:20Z","html_url":"https://github.com/eHealthAfrica/aether/pull/335#discussion_r214815960","pull_request_url":"https://api.github.com/repos/eHealthAfrica/aether/pulls/335","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/eHealthAfrica/aether/pulls/comments/214815960"},"html":{"href":"https://github.com/eHealthAfrica/aether/pull/335#discussion_r214815960"},"pull_request":{"href":"https://api.github.com/repos/eHealthAfrica/aether/pulls/335"}}},"pull_request":{"url":"https://api.github.com/repos/eHealthAfrica/aether/pulls/335","id":211114010,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExMTE0MDEw","html_url":"https://github.com/eHealthAfrica/aether/pull/335","diff_url":"https://github.com/eHealthAfrica/aether/pull/335.diff","patch_url":"https://github.com/eHealthAfrica/aether/pull/335.patch","issue_url":"https://api.github.com/repos/eHealthAfrica/aether/issues/335","number":335,"state":"open","locked":false,"title":"fix: remote storage, file urls","user":{"login":"quesebifurcan","id":3536066,"node_id":"MDQ6VXNlcjM1MzYwNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/3536066?v=4","gravatar_id":"","url":"https://api.github.com/users/quesebifurcan","html_url":"https://github.com/quesebifurcan","followers_url":"https://api.github.com/users/quesebifurcan/followers","following_url":"https://api.github.com/users/quesebifurcan/following{/other_user}","gists_url":"https://api.github.com/users/quesebifurcan/gists{/gist_id}","starred_url":"https://api.github.com/users/quesebifurcan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quesebifurcan/subscriptions","organizations_url":"https://api.github.com/users/quesebifurcan/orgs","repos_url":"https://api.github.com/users/quesebifurcan/repos","events_url":"https://api.github.com/users/quesebifurcan/events{/privacy}","received_events_url":"https://api.github.com/users/quesebifurcan/received_events","type":"User","site_admin":false},"body":"Fix file urls in kernel and odk.\r\n\r\n* Add function `resolve_file_url()` to common module. \r\n\r\nFor local development, the environment variable DJANGO_REMOTE_STORAGE is set to \"filesystem\" and files (attachments, media files etc.) are stored on the file system and served via nginx. Example URL: `http://odk.aether.local/media/<path-to-file>`. The hostname of the docker container is prepended to the media file url so that the resource can be served locally.\r\n       \r\nWhen the environment variable DJANGO_REMOTE_STORAGE is set to \"s3\" or \"gcs\", all file urls will be absolute. Example: `https://abcd.s3.amazonaws.com/<file-name>?AWSAccessKeyId=ABC&Signature=ABC%3D&Expires=1534775613`. This url is not modified.\r\n\r\n* Adjust ODK manifest file creation so that it works with remote storage.\r\n\r\n* Fix broken attachment links in kernel. On current develop, the attachment urls include port numbers (generated via HyperLinkedIdentityField), which doesn't play well with our nginx setup.\r\n\r\n### Testing this pull request\r\n\r\nThis PR is unfortunately a bit tricky to test, since it involves ODK Collect, Gather, aether-kernel and aether-odk-module. We are working on an integration test for this part. Steps to take:\r\n- Check out `fix/remote-storage/file-urls` in this repo\r\n- Check out `develop` on https://github.com/eHealthAfrica/gather\r\n- Modify both kernel and odk services in `<aether>/docker-compose-base.yml` to include the following details:\r\n```\r\nDJANGO_STORAGE_BACKEND: s3\r\nBUCKET_NAME: <bucket-name>\r\nAWS_ACCESS_KEY_ID: <access-key-id>\r\nAWS_SECRET_ACCESS_KEY:  <secret-access-key>\r\n```\r\n- Go to the gather repo and run `docker-compose -f docker-compose-local.yml up`. This will bring up the most recent version of gather with aether checked out at `fix/remote-storage/file-urls`.\r\n- Open `gather.local` in a browser and upload a form. Make sure that the form contains media files so we can check that file urls in gather and aether are working as expected.\r\n- Download ODK Collect, point it at your local instance of aether-odk-module and download the new form. If everything works as expected, the manifest file was generated correctly.\r\n- Fill out and submit the form. Please include at least one image/audio/video file.\r\n\r\nAt this point, we can verify that:\r\n- The attachment links in Gather are working (click on each attachment link in the table)\r\n- The attachment links in Aether are working (click on each attachment link in the response from the `/attachments` endpoint)\r\n- The nested resources in Aether are working (click on each nested attachment link in the response from the `/entities` endpoint)","created_at":"2018-08-27T13:42:17Z","updated_at":"2018-09-04T07:49:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0a31837fb5782b45da4eb70f9029c37865a2a4e2","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/eHealthAfrica/aether/pulls/335/commits","review_comments_url":"https://api.github.com/repos/eHealthAfrica/aether/pulls/335/comments","review_comment_url":"https://api.github.com/repos/eHealthAfrica/aether/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eHealthAfrica/aether/issues/335/comments","statuses_url":"https://api.github.com/repos/eHealthAfrica/aether/statuses/f471f91258d25550b239c34f2272c1fafcdade53","head":{"label":"eHealthAfrica:fix/remote-storage/file-urls","ref":"fix/remote-storage/file-urls","sha":"f471f91258d25550b239c34f2272c1fafcdade53","user":{"login":"eHealthAfrica","id":3214042,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMTQwNDI=","avatar_url":"https://avatars0.githubusercontent.com/u/3214042?v=4","gravatar_id":"","url":"https://api.github.com/users/eHealthAfrica","html_url":"https://github.com/eHealthAfrica","followers_url":"https://api.github.com/users/eHealthAfrica/followers","following_url":"https://api.github.com/users/eHealthAfrica/following{/other_user}","gists_url":"https://api.github.com/users/eHealthAfrica/gists{/gist_id}","starred_url":"https://api.github.com/users/eHealthAfrica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eHealthAfrica/subscriptions","organizations_url":"https://api.github.com/users/eHealthAfrica/orgs","repos_url":"https://api.github.com/users/eHealthAfrica/repos","events_url":"https://api.github.com/users/eHealthAfrica/events{/privacy}","received_events_url":"https://api.github.com/users/eHealthAfrica/received_events","type":"Organization","site_admin":false},"repo":{"id":110524187,"node_id":"MDEwOlJlcG9zaXRvcnkxMTA1MjQxODc=","name":"aether","full_name":"eHealthAfrica/aether","owner":{"login":"eHealthAfrica","id":3214042,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMTQwNDI=","avatar_url":"https://avatars0.githubusercontent.com/u/3214042?v=4","gravatar_id":"","url":"https://api.github.com/users/eHealthAfrica","html_url":"https://github.com/eHealthAfrica","followers_url":"https://api.github.com/users/eHealthAfrica/followers","following_url":"https://api.github.com/users/eHealthAfrica/following{/other_user}","gists_url":"https://api.github.com/users/eHealthAfrica/gists{/gist_id}","starred_url":"https://api.github.com/users/eHealthAfrica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eHealthAfrica/subscriptions","organizations_url":"https://api.github.com/users/eHealthAfrica/orgs","repos_url":"https://api.github.com/users/eHealthAfrica/repos","events_url":"https://api.github.com/users/eHealthAfrica/events{/privacy}","received_events_url":"https://api.github.com/users/eHealthAfrica/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eHealthAfrica/aether","description":"A platform for data curation, exchange, and publication","fork":false,"url":"https://api.github.com/repos/eHealthAfrica/aether","forks_url":"https://api.github.com/repos/eHealthAfrica/aether/forks","keys_url":"https://api.github.com/repos/eHealthAfrica/aether/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eHealthAfrica/aether/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eHealthAfrica/aether/teams","hooks_url":"https://api.github.com/repos/eHealthAfrica/aether/hooks","issue_events_url":"https://api.github.com/repos/eHealthAfrica/aether/issues/events{/number}","events_url":"https://api.github.com/repos/eHealthAfrica/aether/events","assignees_url":"https://api.github.com/repos/eHealthAfrica/aether/assignees{/user}","branches_url":"https://api.github.com/repos/eHealthAfrica/aether/branches{/branch}","tags_url":"https://api.github.com/repos/eHealthAfrica/aether/tags","blobs_url":"https://api.github.com/repos/eHealthAfrica/aether/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eHealthAfrica/aether/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eHealthAfrica/aether/git/refs{/sha}","trees_url":"https://api.github.com/repos/eHealthAfrica/aether/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eHealthAfrica/aether/statuses/{sha}","languages_url":"https://api.github.com/repos/eHealthAfrica/aether/languages","stargazers_url":"https://api.github.com/repos/eHealthAfrica/aether/stargazers","contributors_url":"https://api.github.com/repos/eHealthAfrica/aether/contributors","subscribers_url":"https://api.github.com/repos/eHealthAfrica/aether/subscribers","subscription_url":"https://api.github.com/repos/eHealthAfrica/aether/subscription","commits_url":"https://api.github.com/repos/eHealthAfrica/aether/commits{/sha}","git_commits_url":"https://api.github.com/repos/eHealthAfrica/aether/git/commits{/sha}","comments_url":"https://api.github.com/repos/eHealthAfrica/aether/comments{/number}","issue_comment_url":"https://api.github.com/repos/eHealthAfrica/aether/issues/comments{/number}","contents_url":"https://api.github.com/repos/eHealthAfrica/aether/contents/{+path}","compare_url":"https://api.github.com/repos/eHealthAfrica/aether/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eHealthAfrica/aether/merges","archive_url":"https://api.github.com/repos/eHealthAfrica/aether/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eHealthAfrica/aether/downloads","issues_url":"https://api.github.com/repos/eHealthAfrica/aether/issues{/number}","pulls_url":"https://api.github.com/repos/eHealthAfrica/aether/pulls{/number}","milestones_url":"https://api.github.com/repos/eHealthAfrica/aether/milestones{/number}","notifications_url":"https://api.github.com/repos/eHealthAfrica/aether/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eHealthAfrica/aether/labels{/name}","releases_url":"https://api.github.com/repos/eHealthAfrica/aether/releases{/id}","deployments_url":"https://api.github.com/repos/eHealthAfrica/aether/deployments","created_at":"2017-11-13T08:59:49Z","updated_at":"2018-08-27T09:52:57Z","pushed_at":"2018-09-04T07:49:04Z","git_url":"git://github.com/eHealthAfrica/aether.git","ssh_url":"git@github.com:eHealthAfrica/aether.git","clone_url":"https://github.com/eHealthAfrica/aether.git","svn_url":"https://github.com/eHealthAfrica/aether","homepage":"https://aether.ehealthafrica.org/","size":17508,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1,"open_issues":10,"watchers":1,"default_branch":"develop"}},"base":{"label":"eHealthAfrica:develop","ref":"develop","sha":"5a522d8a482222448a33d80dffcc36889bce4385","user":{"login":"eHealthAfrica","id":3214042,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMTQwNDI=","avatar_url":"https://avatars0.githubusercontent.com/u/3214042?v=4","gravatar_id":"","url":"https://api.github.com/users/eHealthAfrica","html_url":"https://github.com/eHealthAfrica","followers_url":"https://api.github.com/users/eHealthAfrica/followers","following_url":"https://api.github.com/users/eHealthAfrica/following{/other_user}","gists_url":"https://api.github.com/users/eHealthAfrica/gists{/gist_id}","starred_url":"https://api.github.com/users/eHealthAfrica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eHealthAfrica/subscriptions","organizations_url":"https://api.github.com/users/eHealthAfrica/orgs","repos_url":"https://api.github.com/users/eHealthAfrica/repos","events_url":"https://api.github.com/users/eHealthAfrica/events{/privacy}","received_events_url":"https://api.github.com/users/eHealthAfrica/received_events","type":"Organization","site_admin":false},"repo":{"id":110524187,"node_id":"MDEwOlJlcG9zaXRvcnkxMTA1MjQxODc=","name":"aether","full_name":"eHealthAfrica/aether","owner":{"login":"eHealthAfrica","id":3214042,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMyMTQwNDI=","avatar_url":"https://avatars0.githubusercontent.com/u/3214042?v=4","gravatar_id":"","url":"https://api.github.com/users/eHealthAfrica","html_url":"https://github.com/eHealthAfrica","followers_url":"https://api.github.com/users/eHealthAfrica/followers","following_url":"https://api.github.com/users/eHealthAfrica/following{/other_user}","gists_url":"https://api.github.com/users/eHealthAfrica/gists{/gist_id}","starred_url":"https://api.github.com/users/eHealthAfrica/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eHealthAfrica/subscriptions","organizations_url":"https://api.github.com/users/eHealthAfrica/orgs","repos_url":"https://api.github.com/users/eHealthAfrica/repos","events_url":"https://api.github.com/users/eHealthAfrica/events{/privacy}","received_events_url":"https://api.github.com/users/eHealthAfrica/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/eHealthAfrica/aether","description":"A platform for data curation, exchange, and publication","fork":false,"url":"https://api.github.com/repos/eHealthAfrica/aether","forks_url":"https://api.github.com/repos/eHealthAfrica/aether/forks","keys_url":"https://api.github.com/repos/eHealthAfrica/aether/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eHealthAfrica/aether/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eHealthAfrica/aether/teams","hooks_url":"https://api.github.com/repos/eHealthAfrica/aether/hooks","issue_events_url":"https://api.github.com/repos/eHealthAfrica/aether/issues/events{/number}","events_url":"https://api.github.com/repos/eHealthAfrica/aether/events","assignees_url":"https://api.github.com/repos/eHealthAfrica/aether/assignees{/user}","branches_url":"https://api.github.com/repos/eHealthAfrica/aether/branches{/branch}","tags_url":"https://api.github.com/repos/eHealthAfrica/aether/tags","blobs_url":"https://api.github.com/repos/eHealthAfrica/aether/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eHealthAfrica/aether/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eHealthAfrica/aether/git/refs{/sha}","trees_url":"https://api.github.com/repos/eHealthAfrica/aether/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eHealthAfrica/aether/statuses/{sha}","languages_url":"https://api.github.com/repos/eHealthAfrica/aether/languages","stargazers_url":"https://api.github.com/repos/eHealthAfrica/aether/stargazers","contributors_url":"https://api.github.com/repos/eHealthAfrica/aether/contributors","subscribers_url":"https://api.github.com/repos/eHealthAfrica/aether/subscribers","subscription_url":"https://api.github.com/repos/eHealthAfrica/aether/subscription","commits_url":"https://api.github.com/repos/eHealthAfrica/aether/commits{/sha}","git_commits_url":"https://api.github.com/repos/eHealthAfrica/aether/git/commits{/sha}","comments_url":"https://api.github.com/repos/eHealthAfrica/aether/comments{/number}","issue_comment_url":"https://api.github.com/repos/eHealthAfrica/aether/issues/comments{/number}","contents_url":"https://api.github.com/repos/eHealthAfrica/aether/contents/{+path}","compare_url":"https://api.github.com/repos/eHealthAfrica/aether/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eHealthAfrica/aether/merges","archive_url":"https://api.github.com/repos/eHealthAfrica/aether/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eHealthAfrica/aether/downloads","issues_url":"https://api.github.com/repos/eHealthAfrica/aether/issues{/number}","pulls_url":"https://api.github.com/repos/eHealthAfrica/aether/pulls{/number}","milestones_url":"https://api.github.com/repos/eHealthAfrica/aether/milestones{/number}","notifications_url":"https://api.github.com/repos/eHealthAfrica/aether/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eHealthAfrica/aether/labels{/name}","releases_url":"https://api.github.com/repos/eHealthAfrica/aether/releases{/id}","deployments_url":"https://api.github.com/repos/eHealthAfrica/aether/deployments","created_at":"2017-11-13T08:59:49Z","updated_at":"2018-08-27T09:52:57Z","pushed_at":"2018-09-04T07:49:04Z","git_url":"git://github.com/eHealthAfrica/aether.git","ssh_url":"git@github.com:eHealthAfrica/aether.git","clone_url":"https://github.com/eHealthAfrica/aether.git","svn_url":"https://github.com/eHealthAfrica/aether","homepage":"https://aether.ehealthafrica.org/","size":17508,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":10,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1,"open_issues":10,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/eHealthAfrica/aether/pulls/335"},"html":{"href":"https://github.com/eHealthAfrica/aether/pull/335"},"issue":{"href":"https://api.github.com/repos/eHealthAfrica/aether/issues/335"},"comments":{"href":"https://api.github.com/repos/eHealthAfrica/aether/issues/335/comments"},"review_comments":{"href":"https://api.github.com/repos/eHealthAfrica/aether/pulls/335/comments"},"review_comment":{"href":"https://api.github.com/repos/eHealthAfrica/aether/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eHealthAfrica/aether/pulls/335/commits"},"statuses":{"href":"https://api.github.com/repos/eHealthAfrica/aether/statuses/f471f91258d25550b239c34f2272c1fafcdade53"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"obdulia-losantos"}}