{"action":"created","comment":{"url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/comments/98420397","pull_request_review_id":19058931,"id":98420397,"diff_hunk":"@@ -19,10 +21,34 @@ class ChangeEmailForm(FlaskForm):\n         Required(), Email()])\n \n \n+class RequiredIf(InputRequired):\n+\n+    def __init__(self, field_name, value, *args, **kwargs):\n+        self.requiring_field_name = field_name\n+        self.requiring_value = value\n+        super(RequiredIf, self).__init__(*args, **kwargs)\n+\n+    def __call__(self, form, field):\n+        requiring_field = form._fields.get(self.requiring_field_name)\n+\n+        if requiring_field:\n+\n+            if requiring_field.data == self.requiring_value:\n+                super(RequiredIf, self).__call__(form, field)\n+\n+            else:\n+                return Optional()(form, field)\n+\n+\n class EmailForm(FlaskForm):\n     email_known = RadioField(choices=yesno)\n     email_address = EmailField('Email', validators=[","path":"app/main/forms.py","position":44,"original_position":44,"commit_id":"d388fdd57ecbf37cfbc89ee5283f607cc101592e","original_commit_id":"d388fdd57ecbf37cfbc89ee5283f607cc101592e","user":{"login":"andyhd","id":35194,"avatar_url":"https://avatars.githubusercontent.com/u/35194?v=3","gravatar_id":"","url":"https://api.github.com/users/andyhd","html_url":"https://github.com/andyhd","followers_url":"https://api.github.com/users/andyhd/followers","following_url":"https://api.github.com/users/andyhd/following{/other_user}","gists_url":"https://api.github.com/users/andyhd/gists{/gist_id}","starred_url":"https://api.github.com/users/andyhd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyhd/subscriptions","organizations_url":"https://api.github.com/users/andyhd/orgs","repos_url":"https://api.github.com/users/andyhd/repos","events_url":"https://api.github.com/users/andyhd/events{/privacy}","received_events_url":"https://api.github.com/users/andyhd/received_events","type":"User","site_admin":false},"body":"I'm not sure that improves readability much. There's a balance between having words next to each other so they read like a sentence, and splitting overly long lines. When reading, the `validators` keyword argument is almost redundant, because the `RequiredIf` constructor call is IMO pretty self-documenting. Unfortunately the `Email` validator class name is not self-documenting at all, so I agree that moving `validators` onto a new line would make it clearer.","created_at":"2017-01-30T11:15:11Z","updated_at":"2017-01-30T11:15:11Z","html_url":"https://github.com/crossgovernmentservices/ags_gateway/pull/38#discussion_r98420397","pull_request_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/38","_links":{"self":{"href":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/comments/98420397"},"html":{"href":"https://github.com/crossgovernmentservices/ags_gateway/pull/38#discussion_r98420397"},"pull_request":{"href":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/38"}}},"pull_request":{"url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/38","id":103509466,"html_url":"https://github.com/crossgovernmentservices/ags_gateway/pull/38","diff_url":"https://github.com/crossgovernmentservices/ags_gateway/pull/38.diff","patch_url":"https://github.com/crossgovernmentservices/ags_gateway/pull/38.patch","issue_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues/38","number":38,"state":"open","locked":false,"title":"Show an error message if no email address is provided","user":{"login":"andyhd","id":35194,"avatar_url":"https://avatars.githubusercontent.com/u/35194?v=3","gravatar_id":"","url":"https://api.github.com/users/andyhd","html_url":"https://github.com/andyhd","followers_url":"https://api.github.com/users/andyhd/followers","following_url":"https://api.github.com/users/andyhd/following{/other_user}","gists_url":"https://api.github.com/users/andyhd/gists{/gist_id}","starred_url":"https://api.github.com/users/andyhd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyhd/subscriptions","organizations_url":"https://api.github.com/users/andyhd/orgs","repos_url":"https://api.github.com/users/andyhd/repos","events_url":"https://api.github.com/users/andyhd/events{/privacy}","received_events_url":"https://api.github.com/users/andyhd/received_events","type":"User","site_admin":false},"body":"## What\r\n\r\n* Added `RequiredIf` form validator, to show an error if the user indicates that they know their email address, but do not provide it. The email address is not required if the user indicates that they do not know it.\r\n* Added test for scenario where user does not supply an email address\r\n\r\n## How to review\r\n\r\n1. Browse to https://ags-gateway-error-missing-email.cloudapps.digital/confirm-email-address (or https://ags-gateway.cloudapps.digital/confirm-email-address if this PR is merged)\r\n2. Click on \"Yes\"\r\n3. Click on \"Continue\" button without entering an email address\r\n4. See error message \"You must enter a valid email address\" next to the form field\r\n5. Click on \"No\"\r\n6. Click on \"Continue\" button\r\n7. Be taken to the \"Which department do you work for?\" page","created_at":"2017-01-27T15:17:18Z","updated_at":"2017-01-30T11:15:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3291e2ea7e9fe18d51d2fce9940c316d3a1619ab","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/38/commits","review_comments_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/38/comments","review_comment_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues/38/comments","statuses_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/statuses/d388fdd57ecbf37cfbc89ee5283f607cc101592e","head":{"label":"crossgovernmentservices:error-missing-email","ref":"error-missing-email","sha":"d388fdd57ecbf37cfbc89ee5283f607cc101592e","user":{"login":"crossgovernmentservices","id":12066742,"avatar_url":"https://avatars.githubusercontent.com/u/12066742?v=3","gravatar_id":"","url":"https://api.github.com/users/crossgovernmentservices","html_url":"https://github.com/crossgovernmentservices","followers_url":"https://api.github.com/users/crossgovernmentservices/followers","following_url":"https://api.github.com/users/crossgovernmentservices/following{/other_user}","gists_url":"https://api.github.com/users/crossgovernmentservices/gists{/gist_id}","starred_url":"https://api.github.com/users/crossgovernmentservices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crossgovernmentservices/subscriptions","organizations_url":"https://api.github.com/users/crossgovernmentservices/orgs","repos_url":"https://api.github.com/users/crossgovernmentservices/repos","events_url":"https://api.github.com/users/crossgovernmentservices/events{/privacy}","received_events_url":"https://api.github.com/users/crossgovernmentservices/received_events","type":"Organization","site_admin":false},"repo":{"id":73824760,"name":"ags_gateway","full_name":"crossgovernmentservices/ags_gateway","owner":{"login":"crossgovernmentservices","id":12066742,"avatar_url":"https://avatars.githubusercontent.com/u/12066742?v=3","gravatar_id":"","url":"https://api.github.com/users/crossgovernmentservices","html_url":"https://github.com/crossgovernmentservices","followers_url":"https://api.github.com/users/crossgovernmentservices/followers","following_url":"https://api.github.com/users/crossgovernmentservices/following{/other_user}","gists_url":"https://api.github.com/users/crossgovernmentservices/gists{/gist_id}","starred_url":"https://api.github.com/users/crossgovernmentservices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crossgovernmentservices/subscriptions","organizations_url":"https://api.github.com/users/crossgovernmentservices/orgs","repos_url":"https://api.github.com/users/crossgovernmentservices/repos","events_url":"https://api.github.com/users/crossgovernmentservices/events{/privacy}","received_events_url":"https://api.github.com/users/crossgovernmentservices/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crossgovernmentservices/ags_gateway","description":"AGS Gateway OIDC broker user interface web service","fork":false,"url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway","forks_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/forks","keys_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/teams","hooks_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/hooks","issue_events_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues/events{/number}","events_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/events","assignees_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/assignees{/user}","branches_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/branches{/branch}","tags_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/tags","blobs_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/languages","stargazers_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/stargazers","contributors_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/contributors","subscribers_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/subscribers","subscription_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/subscription","commits_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/contents/{+path}","compare_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/merges","archive_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/downloads","issues_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues{/number}","pulls_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/labels{/name}","releases_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/releases{/id}","deployments_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/deployments","created_at":"2016-11-15T15:04:26Z","updated_at":"2016-11-15T15:05:20Z","pushed_at":"2017-01-30T11:13:26Z","git_url":"git://github.com/crossgovernmentservices/ags_gateway.git","ssh_url":"git@github.com:crossgovernmentservices/ags_gateway.git","clone_url":"https://github.com/crossgovernmentservices/ags_gateway.git","svn_url":"https://github.com/crossgovernmentservices/ags_gateway","homepage":null,"size":1418,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"crossgovernmentservices:master","ref":"master","sha":"1ac8bda76384a012e5ba6d346ba6bde4c8247a8d","user":{"login":"crossgovernmentservices","id":12066742,"avatar_url":"https://avatars.githubusercontent.com/u/12066742?v=3","gravatar_id":"","url":"https://api.github.com/users/crossgovernmentservices","html_url":"https://github.com/crossgovernmentservices","followers_url":"https://api.github.com/users/crossgovernmentservices/followers","following_url":"https://api.github.com/users/crossgovernmentservices/following{/other_user}","gists_url":"https://api.github.com/users/crossgovernmentservices/gists{/gist_id}","starred_url":"https://api.github.com/users/crossgovernmentservices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crossgovernmentservices/subscriptions","organizations_url":"https://api.github.com/users/crossgovernmentservices/orgs","repos_url":"https://api.github.com/users/crossgovernmentservices/repos","events_url":"https://api.github.com/users/crossgovernmentservices/events{/privacy}","received_events_url":"https://api.github.com/users/crossgovernmentservices/received_events","type":"Organization","site_admin":false},"repo":{"id":73824760,"name":"ags_gateway","full_name":"crossgovernmentservices/ags_gateway","owner":{"login":"crossgovernmentservices","id":12066742,"avatar_url":"https://avatars.githubusercontent.com/u/12066742?v=3","gravatar_id":"","url":"https://api.github.com/users/crossgovernmentservices","html_url":"https://github.com/crossgovernmentservices","followers_url":"https://api.github.com/users/crossgovernmentservices/followers","following_url":"https://api.github.com/users/crossgovernmentservices/following{/other_user}","gists_url":"https://api.github.com/users/crossgovernmentservices/gists{/gist_id}","starred_url":"https://api.github.com/users/crossgovernmentservices/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crossgovernmentservices/subscriptions","organizations_url":"https://api.github.com/users/crossgovernmentservices/orgs","repos_url":"https://api.github.com/users/crossgovernmentservices/repos","events_url":"https://api.github.com/users/crossgovernmentservices/events{/privacy}","received_events_url":"https://api.github.com/users/crossgovernmentservices/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crossgovernmentservices/ags_gateway","description":"AGS Gateway OIDC broker user interface web service","fork":false,"url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway","forks_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/forks","keys_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/teams","hooks_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/hooks","issue_events_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues/events{/number}","events_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/events","assignees_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/assignees{/user}","branches_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/branches{/branch}","tags_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/tags","blobs_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/refs{/sha}","trees_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/statuses/{sha}","languages_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/languages","stargazers_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/stargazers","contributors_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/contributors","subscribers_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/subscribers","subscription_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/subscription","commits_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/commits{/sha}","git_commits_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/git/commits{/sha}","comments_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/comments{/number}","issue_comment_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues/comments{/number}","contents_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/contents/{+path}","compare_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/merges","archive_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/downloads","issues_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues{/number}","pulls_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls{/number}","milestones_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/milestones{/number}","notifications_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/labels{/name}","releases_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/releases{/id}","deployments_url":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/deployments","created_at":"2016-11-15T15:04:26Z","updated_at":"2016-11-15T15:05:20Z","pushed_at":"2017-01-30T11:13:26Z","git_url":"git://github.com/crossgovernmentservices/ags_gateway.git","ssh_url":"git@github.com:crossgovernmentservices/ags_gateway.git","clone_url":"https://github.com/crossgovernmentservices/ags_gateway.git","svn_url":"https://github.com/crossgovernmentservices/ags_gateway","homepage":null,"size":1418,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/38"},"html":{"href":"https://github.com/crossgovernmentservices/ags_gateway/pull/38"},"issue":{"href":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues/38"},"comments":{"href":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/issues/38/comments"},"review_comments":{"href":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/38/comments"},"review_comment":{"href":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/pulls/38/commits"},"statuses":{"href":"https://api.github.com/repos/crossgovernmentservices/ags_gateway/statuses/d388fdd57ecbf37cfbc89ee5283f607cc101592e"}}}}
{"actor":{"display_login":"andyhd"}}