{"action":"created","comment":{"url":"https://api.github.com/repos/political-memory/political_memory/pulls/comments/67558805","id":67558805,"diff_hunk":"@@ -20,57 +17,29 @@ class RepresentativeList(CSVDownloadMixin, GridListMixin, PaginationMixin,\n \n     csv_name = 'representatives'\n     queryset = Representative.objects.select_related('score')\n+    current_filter = None\n \n     def get_context_data(self, **kwargs):\n         c = super(RepresentativeList, self).get_context_data(**kwargs)\n \n+        c['filter'] = self.current_filter\n         c['object_list'] = [\n             self.add_representative_country_and_main_mandate(r)\n             for r in c['object_list']\n         ]\n \n         return c\n \n-    def search_filter(self, qs):\n-        search = self.request.GET.get('search', None)\n-        if search:\n-            qs = qs.filter(slug__icontains=slugify(search))\n-        return qs\n-\n-    def group_filter(self, qs):\n-        group_kind = self.kwargs.get('group_kind', None)\n-        chamber = self.kwargs.get('chamber', None)\n-        group = self.kwargs.get('group', None)\n-        today = datetime.date.today()\n-\n-        if group_kind and group:\n-            if group.isnumeric():\n-                group_qs = Group.objects.filter(\n-                    id=int(group)\n-                )\n-            else:\n-                group_qs = Group.objects.filter(\n-                    name=group,\n-                    kind=group_kind\n-                )\n-\n-            if chamber:\n-                group_qs = group_qs.filter(chamber__name=chamber)\n-\n-            qs = qs.filter(\n-                models.Q(mandates__end_date__gte=today) |\n-                models.Q(mandates__end_date__isnull=True),\n-                mandates__group__in=group_qs\n-            )\n-\n-        return qs\n+    def rep_filter(self, qs):\n+        f = RepresentativeFilter(self.request.GET, queryset=qs)\n+        self.current_filter = f\n+        return f.qs","path":"memopol/views/representative_list.py","position":70,"original_position":70,"commit_id":"940a07d0812f5451e0c5af825a4dca880be43723","original_commit_id":"940a07d0812f5451e0c5af825a4dca880be43723","user":{"login":"jpic","id":94636,"avatar_url":"https://avatars.githubusercontent.com/u/94636?v=3","gravatar_id":"","url":"https://api.github.com/users/jpic","html_url":"https://github.com/jpic","followers_url":"https://api.github.com/users/jpic/followers","following_url":"https://api.github.com/users/jpic/following{/other_user}","gists_url":"https://api.github.com/users/jpic/gists{/gist_id}","starred_url":"https://api.github.com/users/jpic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpic/subscriptions","organizations_url":"https://api.github.com/users/jpic/orgs","repos_url":"https://api.github.com/users/jpic/repos","events_url":"https://api.github.com/users/jpic/events{/privacy}","received_events_url":"https://api.github.com/users/jpic/received_events","type":"User","site_admin":false},"body":":guitar: ","created_at":"2016-06-17T18:54:59Z","updated_at":"2016-06-17T18:54:59Z","html_url":"https://github.com/political-memory/political_memory/pull/92#discussion_r67558805","pull_request_url":"https://api.github.com/repos/political-memory/political_memory/pulls/92","_links":{"self":{"href":"https://api.github.com/repos/political-memory/political_memory/pulls/comments/67558805"},"html":{"href":"https://github.com/political-memory/political_memory/pull/92#discussion_r67558805"},"pull_request":{"href":"https://api.github.com/repos/political-memory/political_memory/pulls/92"}}},"pull_request":{"url":"https://api.github.com/repos/political-memory/political_memory/pulls/92","id":74038080,"html_url":"https://github.com/political-memory/political_memory/pull/92","diff_url":"https://github.com/political-memory/political_memory/pull/92.diff","patch_url":"https://github.com/political-memory/political_memory/pull/92.patch","issue_url":"https://api.github.com/repos/political-memory/political_memory/issues/92","number":92,"state":"open","locked":false,"title":"[WIP] Add filters for representatives","user":{"login":"njoyard","id":127842,"avatar_url":"https://avatars.githubusercontent.com/u/127842?v=3","gravatar_id":"","url":"https://api.github.com/users/njoyard","html_url":"https://github.com/njoyard","followers_url":"https://api.github.com/users/njoyard/followers","following_url":"https://api.github.com/users/njoyard/following{/other_user}","gists_url":"https://api.github.com/users/njoyard/gists{/gist_id}","starred_url":"https://api.github.com/users/njoyard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njoyard/subscriptions","organizations_url":"https://api.github.com/users/njoyard/orgs","repos_url":"https://api.github.com/users/njoyard/repos","events_url":"https://api.github.com/users/njoyard/events{/privacy}","received_events_url":"https://api.github.com/users/njoyard/received_events","type":"User","site_admin":false},"body":"This PR adds a filter form that uses django-filters on the representative list with the following criteria:\r\n* *search*: identical to the previously existing search box, searches representatives by name\r\n* *chamber*: static drop down list to filter by chamber\r\n* *country*: static drop down list to filter by country\r\n* *group*: autocompleted drop down to filter by all kinds of groups (except chamber and country) : party, committee, delegation, ...\r\n\r\nThe group URLs (like `/legislature/representatives/committee/European Parliament/Committee on Defense whatever`) are now 301-redirected to an URL with querystring parameters in order to pre-fill the filter form.\r\n\r\nTODO:\r\n* [x] fix select2 style to match the rest of the form\r\n* [x] ensure the filter form always submits to the root representative list url instead of the current page url (not really needed but just in case)\r\n* [ ] add a checkbox to choose active/inactive meps *(maybe)* ?\r\n* [x] add something more obvious when there are no results\r\n* [x] ~~add a media block to the root template to allow page templates to add to it~~ not needed, we have a head block\r\n* [ ] change the way groups are displayed in the ac (add abbreviation, make group type more obvious)\r\n* [x] add filter tests\r\n* [ ] check duplicate meps issue again\r\n* [x] fix missing querystring in page links\r\n\r\nPreview:\r\n\r\n![preview](https://framapic.org/gierm9d1M2ym/dqpVBqKOA2Ud.png)","created_at":"2016-06-16T08:07:19Z","updated_at":"2016-06-17T18:54:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d2b4e473cdd80a504b81764cca4eac784a436b40","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/political-memory/political_memory/pulls/92/commits","review_comments_url":"https://api.github.com/repos/political-memory/political_memory/pulls/92/comments","review_comment_url":"https://api.github.com/repos/political-memory/political_memory/pulls/comments{/number}","comments_url":"https://api.github.com/repos/political-memory/political_memory/issues/92/comments","statuses_url":"https://api.github.com/repos/political-memory/political_memory/statuses/940a07d0812f5451e0c5af825a4dca880be43723","head":{"label":"political-memory:filter-representatives","ref":"filter-representatives","sha":"940a07d0812f5451e0c5af825a4dca880be43723","user":{"login":"political-memory","id":5863689,"avatar_url":"https://avatars.githubusercontent.com/u/5863689?v=3","gravatar_id":"","url":"https://api.github.com/users/political-memory","html_url":"https://github.com/political-memory","followers_url":"https://api.github.com/users/political-memory/followers","following_url":"https://api.github.com/users/political-memory/following{/other_user}","gists_url":"https://api.github.com/users/political-memory/gists{/gist_id}","starred_url":"https://api.github.com/users/political-memory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/political-memory/subscriptions","organizations_url":"https://api.github.com/users/political-memory/orgs","repos_url":"https://api.github.com/users/political-memory/repos","events_url":"https://api.github.com/users/political-memory/events{/privacy}","received_events_url":"https://api.github.com/users/political-memory/received_events","type":"Organization","site_admin":false},"repo":{"id":12538655,"name":"political_memory","full_name":"political-memory/political_memory","owner":{"login":"political-memory","id":5863689,"avatar_url":"https://avatars.githubusercontent.com/u/5863689?v=3","gravatar_id":"","url":"https://api.github.com/users/political-memory","html_url":"https://github.com/political-memory","followers_url":"https://api.github.com/users/political-memory/followers","following_url":"https://api.github.com/users/political-memory/following{/other_user}","gists_url":"https://api.github.com/users/political-memory/gists{/gist_id}","starred_url":"https://api.github.com/users/political-memory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/political-memory/subscriptions","organizations_url":"https://api.github.com/users/political-memory/orgs","repos_url":"https://api.github.com/users/political-memory/repos","events_url":"https://api.github.com/users/political-memory/events{/privacy}","received_events_url":"https://api.github.com/users/political-memory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/political-memory/political_memory","description":"Life is too short, let's patch politic","fork":false,"url":"https://api.github.com/repos/political-memory/political_memory","forks_url":"https://api.github.com/repos/political-memory/political_memory/forks","keys_url":"https://api.github.com/repos/political-memory/political_memory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/political-memory/political_memory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/political-memory/political_memory/teams","hooks_url":"https://api.github.com/repos/political-memory/political_memory/hooks","issue_events_url":"https://api.github.com/repos/political-memory/political_memory/issues/events{/number}","events_url":"https://api.github.com/repos/political-memory/political_memory/events","assignees_url":"https://api.github.com/repos/political-memory/political_memory/assignees{/user}","branches_url":"https://api.github.com/repos/political-memory/political_memory/branches{/branch}","tags_url":"https://api.github.com/repos/political-memory/political_memory/tags","blobs_url":"https://api.github.com/repos/political-memory/political_memory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/political-memory/political_memory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/political-memory/political_memory/git/refs{/sha}","trees_url":"https://api.github.com/repos/political-memory/political_memory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/political-memory/political_memory/statuses/{sha}","languages_url":"https://api.github.com/repos/political-memory/political_memory/languages","stargazers_url":"https://api.github.com/repos/political-memory/political_memory/stargazers","contributors_url":"https://api.github.com/repos/political-memory/political_memory/contributors","subscribers_url":"https://api.github.com/repos/political-memory/political_memory/subscribers","subscription_url":"https://api.github.com/repos/political-memory/political_memory/subscription","commits_url":"https://api.github.com/repos/political-memory/political_memory/commits{/sha}","git_commits_url":"https://api.github.com/repos/political-memory/political_memory/git/commits{/sha}","comments_url":"https://api.github.com/repos/political-memory/political_memory/comments{/number}","issue_comment_url":"https://api.github.com/repos/political-memory/political_memory/issues/comments{/number}","contents_url":"https://api.github.com/repos/political-memory/political_memory/contents/{+path}","compare_url":"https://api.github.com/repos/political-memory/political_memory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/political-memory/political_memory/merges","archive_url":"https://api.github.com/repos/political-memory/political_memory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/political-memory/political_memory/downloads","issues_url":"https://api.github.com/repos/political-memory/political_memory/issues{/number}","pulls_url":"https://api.github.com/repos/political-memory/political_memory/pulls{/number}","milestones_url":"https://api.github.com/repos/political-memory/political_memory/milestones{/number}","notifications_url":"https://api.github.com/repos/political-memory/political_memory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/political-memory/political_memory/labels{/name}","releases_url":"https://api.github.com/repos/political-memory/political_memory/releases{/id}","deployments_url":"https://api.github.com/repos/political-memory/political_memory/deployments","created_at":"2013-09-02T11:37:01Z","updated_at":"2016-05-21T01:45:23Z","pushed_at":"2016-06-17T17:57:06Z","git_url":"git://github.com/political-memory/political_memory.git","ssh_url":"git@github.com:political-memory/political_memory.git","clone_url":"https://github.com/political-memory/political_memory.git","svn_url":"https://github.com/political-memory/political_memory","homepage":null,"size":11473,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":24,"forks":5,"open_issues":24,"watchers":6,"default_branch":"master"}},"base":{"label":"political-memory:master","ref":"master","sha":"0cea299b4c27381cdb14423c304e633557c7d084","user":{"login":"political-memory","id":5863689,"avatar_url":"https://avatars.githubusercontent.com/u/5863689?v=3","gravatar_id":"","url":"https://api.github.com/users/political-memory","html_url":"https://github.com/political-memory","followers_url":"https://api.github.com/users/political-memory/followers","following_url":"https://api.github.com/users/political-memory/following{/other_user}","gists_url":"https://api.github.com/users/political-memory/gists{/gist_id}","starred_url":"https://api.github.com/users/political-memory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/political-memory/subscriptions","organizations_url":"https://api.github.com/users/political-memory/orgs","repos_url":"https://api.github.com/users/political-memory/repos","events_url":"https://api.github.com/users/political-memory/events{/privacy}","received_events_url":"https://api.github.com/users/political-memory/received_events","type":"Organization","site_admin":false},"repo":{"id":12538655,"name":"political_memory","full_name":"political-memory/political_memory","owner":{"login":"political-memory","id":5863689,"avatar_url":"https://avatars.githubusercontent.com/u/5863689?v=3","gravatar_id":"","url":"https://api.github.com/users/political-memory","html_url":"https://github.com/political-memory","followers_url":"https://api.github.com/users/political-memory/followers","following_url":"https://api.github.com/users/political-memory/following{/other_user}","gists_url":"https://api.github.com/users/political-memory/gists{/gist_id}","starred_url":"https://api.github.com/users/political-memory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/political-memory/subscriptions","organizations_url":"https://api.github.com/users/political-memory/orgs","repos_url":"https://api.github.com/users/political-memory/repos","events_url":"https://api.github.com/users/political-memory/events{/privacy}","received_events_url":"https://api.github.com/users/political-memory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/political-memory/political_memory","description":"Life is too short, let's patch politic","fork":false,"url":"https://api.github.com/repos/political-memory/political_memory","forks_url":"https://api.github.com/repos/political-memory/political_memory/forks","keys_url":"https://api.github.com/repos/political-memory/political_memory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/political-memory/political_memory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/political-memory/political_memory/teams","hooks_url":"https://api.github.com/repos/political-memory/political_memory/hooks","issue_events_url":"https://api.github.com/repos/political-memory/political_memory/issues/events{/number}","events_url":"https://api.github.com/repos/political-memory/political_memory/events","assignees_url":"https://api.github.com/repos/political-memory/political_memory/assignees{/user}","branches_url":"https://api.github.com/repos/political-memory/political_memory/branches{/branch}","tags_url":"https://api.github.com/repos/political-memory/political_memory/tags","blobs_url":"https://api.github.com/repos/political-memory/political_memory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/political-memory/political_memory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/political-memory/political_memory/git/refs{/sha}","trees_url":"https://api.github.com/repos/political-memory/political_memory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/political-memory/political_memory/statuses/{sha}","languages_url":"https://api.github.com/repos/political-memory/political_memory/languages","stargazers_url":"https://api.github.com/repos/political-memory/political_memory/stargazers","contributors_url":"https://api.github.com/repos/political-memory/political_memory/contributors","subscribers_url":"https://api.github.com/repos/political-memory/political_memory/subscribers","subscription_url":"https://api.github.com/repos/political-memory/political_memory/subscription","commits_url":"https://api.github.com/repos/political-memory/political_memory/commits{/sha}","git_commits_url":"https://api.github.com/repos/political-memory/political_memory/git/commits{/sha}","comments_url":"https://api.github.com/repos/political-memory/political_memory/comments{/number}","issue_comment_url":"https://api.github.com/repos/political-memory/political_memory/issues/comments{/number}","contents_url":"https://api.github.com/repos/political-memory/political_memory/contents/{+path}","compare_url":"https://api.github.com/repos/political-memory/political_memory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/political-memory/political_memory/merges","archive_url":"https://api.github.com/repos/political-memory/political_memory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/political-memory/political_memory/downloads","issues_url":"https://api.github.com/repos/political-memory/political_memory/issues{/number}","pulls_url":"https://api.github.com/repos/political-memory/political_memory/pulls{/number}","milestones_url":"https://api.github.com/repos/political-memory/political_memory/milestones{/number}","notifications_url":"https://api.github.com/repos/political-memory/political_memory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/political-memory/political_memory/labels{/name}","releases_url":"https://api.github.com/repos/political-memory/political_memory/releases{/id}","deployments_url":"https://api.github.com/repos/political-memory/political_memory/deployments","created_at":"2013-09-02T11:37:01Z","updated_at":"2016-05-21T01:45:23Z","pushed_at":"2016-06-17T17:57:06Z","git_url":"git://github.com/political-memory/political_memory.git","ssh_url":"git@github.com:political-memory/political_memory.git","clone_url":"https://github.com/political-memory/political_memory.git","svn_url":"https://github.com/political-memory/political_memory","homepage":null,"size":11473,"stargazers_count":6,"watchers_count":6,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":24,"forks":5,"open_issues":24,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/political-memory/political_memory/pulls/92"},"html":{"href":"https://github.com/political-memory/political_memory/pull/92"},"issue":{"href":"https://api.github.com/repos/political-memory/political_memory/issues/92"},"comments":{"href":"https://api.github.com/repos/political-memory/political_memory/issues/92/comments"},"review_comments":{"href":"https://api.github.com/repos/political-memory/political_memory/pulls/92/comments"},"review_comment":{"href":"https://api.github.com/repos/political-memory/political_memory/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/political-memory/political_memory/pulls/92/commits"},"statuses":{"href":"https://api.github.com/repos/political-memory/political_memory/statuses/940a07d0812f5451e0c5af825a4dca880be43723"}}}}
{"actor":{"display_login":"jpic"}}