{"action":"created","comment":{"url":"https://api.github.com/repos/c2corg/v6_api/pulls/comments/58011048","id":58011048,"diff_hunk":"@@ -67,15 +67,18 @@ def validate_json_password(request):\n         request.errors.add('body', 'password', 'Invalid')\n \n \n+def available_user_attribute(attrname, value):\n+    attr = getattr(User, attrname)\n+    return DBSession.query(User).filter(attr == value).count() == 0\n+\n+\n def validate_unique_attribute(attrname, request):\n     \"\"\"Checks if the given attribute is unique.\n     \"\"\"\n \n     if attrname in request.json:\n         value = request.json[attrname]\n-        attr = getattr(User, attrname)\n-        count = DBSession.query(User).filter(attr == value).count()\n-        if count == 0:\n+        if available_user_attribute(attrname, value):","path":"c2corg_api/views/user.py","position":18,"original_position":18,"commit_id":"bb08053959c7bec93c3f1cc40b073dc463e84f2e","original_commit_id":"a50855553ce5336fea072a379ad787c192a0a3c1","user":{"login":"tsauerwein","id":266474,"avatar_url":"https://avatars.githubusercontent.com/u/266474?v=3","gravatar_id":"","url":"https://api.github.com/users/tsauerwein","html_url":"https://github.com/tsauerwein","followers_url":"https://api.github.com/users/tsauerwein/followers","following_url":"https://api.github.com/users/tsauerwein/following{/other_user}","gists_url":"https://api.github.com/users/tsauerwein/gists{/gist_id}","starred_url":"https://api.github.com/users/tsauerwein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsauerwein/subscriptions","organizations_url":"https://api.github.com/users/tsauerwein/orgs","repos_url":"https://api.github.com/users/tsauerwein/repos","events_url":"https://api.github.com/users/tsauerwein/events{/privacy}","received_events_url":"https://api.github.com/users/tsauerwein/received_events","type":"User","site_admin":false},"body":"What about renaming `available_user_attribute` to `is_unique_user_attribute`?\r\n\r\n```python\r\nif is_unique_user_attribute(attrname, value):\r\n```","created_at":"2016-03-31T07:30:55Z","updated_at":"2016-03-31T07:30:55Z","html_url":"https://github.com/c2corg/v6_api/pull/211#discussion_r58011048","pull_request_url":"https://api.github.com/repos/c2corg/v6_api/pulls/211","_links":{"self":{"href":"https://api.github.com/repos/c2corg/v6_api/pulls/comments/58011048"},"html":{"href":"https://github.com/c2corg/v6_api/pull/211#discussion_r58011048"},"pull_request":{"href":"https://api.github.com/repos/c2corg/v6_api/pulls/211"}}},"pull_request":{"url":"https://api.github.com/repos/c2corg/v6_api/pulls/211","id":64622735,"html_url":"https://github.com/c2corg/v6_api/pull/211","diff_url":"https://github.com/c2corg/v6_api/pull/211.diff","patch_url":"https://github.com/c2corg/v6_api/pull/211.patch","issue_url":"https://api.github.com/repos/c2corg/v6_api/issues/211","number":211,"state":"open","locked":false,"title":"Get and update user account","user":{"login":"gberaudo","id":7294662,"avatar_url":"https://avatars.githubusercontent.com/u/7294662?v=3","gravatar_id":"","url":"https://api.github.com/users/gberaudo","html_url":"https://github.com/gberaudo","followers_url":"https://api.github.com/users/gberaudo/followers","following_url":"https://api.github.com/users/gberaudo/following{/other_user}","gists_url":"https://api.github.com/users/gberaudo/gists{/gist_id}","starred_url":"https://api.github.com/users/gberaudo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gberaudo/subscriptions","organizations_url":"https://api.github.com/users/gberaudo/orgs","repos_url":"https://api.github.com/users/gberaudo/repos","events_url":"https://api.github.com/users/gberaudo/events{/privacy}","received_events_url":"https://api.github.com/users/gberaudo/received_events","type":"User","site_admin":false},"body":"While logged in, allow:\r\n- changing password;\r\n- changing toponame and forum username;\r\n- changing email (with validation).","created_at":"2016-03-30T12:58:57Z","updated_at":"2016-03-31T07:30:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1fb6d94ddd504918b3aac4cd6e8d41494bac2ac3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/c2corg/v6_api/pulls/211/commits","review_comments_url":"https://api.github.com/repos/c2corg/v6_api/pulls/211/comments","review_comment_url":"https://api.github.com/repos/c2corg/v6_api/pulls/comments{/number}","comments_url":"https://api.github.com/repos/c2corg/v6_api/issues/211/comments","statuses_url":"https://api.github.com/repos/c2corg/v6_api/statuses/bb08053959c7bec93c3f1cc40b073dc463e84f2e","head":{"label":"c2corg:user_account","ref":"user_account","sha":"bb08053959c7bec93c3f1cc40b073dc463e84f2e","user":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"repo":{"id":41029840,"name":"v6_api","full_name":"c2corg/v6_api","owner":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/c2corg/v6_api","description":"REST API for c2c.org v6","fork":false,"url":"https://api.github.com/repos/c2corg/v6_api","forks_url":"https://api.github.com/repos/c2corg/v6_api/forks","keys_url":"https://api.github.com/repos/c2corg/v6_api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c2corg/v6_api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c2corg/v6_api/teams","hooks_url":"https://api.github.com/repos/c2corg/v6_api/hooks","issue_events_url":"https://api.github.com/repos/c2corg/v6_api/issues/events{/number}","events_url":"https://api.github.com/repos/c2corg/v6_api/events","assignees_url":"https://api.github.com/repos/c2corg/v6_api/assignees{/user}","branches_url":"https://api.github.com/repos/c2corg/v6_api/branches{/branch}","tags_url":"https://api.github.com/repos/c2corg/v6_api/tags","blobs_url":"https://api.github.com/repos/c2corg/v6_api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c2corg/v6_api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c2corg/v6_api/git/refs{/sha}","trees_url":"https://api.github.com/repos/c2corg/v6_api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c2corg/v6_api/statuses/{sha}","languages_url":"https://api.github.com/repos/c2corg/v6_api/languages","stargazers_url":"https://api.github.com/repos/c2corg/v6_api/stargazers","contributors_url":"https://api.github.com/repos/c2corg/v6_api/contributors","subscribers_url":"https://api.github.com/repos/c2corg/v6_api/subscribers","subscription_url":"https://api.github.com/repos/c2corg/v6_api/subscription","commits_url":"https://api.github.com/repos/c2corg/v6_api/commits{/sha}","git_commits_url":"https://api.github.com/repos/c2corg/v6_api/git/commits{/sha}","comments_url":"https://api.github.com/repos/c2corg/v6_api/comments{/number}","issue_comment_url":"https://api.github.com/repos/c2corg/v6_api/issues/comments{/number}","contents_url":"https://api.github.com/repos/c2corg/v6_api/contents/{+path}","compare_url":"https://api.github.com/repos/c2corg/v6_api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c2corg/v6_api/merges","archive_url":"https://api.github.com/repos/c2corg/v6_api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c2corg/v6_api/downloads","issues_url":"https://api.github.com/repos/c2corg/v6_api/issues{/number}","pulls_url":"https://api.github.com/repos/c2corg/v6_api/pulls{/number}","milestones_url":"https://api.github.com/repos/c2corg/v6_api/milestones{/number}","notifications_url":"https://api.github.com/repos/c2corg/v6_api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c2corg/v6_api/labels{/name}","releases_url":"https://api.github.com/repos/c2corg/v6_api/releases{/id}","deployments_url":"https://api.github.com/repos/c2corg/v6_api/deployments","created_at":"2015-08-19T11:21:39Z","updated_at":"2016-01-12T11:27:03Z","pushed_at":"2016-03-30T16:08:44Z","git_url":"git://github.com/c2corg/v6_api.git","ssh_url":"git@github.com:c2corg/v6_api.git","clone_url":"https://github.com/c2corg/v6_api.git","svn_url":"https://github.com/c2corg/v6_api","homepage":"","size":592,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":42,"forks":1,"open_issues":42,"watchers":4,"default_branch":"master"}},"base":{"label":"c2corg:master","ref":"master","sha":"8f05b5db57058669ea73c55741a52c7fefe4faf2","user":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"repo":{"id":41029840,"name":"v6_api","full_name":"c2corg/v6_api","owner":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/c2corg/v6_api","description":"REST API for c2c.org v6","fork":false,"url":"https://api.github.com/repos/c2corg/v6_api","forks_url":"https://api.github.com/repos/c2corg/v6_api/forks","keys_url":"https://api.github.com/repos/c2corg/v6_api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c2corg/v6_api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c2corg/v6_api/teams","hooks_url":"https://api.github.com/repos/c2corg/v6_api/hooks","issue_events_url":"https://api.github.com/repos/c2corg/v6_api/issues/events{/number}","events_url":"https://api.github.com/repos/c2corg/v6_api/events","assignees_url":"https://api.github.com/repos/c2corg/v6_api/assignees{/user}","branches_url":"https://api.github.com/repos/c2corg/v6_api/branches{/branch}","tags_url":"https://api.github.com/repos/c2corg/v6_api/tags","blobs_url":"https://api.github.com/repos/c2corg/v6_api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c2corg/v6_api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c2corg/v6_api/git/refs{/sha}","trees_url":"https://api.github.com/repos/c2corg/v6_api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c2corg/v6_api/statuses/{sha}","languages_url":"https://api.github.com/repos/c2corg/v6_api/languages","stargazers_url":"https://api.github.com/repos/c2corg/v6_api/stargazers","contributors_url":"https://api.github.com/repos/c2corg/v6_api/contributors","subscribers_url":"https://api.github.com/repos/c2corg/v6_api/subscribers","subscription_url":"https://api.github.com/repos/c2corg/v6_api/subscription","commits_url":"https://api.github.com/repos/c2corg/v6_api/commits{/sha}","git_commits_url":"https://api.github.com/repos/c2corg/v6_api/git/commits{/sha}","comments_url":"https://api.github.com/repos/c2corg/v6_api/comments{/number}","issue_comment_url":"https://api.github.com/repos/c2corg/v6_api/issues/comments{/number}","contents_url":"https://api.github.com/repos/c2corg/v6_api/contents/{+path}","compare_url":"https://api.github.com/repos/c2corg/v6_api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c2corg/v6_api/merges","archive_url":"https://api.github.com/repos/c2corg/v6_api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c2corg/v6_api/downloads","issues_url":"https://api.github.com/repos/c2corg/v6_api/issues{/number}","pulls_url":"https://api.github.com/repos/c2corg/v6_api/pulls{/number}","milestones_url":"https://api.github.com/repos/c2corg/v6_api/milestones{/number}","notifications_url":"https://api.github.com/repos/c2corg/v6_api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c2corg/v6_api/labels{/name}","releases_url":"https://api.github.com/repos/c2corg/v6_api/releases{/id}","deployments_url":"https://api.github.com/repos/c2corg/v6_api/deployments","created_at":"2015-08-19T11:21:39Z","updated_at":"2016-01-12T11:27:03Z","pushed_at":"2016-03-30T16:08:44Z","git_url":"git://github.com/c2corg/v6_api.git","ssh_url":"git@github.com:c2corg/v6_api.git","clone_url":"https://github.com/c2corg/v6_api.git","svn_url":"https://github.com/c2corg/v6_api","homepage":"","size":592,"stargazers_count":4,"watchers_count":4,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":42,"forks":1,"open_issues":42,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/c2corg/v6_api/pulls/211"},"html":{"href":"https://github.com/c2corg/v6_api/pull/211"},"issue":{"href":"https://api.github.com/repos/c2corg/v6_api/issues/211"},"comments":{"href":"https://api.github.com/repos/c2corg/v6_api/issues/211/comments"},"review_comments":{"href":"https://api.github.com/repos/c2corg/v6_api/pulls/211/comments"},"review_comment":{"href":"https://api.github.com/repos/c2corg/v6_api/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/c2corg/v6_api/pulls/211/commits"},"statuses":{"href":"https://api.github.com/repos/c2corg/v6_api/statuses/bb08053959c7bec93c3f1cc40b073dc463e84f2e"}}}}