{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/pontoon/pulls/comments/42676012","id":42676012,"diff_hunk":"@@ -0,0 +1,47 @@\n+# -*- coding: utf-8 -*-\n+from __future__ import unicode_literals\n+\n+from django.conf import settings\n+from django.db import models, migrations\n+\n+\n+def create_translators(apps, schema_editor):\n+    \"\"\"\n+    Bug 952488 - We're assigning translation permissions to active contributors.\n+    \"\"\"   \n+    User = apps.get_model('auth', 'User')\n+\n+    # We're using through migration because it's easier to map\n+    # user/group primary keys without requiring to query full objects.\n+    UserGroup = User.groups.through\n+\n+    contributors_locale = (\n+        User.objects.filter(translation__approved=True)\n+            .values('pk', 'translation__locale')\n+            .annotate(approved_translations=models.Count('translation__locale', distinct=True))\n+            .filter(approved_translations=1)\n+    )\n+\n+    for contributor in contributors_locale:\n+        UserGroup.objects.create(user_id=contributor['pk'],\n+            group_id=contributor['translation__locale'].group.pk)","path":"pontoon/base/migrations/0040_locale_translators.py","position":27,"original_position":27,"commit_id":"5c939b30a862fbbf9c303f73b4f09a575162a4df","original_commit_id":"5c939b30a862fbbf9c303f73b4f09a575162a4df","user":{"login":"Osmose","id":193106,"avatar_url":"https://avatars.githubusercontent.com/u/193106?v=3","gravatar_id":"","url":"https://api.github.com/users/Osmose","html_url":"https://github.com/Osmose","followers_url":"https://api.github.com/users/Osmose/followers","following_url":"https://api.github.com/users/Osmose/following{/other_user}","gists_url":"https://api.github.com/users/Osmose/gists{/gist_id}","starred_url":"https://api.github.com/users/Osmose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Osmose/subscriptions","organizations_url":"https://api.github.com/users/Osmose/orgs","repos_url":"https://api.github.com/users/Osmose/repos","events_url":"https://api.github.com/users/Osmose/events{/privacy}","received_events_url":"https://api.github.com/users/Osmose/received_events","type":"User","site_admin":false},"body":"Does this really work? The `values` call should have `['translation__locale']` as an integer with the pk on the locale rather than the locale instance itself.","created_at":"2015-10-21T20:15:45Z","updated_at":"2015-10-21T20:15:45Z","html_url":"https://github.com/mozilla/pontoon/pull/219#discussion_r42676012","pull_request_url":"https://api.github.com/repos/mozilla/pontoon/pulls/219","_links":{"self":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/comments/42676012"},"html":{"href":"https://github.com/mozilla/pontoon/pull/219#discussion_r42676012"},"pull_request":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/219"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/pontoon/pulls/219","id":48148751,"html_url":"https://github.com/mozilla/pontoon/pull/219","diff_url":"https://github.com/mozilla/pontoon/pull/219.diff","patch_url":"https://github.com/mozilla/pontoon/pull/219.patch","issue_url":"https://api.github.com/repos/mozilla/pontoon/issues/219","number":219,"state":"open","locked":false,"title":"Fix bug 952488 - Added locale managers","user":{"login":"jotes","id":8784972,"avatar_url":"https://avatars.githubusercontent.com/u/8784972?v=3","gravatar_id":"","url":"https://api.github.com/users/jotes","html_url":"https://github.com/jotes","followers_url":"https://api.github.com/users/jotes/followers","following_url":"https://api.github.com/users/jotes/following{/other_user}","gists_url":"https://api.github.com/users/jotes/gists{/gist_id}","starred_url":"https://api.github.com/users/jotes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jotes/subscriptions","organizations_url":"https://api.github.com/users/jotes/orgs","repos_url":"https://api.github.com/users/jotes/repos","events_url":"https://api.github.com/users/jotes/events{/privacy}","received_events_url":"https://api.github.com/users/jotes/received_events","type":"User","site_admin":false},"body":"@Osmose @mathjazz Hi,\r\n\r\nI would say it's an alpha version of migrations. There's a lot to discuss because i wasn't sure about some things. Hopefully every change should be relatively easy.\r\nMy questions and doubts:\r\n- i'm assigning groups to locale because it's a lot easier to assign users. I think it will benefit in future, however i don't want to over-engineer anything.\r\n- i'm not sure if goods idea to have signals which create these permission groups associated with locale. I mean, i don't now how often locale are added, maybe it's a rare case so this isn't so important feat. I could add separate bootstrap function for locale groups. It would speedup tests and object creation.\r\n- I've added some tests for models, i'm not sure if views require them as they use has_perm functions.","created_at":"2015-10-20T01:59:34Z","updated_at":"2015-10-21T20:15:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"86f4cd64cb27f108b35594c4cc0d0e05b335aab8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/pontoon/pulls/219/commits","review_comments_url":"https://api.github.com/repos/mozilla/pontoon/pulls/219/comments","review_comment_url":"https://api.github.com/repos/mozilla/pontoon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/pontoon/issues/219/comments","statuses_url":"https://api.github.com/repos/mozilla/pontoon/statuses/5c939b30a862fbbf9c303f73b4f09a575162a4df","head":{"label":"jotes:locale_managers","ref":"locale_managers","sha":"5c939b30a862fbbf9c303f73b4f09a575162a4df","user":{"login":"jotes","id":8784972,"avatar_url":"https://avatars.githubusercontent.com/u/8784972?v=3","gravatar_id":"","url":"https://api.github.com/users/jotes","html_url":"https://github.com/jotes","followers_url":"https://api.github.com/users/jotes/followers","following_url":"https://api.github.com/users/jotes/following{/other_user}","gists_url":"https://api.github.com/users/jotes/gists{/gist_id}","starred_url":"https://api.github.com/users/jotes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jotes/subscriptions","organizations_url":"https://api.github.com/users/jotes/orgs","repos_url":"https://api.github.com/users/jotes/repos","events_url":"https://api.github.com/users/jotes/events{/privacy}","received_events_url":"https://api.github.com/users/jotes/received_events","type":"User","site_admin":false},"repo":{"id":40921914,"name":"pontoon","full_name":"jotes/pontoon","owner":{"login":"jotes","id":8784972,"avatar_url":"https://avatars.githubusercontent.com/u/8784972?v=3","gravatar_id":"","url":"https://api.github.com/users/jotes","html_url":"https://github.com/jotes","followers_url":"https://api.github.com/users/jotes/followers","following_url":"https://api.github.com/users/jotes/following{/other_user}","gists_url":"https://api.github.com/users/jotes/gists{/gist_id}","starred_url":"https://api.github.com/users/jotes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jotes/subscriptions","organizations_url":"https://api.github.com/users/jotes/orgs","repos_url":"https://api.github.com/users/jotes/repos","events_url":"https://api.github.com/users/jotes/events{/privacy}","received_events_url":"https://api.github.com/users/jotes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jotes/pontoon","description":"In-place localization tool","fork":true,"url":"https://api.github.com/repos/jotes/pontoon","forks_url":"https://api.github.com/repos/jotes/pontoon/forks","keys_url":"https://api.github.com/repos/jotes/pontoon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jotes/pontoon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jotes/pontoon/teams","hooks_url":"https://api.github.com/repos/jotes/pontoon/hooks","issue_events_url":"https://api.github.com/repos/jotes/pontoon/issues/events{/number}","events_url":"https://api.github.com/repos/jotes/pontoon/events","assignees_url":"https://api.github.com/repos/jotes/pontoon/assignees{/user}","branches_url":"https://api.github.com/repos/jotes/pontoon/branches{/branch}","tags_url":"https://api.github.com/repos/jotes/pontoon/tags","blobs_url":"https://api.github.com/repos/jotes/pontoon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jotes/pontoon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jotes/pontoon/git/refs{/sha}","trees_url":"https://api.github.com/repos/jotes/pontoon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jotes/pontoon/statuses/{sha}","languages_url":"https://api.github.com/repos/jotes/pontoon/languages","stargazers_url":"https://api.github.com/repos/jotes/pontoon/stargazers","contributors_url":"https://api.github.com/repos/jotes/pontoon/contributors","subscribers_url":"https://api.github.com/repos/jotes/pontoon/subscribers","subscription_url":"https://api.github.com/repos/jotes/pontoon/subscription","commits_url":"https://api.github.com/repos/jotes/pontoon/commits{/sha}","git_commits_url":"https://api.github.com/repos/jotes/pontoon/git/commits{/sha}","comments_url":"https://api.github.com/repos/jotes/pontoon/comments{/number}","issue_comment_url":"https://api.github.com/repos/jotes/pontoon/issues/comments{/number}","contents_url":"https://api.github.com/repos/jotes/pontoon/contents/{+path}","compare_url":"https://api.github.com/repos/jotes/pontoon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jotes/pontoon/merges","archive_url":"https://api.github.com/repos/jotes/pontoon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jotes/pontoon/downloads","issues_url":"https://api.github.com/repos/jotes/pontoon/issues{/number}","pulls_url":"https://api.github.com/repos/jotes/pontoon/pulls{/number}","milestones_url":"https://api.github.com/repos/jotes/pontoon/milestones{/number}","notifications_url":"https://api.github.com/repos/jotes/pontoon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jotes/pontoon/labels{/name}","releases_url":"https://api.github.com/repos/jotes/pontoon/releases{/id}","created_at":"2015-08-17T19:18:45Z","updated_at":"2015-08-17T19:18:46Z","pushed_at":"2015-10-20T22:17:13Z","git_url":"git://github.com/jotes/pontoon.git","ssh_url":"git@github.com:jotes/pontoon.git","clone_url":"https://github.com/jotes/pontoon.git","svn_url":"https://github.com/jotes/pontoon","homepage":"https://pontoon.mozilla.org/","size":18485,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"mozilla:master","ref":"master","sha":"e7875802aacd6fe8635f02489321a302ef8929c3","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":1385890,"name":"pontoon","full_name":"mozilla/pontoon","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/pontoon","description":"In-place localization tool","fork":false,"url":"https://api.github.com/repos/mozilla/pontoon","forks_url":"https://api.github.com/repos/mozilla/pontoon/forks","keys_url":"https://api.github.com/repos/mozilla/pontoon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/pontoon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/pontoon/teams","hooks_url":"https://api.github.com/repos/mozilla/pontoon/hooks","issue_events_url":"https://api.github.com/repos/mozilla/pontoon/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/pontoon/events","assignees_url":"https://api.github.com/repos/mozilla/pontoon/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/pontoon/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/pontoon/tags","blobs_url":"https://api.github.com/repos/mozilla/pontoon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/pontoon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/pontoon/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/pontoon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/pontoon/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/pontoon/languages","stargazers_url":"https://api.github.com/repos/mozilla/pontoon/stargazers","contributors_url":"https://api.github.com/repos/mozilla/pontoon/contributors","subscribers_url":"https://api.github.com/repos/mozilla/pontoon/subscribers","subscription_url":"https://api.github.com/repos/mozilla/pontoon/subscription","commits_url":"https://api.github.com/repos/mozilla/pontoon/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/pontoon/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/pontoon/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/pontoon/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/pontoon/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/pontoon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/pontoon/merges","archive_url":"https://api.github.com/repos/mozilla/pontoon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/pontoon/downloads","issues_url":"https://api.github.com/repos/mozilla/pontoon/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/pontoon/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/pontoon/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/pontoon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/pontoon/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/pontoon/releases{/id}","created_at":"2011-02-19T11:25:51Z","updated_at":"2015-10-19T17:45:00Z","pushed_at":"2015-10-21T18:50:34Z","git_url":"git://github.com/mozilla/pontoon.git","ssh_url":"git@github.com:mozilla/pontoon.git","clone_url":"https://github.com/mozilla/pontoon.git","svn_url":"https://github.com/mozilla/pontoon","homepage":"https://pontoon.mozilla.org/","size":23824,"stargazers_count":77,"watchers_count":77,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":3,"forks":29,"open_issues":3,"watchers":77,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/219"},"html":{"href":"https://github.com/mozilla/pontoon/pull/219"},"issue":{"href":"https://api.github.com/repos/mozilla/pontoon/issues/219"},"comments":{"href":"https://api.github.com/repos/mozilla/pontoon/issues/219/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/219/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/pontoon/pulls/219/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/pontoon/statuses/5c939b30a862fbbf9c303f73b4f09a575162a4df"}}}}