{"action":"created","comment":{"url":"https://api.github.com/repos/toladata/TolaActivity/pulls/comments/156040416","pull_request_review_id":82452487,"id":156040416,"diff_hunk":"@@ -0,0 +1,37 @@\n+import logging\n+import os\n+\n+from django.contrib.auth.models import Group\n+from django.db.models import signals\n+from django.dispatch import receiver\n+\n+from tola import DEMO_BRANCH\n+from tola.management.commands.loadinitialdata import (\n+    DEFAULT_WORKFLOWLEVEL1_ID, DEFAULT_WORKFLOWLEVEL1_NAME)\n+from workflow.models import (TolaUser, WorkflowLevel1, WorkflowTeam,\n+                             ROLE_VIEW_ONLY)\n+\n+logger = logging.getLogger(__name__)\n+\n+\n+@receiver(signals.post_save, sender=TolaUser)\n+def add_users_to_default_wflvl1(sender, instance, **kwargs):\n+    \"\"\"\n+    Demo-only feature: add new users to certain program as ViewOnly.\n+    \"\"\"\n+    if os.getenv('APP_BRANCH') != DEMO_BRANCH:\n+        return\n+\n+    try:\n+        wflvl1 = WorkflowLevel1.objects.get(id=DEFAULT_WORKFLOWLEVEL1_ID,\n+                                            name=DEFAULT_WORKFLOWLEVEL1_NAME)\n+    except WorkflowLevel1.DoesNotExist:\n+        logger.warning(\n+            'Working on branch %s but the default program \"#%d: %s\" does not '\n+            'exist. Maybe initial data was not loaded with loadinitialdata?',\n+        )\n+        return\n+    else:\n+        role = Group.objects.get(name=ROLE_VIEW_ONLY)\n+        WorkflowTeam.objects.create(workflow_user=instance, role=role,\n+                                    workflowlevel1=wflvl1)","path":"workflow/signals.py","position":37,"original_position":37,"commit_id":"71ef7b24dae3ef2fe72f38c772c2fe26d088f884","original_commit_id":"71ef7b24dae3ef2fe72f38c772c2fe26d088f884","user":{"login":"jefmoura","id":4620451,"avatar_url":"https://avatars0.githubusercontent.com/u/4620451?v=4","gravatar_id":"","url":"https://api.github.com/users/jefmoura","html_url":"https://github.com/jefmoura","followers_url":"https://api.github.com/users/jefmoura/followers","following_url":"https://api.github.com/users/jefmoura/following{/other_user}","gists_url":"https://api.github.com/users/jefmoura/gists{/gist_id}","starred_url":"https://api.github.com/users/jefmoura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jefmoura/subscriptions","organizations_url":"https://api.github.com/users/jefmoura/orgs","repos_url":"https://api.github.com/users/jefmoura/repos","events_url":"https://api.github.com/users/jefmoura/events{/privacy}","received_events_url":"https://api.github.com/users/jefmoura/received_events","type":"User","site_admin":false},"body":"You're using the `else`, so you don't need the `return` in the `except` clause.","created_at":"2017-12-11T10:58:45Z","updated_at":"2017-12-11T11:01:20Z","html_url":"https://github.com/toladata/TolaActivity/pull/887#discussion_r156040416","pull_request_url":"https://api.github.com/repos/toladata/TolaActivity/pulls/887","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/toladata/TolaActivity/pulls/comments/156040416"},"html":{"href":"https://github.com/toladata/TolaActivity/pull/887#discussion_r156040416"},"pull_request":{"href":"https://api.github.com/repos/toladata/TolaActivity/pulls/887"}}},"pull_request":{"url":"https://api.github.com/repos/toladata/TolaActivity/pulls/887","id":157502619,"html_url":"https://github.com/toladata/TolaActivity/pull/887","diff_url":"https://github.com/toladata/TolaActivity/pull/887.diff","patch_url":"https://github.com/toladata/TolaActivity/pull/887.patch","issue_url":"https://api.github.com/repos/toladata/TolaActivity/issues/887","number":887,"state":"open","locked":false,"title":"Assign demo users to default Program #641","user":{"login":"Menda","id":23944,"avatar_url":"https://avatars2.githubusercontent.com/u/23944?v=4","gravatar_id":"","url":"https://api.github.com/users/Menda","html_url":"https://github.com/Menda","followers_url":"https://api.github.com/users/Menda/followers","following_url":"https://api.github.com/users/Menda/following{/other_user}","gists_url":"https://api.github.com/users/Menda/gists{/gist_id}","starred_url":"https://api.github.com/users/Menda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Menda/subscriptions","organizations_url":"https://api.github.com/users/Menda/orgs","repos_url":"https://api.github.com/users/Menda/repos","events_url":"https://api.github.com/users/Menda/events{/privacy}","received_events_url":"https://api.github.com/users/Menda/received_events","type":"User","site_admin":false},"body":"Purpose\r\n=======\r\n\r\nAll Demo Users should have Workflow Teams access to the default WFL1:\r\n\"Humanitarian Response to the Syrian Crisis\".\r\n\r\nTicket\r\n=====\r\n\r\nhttps://github.com/toladata/TolaDataV2/issues/641","created_at":"2017-12-11T08:28:08Z","updated_at":"2017-12-11T11:01:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7594280b1bfaf2c369e07ba7c6f685360a460659","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/toladata/TolaActivity/pulls/887/commits","review_comments_url":"https://api.github.com/repos/toladata/TolaActivity/pulls/887/comments","review_comment_url":"https://api.github.com/repos/toladata/TolaActivity/pulls/comments{/number}","comments_url":"https://api.github.com/repos/toladata/TolaActivity/issues/887/comments","statuses_url":"https://api.github.com/repos/toladata/TolaActivity/statuses/71ef7b24dae3ef2fe72f38c772c2fe26d088f884","head":{"label":"Menda:641-demo-site-default-program","ref":"641-demo-site-default-program","sha":"71ef7b24dae3ef2fe72f38c772c2fe26d088f884","user":{"login":"Menda","id":23944,"avatar_url":"https://avatars2.githubusercontent.com/u/23944?v=4","gravatar_id":"","url":"https://api.github.com/users/Menda","html_url":"https://github.com/Menda","followers_url":"https://api.github.com/users/Menda/followers","following_url":"https://api.github.com/users/Menda/following{/other_user}","gists_url":"https://api.github.com/users/Menda/gists{/gist_id}","starred_url":"https://api.github.com/users/Menda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Menda/subscriptions","organizations_url":"https://api.github.com/users/Menda/orgs","repos_url":"https://api.github.com/users/Menda/repos","events_url":"https://api.github.com/users/Menda/events{/privacy}","received_events_url":"https://api.github.com/users/Menda/received_events","type":"User","site_admin":false},"repo":{"id":105265969,"name":"TolaActivity","full_name":"Menda/TolaActivity","owner":{"login":"Menda","id":23944,"avatar_url":"https://avatars2.githubusercontent.com/u/23944?v=4","gravatar_id":"","url":"https://api.github.com/users/Menda","html_url":"https://github.com/Menda","followers_url":"https://api.github.com/users/Menda/followers","following_url":"https://api.github.com/users/Menda/following{/other_user}","gists_url":"https://api.github.com/users/Menda/gists{/gist_id}","starred_url":"https://api.github.com/users/Menda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Menda/subscriptions","organizations_url":"https://api.github.com/users/Menda/orgs","repos_url":"https://api.github.com/users/Menda/repos","events_url":"https://api.github.com/users/Menda/events{/privacy}","received_events_url":"https://api.github.com/users/Menda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Menda/TolaActivity","description":"Workflow, visualizations and data services for managing NGO projects and programs","fork":true,"url":"https://api.github.com/repos/Menda/TolaActivity","forks_url":"https://api.github.com/repos/Menda/TolaActivity/forks","keys_url":"https://api.github.com/repos/Menda/TolaActivity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Menda/TolaActivity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Menda/TolaActivity/teams","hooks_url":"https://api.github.com/repos/Menda/TolaActivity/hooks","issue_events_url":"https://api.github.com/repos/Menda/TolaActivity/issues/events{/number}","events_url":"https://api.github.com/repos/Menda/TolaActivity/events","assignees_url":"https://api.github.com/repos/Menda/TolaActivity/assignees{/user}","branches_url":"https://api.github.com/repos/Menda/TolaActivity/branches{/branch}","tags_url":"https://api.github.com/repos/Menda/TolaActivity/tags","blobs_url":"https://api.github.com/repos/Menda/TolaActivity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Menda/TolaActivity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Menda/TolaActivity/git/refs{/sha}","trees_url":"https://api.github.com/repos/Menda/TolaActivity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Menda/TolaActivity/statuses/{sha}","languages_url":"https://api.github.com/repos/Menda/TolaActivity/languages","stargazers_url":"https://api.github.com/repos/Menda/TolaActivity/stargazers","contributors_url":"https://api.github.com/repos/Menda/TolaActivity/contributors","subscribers_url":"https://api.github.com/repos/Menda/TolaActivity/subscribers","subscription_url":"https://api.github.com/repos/Menda/TolaActivity/subscription","commits_url":"https://api.github.com/repos/Menda/TolaActivity/commits{/sha}","git_commits_url":"https://api.github.com/repos/Menda/TolaActivity/git/commits{/sha}","comments_url":"https://api.github.com/repos/Menda/TolaActivity/comments{/number}","issue_comment_url":"https://api.github.com/repos/Menda/TolaActivity/issues/comments{/number}","contents_url":"https://api.github.com/repos/Menda/TolaActivity/contents/{+path}","compare_url":"https://api.github.com/repos/Menda/TolaActivity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Menda/TolaActivity/merges","archive_url":"https://api.github.com/repos/Menda/TolaActivity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Menda/TolaActivity/downloads","issues_url":"https://api.github.com/repos/Menda/TolaActivity/issues{/number}","pulls_url":"https://api.github.com/repos/Menda/TolaActivity/pulls{/number}","milestones_url":"https://api.github.com/repos/Menda/TolaActivity/milestones{/number}","notifications_url":"https://api.github.com/repos/Menda/TolaActivity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Menda/TolaActivity/labels{/name}","releases_url":"https://api.github.com/repos/Menda/TolaActivity/releases{/id}","deployments_url":"https://api.github.com/repos/Menda/TolaActivity/deployments","created_at":"2017-09-29T11:41:41Z","updated_at":"2017-09-29T11:41:46Z","pushed_at":"2017-12-11T10:39:52Z","git_url":"git://github.com/Menda/TolaActivity.git","ssh_url":"git@github.com:Menda/TolaActivity.git","clone_url":"https://github.com/Menda/TolaActivity.git","svn_url":"https://github.com/Menda/TolaActivity","homepage":null,"size":85249,"stargazers_count":0,"watchers_count":0,"language":"HTML","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":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"toladata:dev-v2","ref":"dev-v2","sha":"91e5d2540702359cfbe89a87d31a082cd11618a2","user":{"login":"toladata","id":385634,"avatar_url":"https://avatars0.githubusercontent.com/u/385634?v=4","gravatar_id":"","url":"https://api.github.com/users/toladata","html_url":"https://github.com/toladata","followers_url":"https://api.github.com/users/toladata/followers","following_url":"https://api.github.com/users/toladata/following{/other_user}","gists_url":"https://api.github.com/users/toladata/gists{/gist_id}","starred_url":"https://api.github.com/users/toladata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toladata/subscriptions","organizations_url":"https://api.github.com/users/toladata/orgs","repos_url":"https://api.github.com/users/toladata/repos","events_url":"https://api.github.com/users/toladata/events{/privacy}","received_events_url":"https://api.github.com/users/toladata/received_events","type":"Organization","site_admin":false},"repo":{"id":43021528,"name":"TolaActivity","full_name":"toladata/TolaActivity","owner":{"login":"toladata","id":385634,"avatar_url":"https://avatars0.githubusercontent.com/u/385634?v=4","gravatar_id":"","url":"https://api.github.com/users/toladata","html_url":"https://github.com/toladata","followers_url":"https://api.github.com/users/toladata/followers","following_url":"https://api.github.com/users/toladata/following{/other_user}","gists_url":"https://api.github.com/users/toladata/gists{/gist_id}","starred_url":"https://api.github.com/users/toladata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toladata/subscriptions","organizations_url":"https://api.github.com/users/toladata/orgs","repos_url":"https://api.github.com/users/toladata/repos","events_url":"https://api.github.com/users/toladata/events{/privacy}","received_events_url":"https://api.github.com/users/toladata/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/toladata/TolaActivity","description":"Workflow, visualizations and data services for managing NGO projects and programs","fork":false,"url":"https://api.github.com/repos/toladata/TolaActivity","forks_url":"https://api.github.com/repos/toladata/TolaActivity/forks","keys_url":"https://api.github.com/repos/toladata/TolaActivity/keys{/key_id}","collaborators_url":"https://api.github.com/repos/toladata/TolaActivity/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/toladata/TolaActivity/teams","hooks_url":"https://api.github.com/repos/toladata/TolaActivity/hooks","issue_events_url":"https://api.github.com/repos/toladata/TolaActivity/issues/events{/number}","events_url":"https://api.github.com/repos/toladata/TolaActivity/events","assignees_url":"https://api.github.com/repos/toladata/TolaActivity/assignees{/user}","branches_url":"https://api.github.com/repos/toladata/TolaActivity/branches{/branch}","tags_url":"https://api.github.com/repos/toladata/TolaActivity/tags","blobs_url":"https://api.github.com/repos/toladata/TolaActivity/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/toladata/TolaActivity/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/toladata/TolaActivity/git/refs{/sha}","trees_url":"https://api.github.com/repos/toladata/TolaActivity/git/trees{/sha}","statuses_url":"https://api.github.com/repos/toladata/TolaActivity/statuses/{sha}","languages_url":"https://api.github.com/repos/toladata/TolaActivity/languages","stargazers_url":"https://api.github.com/repos/toladata/TolaActivity/stargazers","contributors_url":"https://api.github.com/repos/toladata/TolaActivity/contributors","subscribers_url":"https://api.github.com/repos/toladata/TolaActivity/subscribers","subscription_url":"https://api.github.com/repos/toladata/TolaActivity/subscription","commits_url":"https://api.github.com/repos/toladata/TolaActivity/commits{/sha}","git_commits_url":"https://api.github.com/repos/toladata/TolaActivity/git/commits{/sha}","comments_url":"https://api.github.com/repos/toladata/TolaActivity/comments{/number}","issue_comment_url":"https://api.github.com/repos/toladata/TolaActivity/issues/comments{/number}","contents_url":"https://api.github.com/repos/toladata/TolaActivity/contents/{+path}","compare_url":"https://api.github.com/repos/toladata/TolaActivity/compare/{base}...{head}","merges_url":"https://api.github.com/repos/toladata/TolaActivity/merges","archive_url":"https://api.github.com/repos/toladata/TolaActivity/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/toladata/TolaActivity/downloads","issues_url":"https://api.github.com/repos/toladata/TolaActivity/issues{/number}","pulls_url":"https://api.github.com/repos/toladata/TolaActivity/pulls{/number}","milestones_url":"https://api.github.com/repos/toladata/TolaActivity/milestones{/number}","notifications_url":"https://api.github.com/repos/toladata/TolaActivity/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/toladata/TolaActivity/labels{/name}","releases_url":"https://api.github.com/repos/toladata/TolaActivity/releases{/id}","deployments_url":"https://api.github.com/repos/toladata/TolaActivity/deployments","created_at":"2015-09-23T19:14:59Z","updated_at":"2017-12-01T10:01:32Z","pushed_at":"2017-12-11T10:46:10Z","git_url":"git://github.com/toladata/TolaActivity.git","ssh_url":"git@github.com:toladata/TolaActivity.git","clone_url":"https://github.com/toladata/TolaActivity.git","svn_url":"https://github.com/toladata/TolaActivity","homepage":null,"size":85267,"stargazers_count":5,"watchers_count":5,"language":"HTML","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":13,"mirror_url":null,"archived":false,"open_issues_count":51,"license":null,"forks":13,"open_issues":51,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/toladata/TolaActivity/pulls/887"},"html":{"href":"https://github.com/toladata/TolaActivity/pull/887"},"issue":{"href":"https://api.github.com/repos/toladata/TolaActivity/issues/887"},"comments":{"href":"https://api.github.com/repos/toladata/TolaActivity/issues/887/comments"},"review_comments":{"href":"https://api.github.com/repos/toladata/TolaActivity/pulls/887/comments"},"review_comment":{"href":"https://api.github.com/repos/toladata/TolaActivity/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/toladata/TolaActivity/pulls/887/commits"},"statuses":{"href":"https://api.github.com/repos/toladata/TolaActivity/statuses/71ef7b24dae3ef2fe72f38c772c2fe26d088f884"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jefmoura"}}