{"action":"created","comment":{"url":"https://api.github.com/repos/flavour/eden/pulls/comments/35530258","id":35530258,"diff_hunk":"@@ -1213,6 +1239,41 @@ def cap_rheader(r):\n                                        _target=\"_blank\",\n                                        )\n \n+                    auth = current.auth                    \n+                    has_permission = auth.s3_has_permission\n+                    alert_id = r.id\n+                    approved_by = r.record.approved_by\n+                    # Display 'Submit for Approval' based on permission  \n+                    # and deployment settings\n+                    if not approved_by and \\\n+                       has_permission(\"create\", \"cap_alert\") and \\\n+                       has_permission(\"update\", \"cap_alert\", record_id=alert_id) and \\\n+                       current.deployment_settings.get_cap_authorisation():\n+                        # Get the user id for the role alert_approver\n+                        agtable = s3db.auth_group\n+                        group_row = current.db(agtable.role == \"Alert Approver\").\\\n+                                                        select(agtable.id,\n+                                                               limitby=(0, 1)).first()\n+                        if group_row:\n+                            group_id = group_row.id\n+                            \n+                            user_ids = auth.s3_group_members(group_id) # List of user_ids\n+                            pe_ids = [] # List of pe_ids\n+                            for user_id in user_ids:\n+                                pe_ids.append(auth.s3_user_pe_id(int(user_id)))","path":"modules/s3db/cap.py","position":72,"original_position":72,"commit_id":"41e8fd4216e44b68c83a227388b1bbc2c3cac6fd","original_commit_id":"41e8fd4216e44b68c83a227388b1bbc2c3cac6fd","user":{"login":"flavour","id":389592,"avatar_url":"https://avatars.githubusercontent.com/u/389592?v=3","gravatar_id":"","url":"https://api.github.com/users/flavour","html_url":"https://github.com/flavour","followers_url":"https://api.github.com/users/flavour/followers","following_url":"https://api.github.com/users/flavour/following{/other_user}","gists_url":"https://api.github.com/users/flavour/gists{/gist_id}","starred_url":"https://api.github.com/users/flavour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flavour/subscriptions","organizations_url":"https://api.github.com/users/flavour/orgs","repos_url":"https://api.github.com/users/flavour/repos","events_url":"https://api.github.com/users/flavour/events{/privacy}","received_events_url":"https://api.github.com/users/flavour/received_events","type":"User","site_admin":false},"body":"I would rewrite this to avoid the loop of DB queries - more efficient to have a single DB query with a .belongs() in (which we could further optimise by using == if we only have a single approver)","created_at":"2015-07-27T12:32:35Z","updated_at":"2015-07-27T12:32:35Z","html_url":"https://github.com/flavour/eden/pull/1108#discussion_r35530258","pull_request_url":"https://api.github.com/repos/flavour/eden/pulls/1108","_links":{"self":{"href":"https://api.github.com/repos/flavour/eden/pulls/comments/35530258"},"html":{"href":"https://github.com/flavour/eden/pull/1108#discussion_r35530258"},"pull_request":{"href":"https://api.github.com/repos/flavour/eden/pulls/1108"}}},"pull_request":{"url":"https://api.github.com/repos/flavour/eden/pulls/1108","id":40847085,"html_url":"https://github.com/flavour/eden/pull/1108","diff_url":"https://github.com/flavour/eden/pull/1108.diff","patch_url":"https://github.com/flavour/eden/pull/1108.patch","issue_url":"https://api.github.com/repos/flavour/eden/issues/1108","number":1108,"state":"open","locked":false,"title":"submit for approval and approve/reject alert","user":{"login":"biplovbhandari","id":4207677,"avatar_url":"https://avatars.githubusercontent.com/u/4207677?v=3","gravatar_id":"","url":"https://api.github.com/users/biplovbhandari","html_url":"https://github.com/biplovbhandari","followers_url":"https://api.github.com/users/biplovbhandari/followers","following_url":"https://api.github.com/users/biplovbhandari/following{/other_user}","gists_url":"https://api.github.com/users/biplovbhandari/gists{/gist_id}","starred_url":"https://api.github.com/users/biplovbhandari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biplovbhandari/subscriptions","organizations_url":"https://api.github.com/users/biplovbhandari/orgs","repos_url":"https://api.github.com/users/biplovbhandari/repos","events_url":"https://api.github.com/users/biplovbhandari/events{/privacy}","received_events_url":"https://api.github.com/users/biplovbhandari/received_events","type":"User","site_admin":false},"body":"@flavour Please merge this","created_at":"2015-07-26T03:09:59Z","updated_at":"2015-07-27T12:32:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"369360d71d2007a34b0313e2a55ac88ea876bb59","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/flavour/eden/pulls/1108/commits","review_comments_url":"https://api.github.com/repos/flavour/eden/pulls/1108/comments","review_comment_url":"https://api.github.com/repos/flavour/eden/pulls/comments{/number}","comments_url":"https://api.github.com/repos/flavour/eden/issues/1108/comments","statuses_url":"https://api.github.com/repos/flavour/eden/statuses/41e8fd4216e44b68c83a227388b1bbc2c3cac6fd","head":{"label":"biplovbhandari:master","ref":"master","sha":"41e8fd4216e44b68c83a227388b1bbc2c3cac6fd","user":{"login":"biplovbhandari","id":4207677,"avatar_url":"https://avatars.githubusercontent.com/u/4207677?v=3","gravatar_id":"","url":"https://api.github.com/users/biplovbhandari","html_url":"https://github.com/biplovbhandari","followers_url":"https://api.github.com/users/biplovbhandari/followers","following_url":"https://api.github.com/users/biplovbhandari/following{/other_user}","gists_url":"https://api.github.com/users/biplovbhandari/gists{/gist_id}","starred_url":"https://api.github.com/users/biplovbhandari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biplovbhandari/subscriptions","organizations_url":"https://api.github.com/users/biplovbhandari/orgs","repos_url":"https://api.github.com/users/biplovbhandari/repos","events_url":"https://api.github.com/users/biplovbhandari/events{/privacy}","received_events_url":"https://api.github.com/users/biplovbhandari/received_events","type":"User","site_admin":false},"repo":{"id":37774689,"name":"eden","full_name":"biplovbhandari/eden","owner":{"login":"biplovbhandari","id":4207677,"avatar_url":"https://avatars.githubusercontent.com/u/4207677?v=3","gravatar_id":"","url":"https://api.github.com/users/biplovbhandari","html_url":"https://github.com/biplovbhandari","followers_url":"https://api.github.com/users/biplovbhandari/followers","following_url":"https://api.github.com/users/biplovbhandari/following{/other_user}","gists_url":"https://api.github.com/users/biplovbhandari/gists{/gist_id}","starred_url":"https://api.github.com/users/biplovbhandari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/biplovbhandari/subscriptions","organizations_url":"https://api.github.com/users/biplovbhandari/orgs","repos_url":"https://api.github.com/users/biplovbhandari/repos","events_url":"https://api.github.com/users/biplovbhandari/events{/privacy}","received_events_url":"https://api.github.com/users/biplovbhandari/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/biplovbhandari/eden","description":"Sahana Eden is an Open Source Humanitarian Platform which can be used to provide solutions for Disaster Management, Development, and Environmental Management sectors.. Please sign CLA when submitting pull requests: http://bit.ly/SSF-eCLA","fork":true,"url":"https://api.github.com/repos/biplovbhandari/eden","forks_url":"https://api.github.com/repos/biplovbhandari/eden/forks","keys_url":"https://api.github.com/repos/biplovbhandari/eden/keys{/key_id}","collaborators_url":"https://api.github.com/repos/biplovbhandari/eden/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/biplovbhandari/eden/teams","hooks_url":"https://api.github.com/repos/biplovbhandari/eden/hooks","issue_events_url":"https://api.github.com/repos/biplovbhandari/eden/issues/events{/number}","events_url":"https://api.github.com/repos/biplovbhandari/eden/events","assignees_url":"https://api.github.com/repos/biplovbhandari/eden/assignees{/user}","branches_url":"https://api.github.com/repos/biplovbhandari/eden/branches{/branch}","tags_url":"https://api.github.com/repos/biplovbhandari/eden/tags","blobs_url":"https://api.github.com/repos/biplovbhandari/eden/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/biplovbhandari/eden/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/biplovbhandari/eden/git/refs{/sha}","trees_url":"https://api.github.com/repos/biplovbhandari/eden/git/trees{/sha}","statuses_url":"https://api.github.com/repos/biplovbhandari/eden/statuses/{sha}","languages_url":"https://api.github.com/repos/biplovbhandari/eden/languages","stargazers_url":"https://api.github.com/repos/biplovbhandari/eden/stargazers","contributors_url":"https://api.github.com/repos/biplovbhandari/eden/contributors","subscribers_url":"https://api.github.com/repos/biplovbhandari/eden/subscribers","subscription_url":"https://api.github.com/repos/biplovbhandari/eden/subscription","commits_url":"https://api.github.com/repos/biplovbhandari/eden/commits{/sha}","git_commits_url":"https://api.github.com/repos/biplovbhandari/eden/git/commits{/sha}","comments_url":"https://api.github.com/repos/biplovbhandari/eden/comments{/number}","issue_comment_url":"https://api.github.com/repos/biplovbhandari/eden/issues/comments{/number}","contents_url":"https://api.github.com/repos/biplovbhandari/eden/contents/{+path}","compare_url":"https://api.github.com/repos/biplovbhandari/eden/compare/{base}...{head}","merges_url":"https://api.github.com/repos/biplovbhandari/eden/merges","archive_url":"https://api.github.com/repos/biplovbhandari/eden/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/biplovbhandari/eden/downloads","issues_url":"https://api.github.com/repos/biplovbhandari/eden/issues{/number}","pulls_url":"https://api.github.com/repos/biplovbhandari/eden/pulls{/number}","milestones_url":"https://api.github.com/repos/biplovbhandari/eden/milestones{/number}","notifications_url":"https://api.github.com/repos/biplovbhandari/eden/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/biplovbhandari/eden/labels{/name}","releases_url":"https://api.github.com/repos/biplovbhandari/eden/releases{/id}","created_at":"2015-06-20T15:32:51Z","updated_at":"2015-06-20T15:33:04Z","pushed_at":"2015-07-27T11:08:17Z","git_url":"git://github.com/biplovbhandari/eden.git","ssh_url":"git@github.com:biplovbhandari/eden.git","clone_url":"https://github.com/biplovbhandari/eden.git","svn_url":"https://github.com/biplovbhandari/eden","homepage":"http://eden.sahanafoundation.org","size":157100,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"flavour:master","ref":"master","sha":"17e655cd473b11fe18b8c0f25a5729a66b2b5c4c","user":{"login":"flavour","id":389592,"avatar_url":"https://avatars.githubusercontent.com/u/389592?v=3","gravatar_id":"","url":"https://api.github.com/users/flavour","html_url":"https://github.com/flavour","followers_url":"https://api.github.com/users/flavour/followers","following_url":"https://api.github.com/users/flavour/following{/other_user}","gists_url":"https://api.github.com/users/flavour/gists{/gist_id}","starred_url":"https://api.github.com/users/flavour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flavour/subscriptions","organizations_url":"https://api.github.com/users/flavour/orgs","repos_url":"https://api.github.com/users/flavour/repos","events_url":"https://api.github.com/users/flavour/events{/privacy}","received_events_url":"https://api.github.com/users/flavour/received_events","type":"User","site_admin":false},"repo":{"id":3021325,"name":"eden","full_name":"flavour/eden","owner":{"login":"flavour","id":389592,"avatar_url":"https://avatars.githubusercontent.com/u/389592?v=3","gravatar_id":"","url":"https://api.github.com/users/flavour","html_url":"https://github.com/flavour","followers_url":"https://api.github.com/users/flavour/followers","following_url":"https://api.github.com/users/flavour/following{/other_user}","gists_url":"https://api.github.com/users/flavour/gists{/gist_id}","starred_url":"https://api.github.com/users/flavour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flavour/subscriptions","organizations_url":"https://api.github.com/users/flavour/orgs","repos_url":"https://api.github.com/users/flavour/repos","events_url":"https://api.github.com/users/flavour/events{/privacy}","received_events_url":"https://api.github.com/users/flavour/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/flavour/eden","description":"Sahana Eden is an Open Source Humanitarian Platform which can be used to provide solutions for Disaster Management, Development, and Environmental Management sectors.. Please sign CLA when submitting pull requests: http://bit.ly/SSF-eCLA","fork":false,"url":"https://api.github.com/repos/flavour/eden","forks_url":"https://api.github.com/repos/flavour/eden/forks","keys_url":"https://api.github.com/repos/flavour/eden/keys{/key_id}","collaborators_url":"https://api.github.com/repos/flavour/eden/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/flavour/eden/teams","hooks_url":"https://api.github.com/repos/flavour/eden/hooks","issue_events_url":"https://api.github.com/repos/flavour/eden/issues/events{/number}","events_url":"https://api.github.com/repos/flavour/eden/events","assignees_url":"https://api.github.com/repos/flavour/eden/assignees{/user}","branches_url":"https://api.github.com/repos/flavour/eden/branches{/branch}","tags_url":"https://api.github.com/repos/flavour/eden/tags","blobs_url":"https://api.github.com/repos/flavour/eden/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/flavour/eden/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/flavour/eden/git/refs{/sha}","trees_url":"https://api.github.com/repos/flavour/eden/git/trees{/sha}","statuses_url":"https://api.github.com/repos/flavour/eden/statuses/{sha}","languages_url":"https://api.github.com/repos/flavour/eden/languages","stargazers_url":"https://api.github.com/repos/flavour/eden/stargazers","contributors_url":"https://api.github.com/repos/flavour/eden/contributors","subscribers_url":"https://api.github.com/repos/flavour/eden/subscribers","subscription_url":"https://api.github.com/repos/flavour/eden/subscription","commits_url":"https://api.github.com/repos/flavour/eden/commits{/sha}","git_commits_url":"https://api.github.com/repos/flavour/eden/git/commits{/sha}","comments_url":"https://api.github.com/repos/flavour/eden/comments{/number}","issue_comment_url":"https://api.github.com/repos/flavour/eden/issues/comments{/number}","contents_url":"https://api.github.com/repos/flavour/eden/contents/{+path}","compare_url":"https://api.github.com/repos/flavour/eden/compare/{base}...{head}","merges_url":"https://api.github.com/repos/flavour/eden/merges","archive_url":"https://api.github.com/repos/flavour/eden/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/flavour/eden/downloads","issues_url":"https://api.github.com/repos/flavour/eden/issues{/number}","pulls_url":"https://api.github.com/repos/flavour/eden/pulls{/number}","milestones_url":"https://api.github.com/repos/flavour/eden/milestones{/number}","notifications_url":"https://api.github.com/repos/flavour/eden/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/flavour/eden/labels{/name}","releases_url":"https://api.github.com/repos/flavour/eden/releases{/id}","created_at":"2011-12-20T17:49:16Z","updated_at":"2015-07-13T08:08:34Z","pushed_at":"2015-07-27T09:15:49Z","git_url":"git://github.com/flavour/eden.git","ssh_url":"git@github.com:flavour/eden.git","clone_url":"https://github.com/flavour/eden.git","svn_url":"https://github.com/flavour/eden","homepage":"http://eden.sahanafoundation.org","size":198540,"stargazers_count":171,"watchers_count":171,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":423,"mirror_url":null,"open_issues_count":61,"forks":423,"open_issues":61,"watchers":171,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/flavour/eden/pulls/1108"},"html":{"href":"https://github.com/flavour/eden/pull/1108"},"issue":{"href":"https://api.github.com/repos/flavour/eden/issues/1108"},"comments":{"href":"https://api.github.com/repos/flavour/eden/issues/1108/comments"},"review_comments":{"href":"https://api.github.com/repos/flavour/eden/pulls/1108/comments"},"review_comment":{"href":"https://api.github.com/repos/flavour/eden/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/flavour/eden/pulls/1108/commits"},"statuses":{"href":"https://api.github.com/repos/flavour/eden/statuses/41e8fd4216e44b68c83a227388b1bbc2c3cac6fd"}}}}