{"action":"created","comment":{"url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/comments/185010497","pull_request_review_id":116315964,"id":185010497,"diff_hunk":"@@ -0,0 +1,80 @@\n+from datetime import datetime\n+from functools import lru_cache\n+\n+import reversion\n+\n+from datahub.company.models import Advisor\n+from datahub.dbmaintenance.utils import parse_uuid\n+from datahub.investment.models import InvestmentProject\n+from datahub.metadata.models import InvestmentProjectStage\n+from ..base import CSVBaseCommand\n+\n+\n+class Command(CSVBaseCommand):\n+    \"\"\"Command to update investment_project.stage.\"\"\"\n+\n+    def add_arguments(self, parser):\n+        \"\"\"Define extra arguments.\"\"\"\n+        super().add_arguments(parser)\n+        parser.add_argument(\n+            '--simulate',\n+            action='store_true',\n+            default=False,\n+            help='If True it only simulates the command without saving the changes.',\n+        )\n+        parser.add_argument(\n+            '--user',\n+            default=False,\n+            dest='user',\n+            action='store',\n+            help='UUID of a valid adviser to use as the modified_by value',\n+        )\n+\n+    @lru_cache(maxsize=None)\n+    def get_stage(self, stage_id):\n+        \"\"\"\n+        :param company_id: uuid of the company\n+        :return: instance of investment project stage with id == stage_id if it exists,\n+            None otherwise\n+        \"\"\"\n+        if not stage_id or stage_id == 'null':\n+            return None\n+        return InvestmentProjectStage.objects.get(id=stage_id)\n+\n+    def get_adviser(self, adviser_id):\n+        \"\"\"\n+        :param adviser: uuid of the company\n+        :return: instance of a data hub adviser,\n+            None otherwise\n+        \"\"\"\n+        if not adviser_id or adviser_id == 'null':\n+            return None\n+        return Advisor.objects.get(id=adviser_id)\n+\n+    def _process_row(self, row, simulate=False, user=False, **options):\n+        \"\"\"Process one single row.\"\"\"\n+        id = parse_uuid(row['id'])\n+        stage = parse_uuid(row['new_stage'])","path":"datahub/dbmaintenance/management/commands/update_investment_project_stage.py","position":57,"original_position":57,"commit_id":"e7ab341f42243089af74bd163c04e6b23801d7d2","original_commit_id":"e7ab341f42243089af74bd163c04e6b23801d7d2","user":{"login":"marcofucci","id":178865,"avatar_url":"https://avatars3.githubusercontent.com/u/178865?v=4","gravatar_id":"","url":"https://api.github.com/users/marcofucci","html_url":"https://github.com/marcofucci","followers_url":"https://api.github.com/users/marcofucci/followers","following_url":"https://api.github.com/users/marcofucci/following{/other_user}","gists_url":"https://api.github.com/users/marcofucci/gists{/gist_id}","starred_url":"https://api.github.com/users/marcofucci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcofucci/subscriptions","organizations_url":"https://api.github.com/users/marcofucci/orgs","repos_url":"https://api.github.com/users/marcofucci/repos","events_url":"https://api.github.com/users/marcofucci/events{/privacy}","received_events_url":"https://api.github.com/users/marcofucci/received_events","type":"User","site_admin":false},"body":"`stage_id` might be a better name?","created_at":"2018-04-30T14:54:21Z","updated_at":"2018-04-30T14:54:21Z","html_url":"https://github.com/uktrade/data-hub-leeloo/pull/931#discussion_r185010497","pull_request_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/931","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/comments/185010497"},"html":{"href":"https://github.com/uktrade/data-hub-leeloo/pull/931#discussion_r185010497"},"pull_request":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/931"}}},"pull_request":{"url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/931","id":184012070,"html_url":"https://github.com/uktrade/data-hub-leeloo/pull/931","diff_url":"https://github.com/uktrade/data-hub-leeloo/pull/931.diff","patch_url":"https://github.com/uktrade/data-hub-leeloo/pull/931.patch","issue_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/931","number":931,"state":"open","locked":false,"title":"Feature/update stages","user":{"login":"jim68000","id":161962,"avatar_url":"https://avatars3.githubusercontent.com/u/161962?v=4","gravatar_id":"","url":"https://api.github.com/users/jim68000","html_url":"https://github.com/jim68000","followers_url":"https://api.github.com/users/jim68000/followers","following_url":"https://api.github.com/users/jim68000/following{/other_user}","gists_url":"https://api.github.com/users/jim68000/gists{/gist_id}","starred_url":"https://api.github.com/users/jim68000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jim68000/subscriptions","organizations_url":"https://api.github.com/users/jim68000/orgs","repos_url":"https://api.github.com/users/jim68000/repos","events_url":"https://api.github.com/users/jim68000/events{/privacy}","received_events_url":"https://api.github.com/users/jim68000/received_events","type":"User","site_admin":false},"body":"Issue number: \r\n\r\n### Description of change\r\n\r\nA command that allows us to change investment project stages via the management console. \r\n\r\nAs this is my first attempt at committing something to Leeloo can you all take a _really hard look at what I've done please?_\r\n\r\n### Checklist\r\n\r\n* [x] Have any relevant search models been updated?\r\n* [x] Have any relevant fixtures (`fixtures/test_data.yaml`) been updated?\r\n* [x] Have any relevant select-/prefetch-related field lists in the views and search apps been updated?\r\n* [x] Has the admin site been updated (for new models, fields etc.)?\r\n* [x] Has the README been updated (if needed)?\r\n","created_at":"2018-04-25T12:01:11Z","updated_at":"2018-04-30T14:54:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"edb5aa1d954974a27abfe506c6ed52cf4eff4928","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/931/commits","review_comments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/931/comments","review_comment_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/931/comments","statuses_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/statuses/e7ab341f42243089af74bd163c04e6b23801d7d2","head":{"label":"uktrade:feature/update_stages","ref":"feature/update_stages","sha":"e7ab341f42243089af74bd163c04e6b23801d7d2","user":{"login":"uktrade","id":15107524,"avatar_url":"https://avatars2.githubusercontent.com/u/15107524?v=4","gravatar_id":"","url":"https://api.github.com/users/uktrade","html_url":"https://github.com/uktrade","followers_url":"https://api.github.com/users/uktrade/followers","following_url":"https://api.github.com/users/uktrade/following{/other_user}","gists_url":"https://api.github.com/users/uktrade/gists{/gist_id}","starred_url":"https://api.github.com/users/uktrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uktrade/subscriptions","organizations_url":"https://api.github.com/users/uktrade/orgs","repos_url":"https://api.github.com/users/uktrade/repos","events_url":"https://api.github.com/users/uktrade/events{/privacy}","received_events_url":"https://api.github.com/users/uktrade/received_events","type":"Organization","site_admin":false},"repo":{"id":73379434,"name":"data-hub-leeloo","full_name":"uktrade/data-hub-leeloo","owner":{"login":"uktrade","id":15107524,"avatar_url":"https://avatars2.githubusercontent.com/u/15107524?v=4","gravatar_id":"","url":"https://api.github.com/users/uktrade","html_url":"https://github.com/uktrade","followers_url":"https://api.github.com/users/uktrade/followers","following_url":"https://api.github.com/users/uktrade/following{/other_user}","gists_url":"https://api.github.com/users/uktrade/gists{/gist_id}","starred_url":"https://api.github.com/users/uktrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uktrade/subscriptions","organizations_url":"https://api.github.com/users/uktrade/orgs","repos_url":"https://api.github.com/users/uktrade/repos","events_url":"https://api.github.com/users/uktrade/events{/privacy}","received_events_url":"https://api.github.com/users/uktrade/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uktrade/data-hub-leeloo","description":"Django API for Data Hub frontend","fork":false,"url":"https://api.github.com/repos/uktrade/data-hub-leeloo","forks_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/forks","keys_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/teams","hooks_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/hooks","issue_events_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/events{/number}","events_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/events","assignees_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/assignees{/user}","branches_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/branches{/branch}","tags_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/tags","blobs_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/refs{/sha}","trees_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/statuses/{sha}","languages_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/languages","stargazers_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/stargazers","contributors_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/contributors","subscribers_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/subscribers","subscription_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/subscription","commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/commits{/sha}","git_commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/commits{/sha}","comments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/comments{/number}","issue_comment_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/comments{/number}","contents_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/contents/{+path}","compare_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/merges","archive_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/downloads","issues_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues{/number}","pulls_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls{/number}","milestones_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/milestones{/number}","notifications_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/labels{/name}","releases_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/releases{/id}","deployments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/deployments","created_at":"2016-11-10T12:21:01Z","updated_at":"2018-04-30T11:28:54Z","pushed_at":"2018-04-30T12:39:10Z","git_url":"git://github.com/uktrade/data-hub-leeloo.git","ssh_url":"git@github.com:uktrade/data-hub-leeloo.git","clone_url":"https://github.com/uktrade/data-hub-leeloo.git","svn_url":"https://github.com/uktrade/data-hub-leeloo","homepage":null,"size":4918,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":1,"default_branch":"develop"}},"base":{"label":"uktrade:develop","ref":"develop","sha":"ebb25ff3ed43ef574fc3c7120865878f0d072bf8","user":{"login":"uktrade","id":15107524,"avatar_url":"https://avatars2.githubusercontent.com/u/15107524?v=4","gravatar_id":"","url":"https://api.github.com/users/uktrade","html_url":"https://github.com/uktrade","followers_url":"https://api.github.com/users/uktrade/followers","following_url":"https://api.github.com/users/uktrade/following{/other_user}","gists_url":"https://api.github.com/users/uktrade/gists{/gist_id}","starred_url":"https://api.github.com/users/uktrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uktrade/subscriptions","organizations_url":"https://api.github.com/users/uktrade/orgs","repos_url":"https://api.github.com/users/uktrade/repos","events_url":"https://api.github.com/users/uktrade/events{/privacy}","received_events_url":"https://api.github.com/users/uktrade/received_events","type":"Organization","site_admin":false},"repo":{"id":73379434,"name":"data-hub-leeloo","full_name":"uktrade/data-hub-leeloo","owner":{"login":"uktrade","id":15107524,"avatar_url":"https://avatars2.githubusercontent.com/u/15107524?v=4","gravatar_id":"","url":"https://api.github.com/users/uktrade","html_url":"https://github.com/uktrade","followers_url":"https://api.github.com/users/uktrade/followers","following_url":"https://api.github.com/users/uktrade/following{/other_user}","gists_url":"https://api.github.com/users/uktrade/gists{/gist_id}","starred_url":"https://api.github.com/users/uktrade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uktrade/subscriptions","organizations_url":"https://api.github.com/users/uktrade/orgs","repos_url":"https://api.github.com/users/uktrade/repos","events_url":"https://api.github.com/users/uktrade/events{/privacy}","received_events_url":"https://api.github.com/users/uktrade/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/uktrade/data-hub-leeloo","description":"Django API for Data Hub frontend","fork":false,"url":"https://api.github.com/repos/uktrade/data-hub-leeloo","forks_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/forks","keys_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/teams","hooks_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/hooks","issue_events_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/events{/number}","events_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/events","assignees_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/assignees{/user}","branches_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/branches{/branch}","tags_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/tags","blobs_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/refs{/sha}","trees_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/statuses/{sha}","languages_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/languages","stargazers_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/stargazers","contributors_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/contributors","subscribers_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/subscribers","subscription_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/subscription","commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/commits{/sha}","git_commits_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/git/commits{/sha}","comments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/comments{/number}","issue_comment_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/comments{/number}","contents_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/contents/{+path}","compare_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/merges","archive_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/downloads","issues_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues{/number}","pulls_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls{/number}","milestones_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/milestones{/number}","notifications_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/labels{/name}","releases_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/releases{/id}","deployments_url":"https://api.github.com/repos/uktrade/data-hub-leeloo/deployments","created_at":"2016-11-10T12:21:01Z","updated_at":"2018-04-30T11:28:54Z","pushed_at":"2018-04-30T12:39:10Z","git_url":"git://github.com/uktrade/data-hub-leeloo.git","ssh_url":"git@github.com:uktrade/data-hub-leeloo.git","clone_url":"https://github.com/uktrade/data-hub-leeloo.git","svn_url":"https://github.com/uktrade/data-hub-leeloo","homepage":null,"size":4918,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":5,"license":null,"forks":0,"open_issues":5,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/931"},"html":{"href":"https://github.com/uktrade/data-hub-leeloo/pull/931"},"issue":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/931"},"comments":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/issues/931/comments"},"review_comments":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/931/comments"},"review_comment":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/pulls/931/commits"},"statuses":{"href":"https://api.github.com/repos/uktrade/data-hub-leeloo/statuses/e7ab341f42243089af74bd163c04e6b23801d7d2"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"marcofucci"}}