{"action":"created","comment":{"url":"https://api.github.com/repos/indico/indico/pulls/comments/29328526","id":29328526,"diff_hunk":"@@ -396,3 +443,45 @@ def unlink_to(self, obj, role):\n         :param role: the role to use in the link\n         \"\"\"\n         return UserLink.remove_link(self, obj, role)\n+\n+    def synchronize_data(self, refresh=False):\n+        \"\"\"\n+        Synchronize the fields of the user from the sync identity.\n+\n+        This will take only into account ``user.sync_fields``.\n+\n+        :param refresh: bool -- Whether to refresh the synced identity\n+                        with the sync provider before or not. (Only if\n+                        the sync provider support refresh.)\n+        \"\"\"\n+        identity = self._get_synced_identity(refresh=refresh)\n+        if identity is None:\n+            return\n+        for field in self.synced_fields:\n+            old_value = getattr(self, field)\n+            new_value = identity.data.get(field) or ''\n+            if field in ('first_name', 'last_name') and not new_value:\n+                continue\n+            if old_value == new_value:\n+                continue\n+            flash(_(\"Your {field_name} has been synchronised from '{old_value}' to '{new_value}'.\").format(","path":"indico/modules/users/models/users.py","position":93,"original_position":93,"commit_id":"7099db213075d0807ac8edb784a0e79b62509189","original_commit_id":"7099db213075d0807ac8edb784a0e79b62509189","user":{"login":"ThiefMaster","id":179599,"avatar_url":"https://avatars.githubusercontent.com/u/179599?v=3","gravatar_id":"","url":"https://api.github.com/users/ThiefMaster","html_url":"https://github.com/ThiefMaster","followers_url":"https://api.github.com/users/ThiefMaster/followers","following_url":"https://api.github.com/users/ThiefMaster/following{/other_user}","gists_url":"https://api.github.com/users/ThiefMaster/gists{/gist_id}","starred_url":"https://api.github.com/users/ThiefMaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ThiefMaster/subscriptions","organizations_url":"https://api.github.com/users/ThiefMaster/orgs","repos_url":"https://api.github.com/users/ThiefMaster/repos","events_url":"https://api.github.com/users/ThiefMaster/events{/privacy}","received_events_url":"https://api.github.com/users/ThiefMaster/received_events","type":"User","site_admin":false},"body":"then we'd have to move the whole thing out of the model (and e.g. into `util`, which wouldn't be that bad..).\r\n\r\ni think this is one of the cases where it's acceptable to not have things strictly separated...","created_at":"2015-04-29T11:52:34Z","updated_at":"2015-04-29T11:52:34Z","html_url":"https://github.com/indico/indico/pull/1862#discussion_r29328526","pull_request_url":"https://api.github.com/repos/indico/indico/pulls/1862","_links":{"self":{"href":"https://api.github.com/repos/indico/indico/pulls/comments/29328526"},"html":{"href":"https://github.com/indico/indico/pull/1862#discussion_r29328526"},"pull_request":{"href":"https://api.github.com/repos/indico/indico/pulls/1862"}}},"pull_request":{"url":"https://api.github.com/repos/indico/indico/pulls/1862","id":34348605,"html_url":"https://github.com/indico/indico/pull/1862","diff_url":"https://github.com/indico/indico/pull/1862.diff","patch_url":"https://github.com/indico/indico/pull/1862.patch","issue_url":"https://api.github.com/repos/indico/indico/issues/1862","number":1862,"state":"open","locked":false,"title":"sync user data","user":{"login":"jacquesd","id":2848217,"avatar_url":"https://avatars.githubusercontent.com/u/2848217?v=3","gravatar_id":"","url":"https://api.github.com/users/jacquesd","html_url":"https://github.com/jacquesd","followers_url":"https://api.github.com/users/jacquesd/followers","following_url":"https://api.github.com/users/jacquesd/following{/other_user}","gists_url":"https://api.github.com/users/jacquesd/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquesd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquesd/subscriptions","organizations_url":"https://api.github.com/users/jacquesd/orgs","repos_url":"https://api.github.com/users/jacquesd/repos","events_url":"https://api.github.com/users/jacquesd/events{/privacy}","received_events_url":"https://api.github.com/users/jacquesd/received_events","type":"User","site_admin":false},"body":"- define a sync provider in `indico.conf` (by adding a `synced_fields` option with a list of fields to be synchronized).\r\n- synchronizes user data on login\r\n- new `SyncedInputWidget`\r\n- allow user to toggle the synchronization of specific fields in their profile settings\r\n- update migration script to migrate users' synchronized fields","created_at":"2015-04-29T10:09:36Z","updated_at":"2015-04-29T11:52:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a45681d4b38e91f677c37426d9d6eddea000d4fa","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/indico/indico/pulls/1862/commits","review_comments_url":"https://api.github.com/repos/indico/indico/pulls/1862/comments","review_comment_url":"https://api.github.com/repos/indico/indico/pulls/comments{/number}","comments_url":"https://api.github.com/repos/indico/indico/issues/1862/comments","statuses_url":"https://api.github.com/repos/indico/indico/statuses/7099db213075d0807ac8edb784a0e79b62509189","head":{"label":"jacquesd:wip/sync-user-data","ref":"wip/sync-user-data","sha":"7099db213075d0807ac8edb784a0e79b62509189","user":{"login":"jacquesd","id":2848217,"avatar_url":"https://avatars.githubusercontent.com/u/2848217?v=3","gravatar_id":"","url":"https://api.github.com/users/jacquesd","html_url":"https://github.com/jacquesd","followers_url":"https://api.github.com/users/jacquesd/followers","following_url":"https://api.github.com/users/jacquesd/following{/other_user}","gists_url":"https://api.github.com/users/jacquesd/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquesd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquesd/subscriptions","organizations_url":"https://api.github.com/users/jacquesd/orgs","repos_url":"https://api.github.com/users/jacquesd/repos","events_url":"https://api.github.com/users/jacquesd/events{/privacy}","received_events_url":"https://api.github.com/users/jacquesd/received_events","type":"User","site_admin":false},"repo":{"id":23547375,"name":"indico","full_name":"jacquesd/indico","owner":{"login":"jacquesd","id":2848217,"avatar_url":"https://avatars.githubusercontent.com/u/2848217?v=3","gravatar_id":"","url":"https://api.github.com/users/jacquesd","html_url":"https://github.com/jacquesd","followers_url":"https://api.github.com/users/jacquesd/followers","following_url":"https://api.github.com/users/jacquesd/following{/other_user}","gists_url":"https://api.github.com/users/jacquesd/gists{/gist_id}","starred_url":"https://api.github.com/users/jacquesd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacquesd/subscriptions","organizations_url":"https://api.github.com/users/jacquesd/orgs","repos_url":"https://api.github.com/users/jacquesd/repos","events_url":"https://api.github.com/users/jacquesd/events{/privacy}","received_events_url":"https://api.github.com/users/jacquesd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jacquesd/indico","description":"The Indico Project","fork":true,"url":"https://api.github.com/repos/jacquesd/indico","forks_url":"https://api.github.com/repos/jacquesd/indico/forks","keys_url":"https://api.github.com/repos/jacquesd/indico/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jacquesd/indico/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jacquesd/indico/teams","hooks_url":"https://api.github.com/repos/jacquesd/indico/hooks","issue_events_url":"https://api.github.com/repos/jacquesd/indico/issues/events{/number}","events_url":"https://api.github.com/repos/jacquesd/indico/events","assignees_url":"https://api.github.com/repos/jacquesd/indico/assignees{/user}","branches_url":"https://api.github.com/repos/jacquesd/indico/branches{/branch}","tags_url":"https://api.github.com/repos/jacquesd/indico/tags","blobs_url":"https://api.github.com/repos/jacquesd/indico/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jacquesd/indico/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jacquesd/indico/git/refs{/sha}","trees_url":"https://api.github.com/repos/jacquesd/indico/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jacquesd/indico/statuses/{sha}","languages_url":"https://api.github.com/repos/jacquesd/indico/languages","stargazers_url":"https://api.github.com/repos/jacquesd/indico/stargazers","contributors_url":"https://api.github.com/repos/jacquesd/indico/contributors","subscribers_url":"https://api.github.com/repos/jacquesd/indico/subscribers","subscription_url":"https://api.github.com/repos/jacquesd/indico/subscription","commits_url":"https://api.github.com/repos/jacquesd/indico/commits{/sha}","git_commits_url":"https://api.github.com/repos/jacquesd/indico/git/commits{/sha}","comments_url":"https://api.github.com/repos/jacquesd/indico/comments{/number}","issue_comment_url":"https://api.github.com/repos/jacquesd/indico/issues/comments{/number}","contents_url":"https://api.github.com/repos/jacquesd/indico/contents/{+path}","compare_url":"https://api.github.com/repos/jacquesd/indico/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jacquesd/indico/merges","archive_url":"https://api.github.com/repos/jacquesd/indico/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jacquesd/indico/downloads","issues_url":"https://api.github.com/repos/jacquesd/indico/issues{/number}","pulls_url":"https://api.github.com/repos/jacquesd/indico/pulls{/number}","milestones_url":"https://api.github.com/repos/jacquesd/indico/milestones{/number}","notifications_url":"https://api.github.com/repos/jacquesd/indico/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jacquesd/indico/labels{/name}","releases_url":"https://api.github.com/repos/jacquesd/indico/releases{/id}","created_at":"2014-09-01T15:38:51Z","updated_at":"2015-04-23T14:01:06Z","pushed_at":"2015-04-29T10:05:13Z","git_url":"git://github.com/jacquesd/indico.git","ssh_url":"git@github.com:jacquesd/indico.git","clone_url":"https://github.com/jacquesd/indico.git","svn_url":"https://github.com/jacquesd/indico","homepage":"http://indico-software.org","size":179451,"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":"indico:wip/new-groups-users","ref":"wip/new-groups-users","sha":"91c7a0ef009f9ba1029e7372ac1adb9f1fdea0ae","user":{"login":"indico","id":715236,"avatar_url":"https://avatars.githubusercontent.com/u/715236?v=3","gravatar_id":"","url":"https://api.github.com/users/indico","html_url":"https://github.com/indico","followers_url":"https://api.github.com/users/indico/followers","following_url":"https://api.github.com/users/indico/following{/other_user}","gists_url":"https://api.github.com/users/indico/gists{/gist_id}","starred_url":"https://api.github.com/users/indico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indico/subscriptions","organizations_url":"https://api.github.com/users/indico/orgs","repos_url":"https://api.github.com/users/indico/repos","events_url":"https://api.github.com/users/indico/events{/privacy}","received_events_url":"https://api.github.com/users/indico/received_events","type":"Organization","site_admin":false},"repo":{"id":2113067,"name":"indico","full_name":"indico/indico","owner":{"login":"indico","id":715236,"avatar_url":"https://avatars.githubusercontent.com/u/715236?v=3","gravatar_id":"","url":"https://api.github.com/users/indico","html_url":"https://github.com/indico","followers_url":"https://api.github.com/users/indico/followers","following_url":"https://api.github.com/users/indico/following{/other_user}","gists_url":"https://api.github.com/users/indico/gists{/gist_id}","starred_url":"https://api.github.com/users/indico/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/indico/subscriptions","organizations_url":"https://api.github.com/users/indico/orgs","repos_url":"https://api.github.com/users/indico/repos","events_url":"https://api.github.com/users/indico/events{/privacy}","received_events_url":"https://api.github.com/users/indico/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/indico/indico","description":"The Indico Project","fork":false,"url":"https://api.github.com/repos/indico/indico","forks_url":"https://api.github.com/repos/indico/indico/forks","keys_url":"https://api.github.com/repos/indico/indico/keys{/key_id}","collaborators_url":"https://api.github.com/repos/indico/indico/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/indico/indico/teams","hooks_url":"https://api.github.com/repos/indico/indico/hooks","issue_events_url":"https://api.github.com/repos/indico/indico/issues/events{/number}","events_url":"https://api.github.com/repos/indico/indico/events","assignees_url":"https://api.github.com/repos/indico/indico/assignees{/user}","branches_url":"https://api.github.com/repos/indico/indico/branches{/branch}","tags_url":"https://api.github.com/repos/indico/indico/tags","blobs_url":"https://api.github.com/repos/indico/indico/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/indico/indico/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/indico/indico/git/refs{/sha}","trees_url":"https://api.github.com/repos/indico/indico/git/trees{/sha}","statuses_url":"https://api.github.com/repos/indico/indico/statuses/{sha}","languages_url":"https://api.github.com/repos/indico/indico/languages","stargazers_url":"https://api.github.com/repos/indico/indico/stargazers","contributors_url":"https://api.github.com/repos/indico/indico/contributors","subscribers_url":"https://api.github.com/repos/indico/indico/subscribers","subscription_url":"https://api.github.com/repos/indico/indico/subscription","commits_url":"https://api.github.com/repos/indico/indico/commits{/sha}","git_commits_url":"https://api.github.com/repos/indico/indico/git/commits{/sha}","comments_url":"https://api.github.com/repos/indico/indico/comments{/number}","issue_comment_url":"https://api.github.com/repos/indico/indico/issues/comments{/number}","contents_url":"https://api.github.com/repos/indico/indico/contents/{+path}","compare_url":"https://api.github.com/repos/indico/indico/compare/{base}...{head}","merges_url":"https://api.github.com/repos/indico/indico/merges","archive_url":"https://api.github.com/repos/indico/indico/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/indico/indico/downloads","issues_url":"https://api.github.com/repos/indico/indico/issues{/number}","pulls_url":"https://api.github.com/repos/indico/indico/pulls{/number}","milestones_url":"https://api.github.com/repos/indico/indico/milestones{/number}","notifications_url":"https://api.github.com/repos/indico/indico/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/indico/indico/labels{/name}","releases_url":"https://api.github.com/repos/indico/indico/releases{/id}","created_at":"2011-07-27T13:56:30Z","updated_at":"2015-04-29T09:23:16Z","pushed_at":"2015-04-29T11:14:48Z","git_url":"git://github.com/indico/indico.git","ssh_url":"git@github.com:indico/indico.git","clone_url":"https://github.com/indico/indico.git","svn_url":"https://github.com/indico/indico","homepage":"http://indico-software.org","size":199043,"stargazers_count":84,"watchers_count":84,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":49,"mirror_url":null,"open_issues_count":490,"forks":49,"open_issues":490,"watchers":84,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/indico/indico/pulls/1862"},"html":{"href":"https://github.com/indico/indico/pull/1862"},"issue":{"href":"https://api.github.com/repos/indico/indico/issues/1862"},"comments":{"href":"https://api.github.com/repos/indico/indico/issues/1862/comments"},"review_comments":{"href":"https://api.github.com/repos/indico/indico/pulls/1862/comments"},"review_comment":{"href":"https://api.github.com/repos/indico/indico/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/indico/indico/pulls/1862/commits"},"statuses":{"href":"https://api.github.com/repos/indico/indico/statuses/7099db213075d0807ac8edb784a0e79b62509189"}}}}