{"action":"created","comment":{"url":"https://api.github.com/repos/translate/pootle/pulls/comments/84758970","pull_request_review_id":5516188,"id":84758970,"diff_hunk":"@@ -135,3 +150,116 @@ def save(self):\n                 if self.cleaned_data[\"rm_%ss\" % role]:\n                     for user in self.cleaned_data[\"rm_%ss\" % role]:\n                         self.language_team.remove_member(user)\n+\n+\n+class LanguageSuggestionAdminForm(LanguageTeamFormtableForm):\n+    action_field = \"actions\"\n+    search_field = \"suggestions\"\n+    action_choices = (\n+        (\"\", \"----\"),\n+        (\"reject\", _(\"Reject\")),\n+        (\"accept\", _(\"Accept\")))\n+    filter_suggester = forms.ChoiceField(\n+        choices=(),\n+        required=False,\n+        widget=forms.Select(\n+            attrs={'class': 'js-select2 select2-language'}))\n+    filter_state = forms.ChoiceField(\n+        required=False,\n+        choices=(\n+            [(\"\", \"-----\")]\n+            + [(k, v)\n+               for k, v\n+               in STATES_MAP.items() if k != OBSOLETE]),\n+        widget=forms.Select(\n+            attrs={'class': 'js-select2 select2-language'}))\n+    filter_tp = forms.ModelChoiceField(\n+        label=_(\"Project\"),\n+        required=False,\n+        queryset=TranslationProject.objects.none(),\n+        widget=forms.Select(\n+            attrs={'class': 'js-select2'}))\n+    suggestions = forms.ModelMultipleChoiceField(\n+        widget=TableSelectMultiple(\n+            item_attrs=[\n+                \"unit_link\",\n+                \"unit_state\",\n+                \"unit\",\n+                \"target_f\",\n+                \"user\",\n+                \"creation_time\",\n+                \"project\"]),\n+        required=False,\n+        queryset=Suggestion.objects.select_related(\n+            \"unit\",\n+            \"unit__store\",\n+            \"unit__store__translation_project\",\n+            \"unit__store__translation_project__project\").none())\n+\n+    def __init__(self, *args, **kwargs):\n+        self.user = kwargs.pop(\"user\")\n+        self.language = kwargs.pop(\"language\")\n+        super(LanguageSuggestionAdminForm, self).__init__(*args, **kwargs)\n+        self.fields[\"filter_suggester\"].choices = self.filter_suggester_choices\n+        self.fields[\"filter_tp\"].queryset = self.filter_tp_qs\n+        self.fields[\"suggestions\"].queryset = self.suggestions_qs\n+\n+    @property\n+    def filter_suggester_choices(self):\n+        suggesters = list(\n+            (username,\n+             (\"%s (%s)\" % (fullname, username)\n+              if fullname.strip()\n+              else username))\n+            for username, fullname\n+            in sorted(self.language_team.users_with_suggestions))\n+        return [(\"\", \"-----\")] + suggesters\n+\n+    @property\n+    def suggestions_qs(self):\n+        return self.language_team.suggestions.select_related(\"unit\", \"user\").filter(\n+            unit__store__translation_project__project__disabled=False)\n+\n+    @property\n+    def filter_tp_qs(self):\n+        tps = self.language.translationproject_set.exclude(\n+            project__disabled=True)\n+        tps = tps.filter(\n+            stores__unit__suggestion__state=SuggestionStates.PENDING)\n+        return tps.order_by(\"project__code\").distinct()\n+\n+    @property\n+    def suggestions_to_save(self):\n+        if not self.is_valid():\n+            return []\n+        return (\n+            self.fields[\"suggestions\"].queryset\n+            if self.cleaned_data[\"select_all\"]\n+            else self.cleaned_data[\"suggestions\"])\n+\n+    @property\n+    def suggestions_review(self):\n+        if not self.is_valid():\n+            return\n+        return review.get(Suggestion)(self.suggestions_to_save, self.user)\n+\n+    def save(self):\n+        return (\n+            self.suggestions_review.accept(\n+                comment=self.cleaned_data[\"comment\"])\n+            if self.cleaned_data[\"actions\"] == \"accept\"","path":"pootle/apps/pootle_language/forms.py","position":141,"original_position":141,"commit_id":"782fb75909162e3010e00c5e60a08a98aeb0a3cb","original_commit_id":"65d4fb0125340f49f79fb697778806bbdb8f0527","user":{"login":"unho","id":939880,"avatar_url":"https://avatars.githubusercontent.com/u/939880?v=3","gravatar_id":"","url":"https://api.github.com/users/unho","html_url":"https://github.com/unho","followers_url":"https://api.github.com/users/unho/followers","following_url":"https://api.github.com/users/unho/following{/other_user}","gists_url":"https://api.github.com/users/unho/gists{/gist_id}","starred_url":"https://api.github.com/users/unho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unho/subscriptions","organizations_url":"https://api.github.com/users/unho/orgs","repos_url":"https://api.github.com/users/unho/repos","events_url":"https://api.github.com/users/unho/events{/privacy}","received_events_url":"https://api.github.com/users/unho/received_events","type":"User","site_admin":false},"body":"Thinking aloud this would better to be some constant. But I am not blocking on it.","created_at":"2016-10-24T18:58:48Z","updated_at":"2016-10-24T18:58:49Z","html_url":"https://github.com/translate/pootle/pull/5380#discussion_r84758970","pull_request_url":"https://api.github.com/repos/translate/pootle/pulls/5380","_links":{"self":{"href":"https://api.github.com/repos/translate/pootle/pulls/comments/84758970"},"html":{"href":"https://github.com/translate/pootle/pull/5380#discussion_r84758970"},"pull_request":{"href":"https://api.github.com/repos/translate/pootle/pulls/5380"}}},"pull_request":{"url":"https://api.github.com/repos/translate/pootle/pulls/5380","id":89487992,"html_url":"https://github.com/translate/pootle/pull/5380","diff_url":"https://github.com/translate/pootle/pull/5380.diff","patch_url":"https://github.com/translate/pootle/pull/5380.patch","issue_url":"https://api.github.com/repos/translate/pootle/issues/5380","number":5380,"state":"open","locked":false,"title":"Team page suggestions","user":{"login":"phlax","id":454682,"avatar_url":"https://avatars.githubusercontent.com/u/454682?v=3","gravatar_id":"","url":"https://api.github.com/users/phlax","html_url":"https://github.com/phlax","followers_url":"https://api.github.com/users/phlax/followers","following_url":"https://api.github.com/users/phlax/following{/other_user}","gists_url":"https://api.github.com/users/phlax/gists{/gist_id}","starred_url":"https://api.github.com/users/phlax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phlax/subscriptions","organizations_url":"https://api.github.com/users/phlax/orgs","repos_url":"https://api.github.com/users/phlax/repos","events_url":"https://api.github.com/users/phlax/events{/privacy}","received_events_url":"https://api.github.com/users/phlax/received_events","type":"User","site_admin":false},"body":"Adds a suggestion management UI for language teams","created_at":"2016-10-15T09:43:43Z","updated_at":"2016-10-24T18:58:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70a5aae55d310c32a648279adee20373e2ead48c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/translate/pootle/pulls/5380/commits","review_comments_url":"https://api.github.com/repos/translate/pootle/pulls/5380/comments","review_comment_url":"https://api.github.com/repos/translate/pootle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/translate/pootle/issues/5380/comments","statuses_url":"https://api.github.com/repos/translate/pootle/statuses/782fb75909162e3010e00c5e60a08a98aeb0a3cb","head":{"label":"phlax:team_page_suggestions","ref":"team_page_suggestions","sha":"782fb75909162e3010e00c5e60a08a98aeb0a3cb","user":{"login":"phlax","id":454682,"avatar_url":"https://avatars.githubusercontent.com/u/454682?v=3","gravatar_id":"","url":"https://api.github.com/users/phlax","html_url":"https://github.com/phlax","followers_url":"https://api.github.com/users/phlax/followers","following_url":"https://api.github.com/users/phlax/following{/other_user}","gists_url":"https://api.github.com/users/phlax/gists{/gist_id}","starred_url":"https://api.github.com/users/phlax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phlax/subscriptions","organizations_url":"https://api.github.com/users/phlax/orgs","repos_url":"https://api.github.com/users/phlax/repos","events_url":"https://api.github.com/users/phlax/events{/privacy}","received_events_url":"https://api.github.com/users/phlax/received_events","type":"User","site_admin":false},"repo":{"id":39886550,"name":"pootle","full_name":"phlax/pootle","owner":{"login":"phlax","id":454682,"avatar_url":"https://avatars.githubusercontent.com/u/454682?v=3","gravatar_id":"","url":"https://api.github.com/users/phlax","html_url":"https://github.com/phlax","followers_url":"https://api.github.com/users/phlax/followers","following_url":"https://api.github.com/users/phlax/following{/other_user}","gists_url":"https://api.github.com/users/phlax/gists{/gist_id}","starred_url":"https://api.github.com/users/phlax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phlax/subscriptions","organizations_url":"https://api.github.com/users/phlax/orgs","repos_url":"https://api.github.com/users/phlax/repos","events_url":"https://api.github.com/users/phlax/events{/privacy}","received_events_url":"https://api.github.com/users/phlax/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/phlax/pootle","description":"Online translation tool","fork":true,"url":"https://api.github.com/repos/phlax/pootle","forks_url":"https://api.github.com/repos/phlax/pootle/forks","keys_url":"https://api.github.com/repos/phlax/pootle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phlax/pootle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phlax/pootle/teams","hooks_url":"https://api.github.com/repos/phlax/pootle/hooks","issue_events_url":"https://api.github.com/repos/phlax/pootle/issues/events{/number}","events_url":"https://api.github.com/repos/phlax/pootle/events","assignees_url":"https://api.github.com/repos/phlax/pootle/assignees{/user}","branches_url":"https://api.github.com/repos/phlax/pootle/branches{/branch}","tags_url":"https://api.github.com/repos/phlax/pootle/tags","blobs_url":"https://api.github.com/repos/phlax/pootle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phlax/pootle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phlax/pootle/git/refs{/sha}","trees_url":"https://api.github.com/repos/phlax/pootle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phlax/pootle/statuses/{sha}","languages_url":"https://api.github.com/repos/phlax/pootle/languages","stargazers_url":"https://api.github.com/repos/phlax/pootle/stargazers","contributors_url":"https://api.github.com/repos/phlax/pootle/contributors","subscribers_url":"https://api.github.com/repos/phlax/pootle/subscribers","subscription_url":"https://api.github.com/repos/phlax/pootle/subscription","commits_url":"https://api.github.com/repos/phlax/pootle/commits{/sha}","git_commits_url":"https://api.github.com/repos/phlax/pootle/git/commits{/sha}","comments_url":"https://api.github.com/repos/phlax/pootle/comments{/number}","issue_comment_url":"https://api.github.com/repos/phlax/pootle/issues/comments{/number}","contents_url":"https://api.github.com/repos/phlax/pootle/contents/{+path}","compare_url":"https://api.github.com/repos/phlax/pootle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phlax/pootle/merges","archive_url":"https://api.github.com/repos/phlax/pootle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phlax/pootle/downloads","issues_url":"https://api.github.com/repos/phlax/pootle/issues{/number}","pulls_url":"https://api.github.com/repos/phlax/pootle/pulls{/number}","milestones_url":"https://api.github.com/repos/phlax/pootle/milestones{/number}","notifications_url":"https://api.github.com/repos/phlax/pootle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phlax/pootle/labels{/name}","releases_url":"https://api.github.com/repos/phlax/pootle/releases{/id}","deployments_url":"https://api.github.com/repos/phlax/pootle/deployments","created_at":"2015-07-29T10:00:35Z","updated_at":"2016-01-14T21:46:37Z","pushed_at":"2016-10-24T18:55:25Z","git_url":"git://github.com/phlax/pootle.git","ssh_url":"git@github.com:phlax/pootle.git","clone_url":"https://github.com/phlax/pootle.git","svn_url":"https://github.com/phlax/pootle","homepage":"http://pootle.translatehouse.org","size":104259,"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":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"translate:master","ref":"master","sha":"53da3368c4abb2f83d1438764b5f3f75b01d6e64","user":{"login":"translate","id":1538178,"avatar_url":"https://avatars.githubusercontent.com/u/1538178?v=3","gravatar_id":"","url":"https://api.github.com/users/translate","html_url":"https://github.com/translate","followers_url":"https://api.github.com/users/translate/followers","following_url":"https://api.github.com/users/translate/following{/other_user}","gists_url":"https://api.github.com/users/translate/gists{/gist_id}","starred_url":"https://api.github.com/users/translate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/translate/subscriptions","organizations_url":"https://api.github.com/users/translate/orgs","repos_url":"https://api.github.com/users/translate/repos","events_url":"https://api.github.com/users/translate/events{/privacy}","received_events_url":"https://api.github.com/users/translate/received_events","type":"Organization","site_admin":false},"repo":{"id":3769702,"name":"pootle","full_name":"translate/pootle","owner":{"login":"translate","id":1538178,"avatar_url":"https://avatars.githubusercontent.com/u/1538178?v=3","gravatar_id":"","url":"https://api.github.com/users/translate","html_url":"https://github.com/translate","followers_url":"https://api.github.com/users/translate/followers","following_url":"https://api.github.com/users/translate/following{/other_user}","gists_url":"https://api.github.com/users/translate/gists{/gist_id}","starred_url":"https://api.github.com/users/translate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/translate/subscriptions","organizations_url":"https://api.github.com/users/translate/orgs","repos_url":"https://api.github.com/users/translate/repos","events_url":"https://api.github.com/users/translate/events{/privacy}","received_events_url":"https://api.github.com/users/translate/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/translate/pootle","description":"Online translation tool","fork":false,"url":"https://api.github.com/repos/translate/pootle","forks_url":"https://api.github.com/repos/translate/pootle/forks","keys_url":"https://api.github.com/repos/translate/pootle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/translate/pootle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/translate/pootle/teams","hooks_url":"https://api.github.com/repos/translate/pootle/hooks","issue_events_url":"https://api.github.com/repos/translate/pootle/issues/events{/number}","events_url":"https://api.github.com/repos/translate/pootle/events","assignees_url":"https://api.github.com/repos/translate/pootle/assignees{/user}","branches_url":"https://api.github.com/repos/translate/pootle/branches{/branch}","tags_url":"https://api.github.com/repos/translate/pootle/tags","blobs_url":"https://api.github.com/repos/translate/pootle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/translate/pootle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/translate/pootle/git/refs{/sha}","trees_url":"https://api.github.com/repos/translate/pootle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/translate/pootle/statuses/{sha}","languages_url":"https://api.github.com/repos/translate/pootle/languages","stargazers_url":"https://api.github.com/repos/translate/pootle/stargazers","contributors_url":"https://api.github.com/repos/translate/pootle/contributors","subscribers_url":"https://api.github.com/repos/translate/pootle/subscribers","subscription_url":"https://api.github.com/repos/translate/pootle/subscription","commits_url":"https://api.github.com/repos/translate/pootle/commits{/sha}","git_commits_url":"https://api.github.com/repos/translate/pootle/git/commits{/sha}","comments_url":"https://api.github.com/repos/translate/pootle/comments{/number}","issue_comment_url":"https://api.github.com/repos/translate/pootle/issues/comments{/number}","contents_url":"https://api.github.com/repos/translate/pootle/contents/{+path}","compare_url":"https://api.github.com/repos/translate/pootle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/translate/pootle/merges","archive_url":"https://api.github.com/repos/translate/pootle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/translate/pootle/downloads","issues_url":"https://api.github.com/repos/translate/pootle/issues{/number}","pulls_url":"https://api.github.com/repos/translate/pootle/pulls{/number}","milestones_url":"https://api.github.com/repos/translate/pootle/milestones{/number}","notifications_url":"https://api.github.com/repos/translate/pootle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/translate/pootle/labels{/name}","releases_url":"https://api.github.com/repos/translate/pootle/releases{/id}","deployments_url":"https://api.github.com/repos/translate/pootle/deployments","created_at":"2012-03-19T23:06:03Z","updated_at":"2016-10-22T14:55:41Z","pushed_at":"2016-10-24T18:55:26Z","git_url":"git://github.com/translate/pootle.git","ssh_url":"git@github.com:translate/pootle.git","clone_url":"https://github.com/translate/pootle.git","svn_url":"https://github.com/translate/pootle","homepage":"http://pootle.translatehouse.org","size":109109,"stargazers_count":702,"watchers_count":702,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":200,"mirror_url":null,"open_issues_count":468,"forks":200,"open_issues":468,"watchers":702,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/translate/pootle/pulls/5380"},"html":{"href":"https://github.com/translate/pootle/pull/5380"},"issue":{"href":"https://api.github.com/repos/translate/pootle/issues/5380"},"comments":{"href":"https://api.github.com/repos/translate/pootle/issues/5380/comments"},"review_comments":{"href":"https://api.github.com/repos/translate/pootle/pulls/5380/comments"},"review_comment":{"href":"https://api.github.com/repos/translate/pootle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/translate/pootle/pulls/5380/commits"},"statuses":{"href":"https://api.github.com/repos/translate/pootle/statuses/782fb75909162e3010e00c5e60a08a98aeb0a3cb"}}}}
{"actor":{"display_login":"unho"}}