{"action":"created","comment":{"url":"https://api.github.com/repos/4teamwork/opengever.core/pulls/comments/59689428","id":59689428,"diff_hunk":"@@ -0,0 +1,58 @@\n+from collections import OrderedDict\n+\n+\n+class Filter(object):\n+    \"\"\"Baseclass for a tabbedview listing filter.\n+    \"\"\"\n+\n+    def __init__(self, id, label, default=False):\n+        self.id = id\n+        self.label = label\n+        self.default = default\n+\n+    def update_query(self, query):\n+        return query\n+\n+\n+class CatalogQueryFilter(Filter):\n+    \"\"\"A Filter class which extends the existing portal_catalog query with the\n+    given extension `query_extension`.\n+    \"\"\"\n+\n+    def __init__(self, id, label, default=False, query_extension={}):\n+        super(CatalogQueryFilter, self).__init__(id, label, default)\n+        self.query_extension = query_extension\n+\n+    def update_query(self, query):\n+        query.update(self.query_extension)\n+        return query\n+\n+\n+class PendingTasksFilter(Filter):\n+    \"\"\"A SQLTaskListing filter which limits the result of only pending tasks.\n+    \"\"\"\n+    def update_query(self, query):\n+        return query.in_pending_state()\n+\n+\n+class FilterList(object):\n+    \"\"\"A list of tabbedview listing Filter objects.\n+    \"\"\"\n+\n+    def __init__(self, *args):\n+        self._filters = OrderedDict()\n+        self.default_filter = None\n+        for filter in args:\n+            self._filters[filter.id] = filter\n+            if filter.default:\n+                if self.default_filter:\n+                    raise ValueError(\n+                        'Only one Filter marked as default possible.')\n+\n+                self.default_filter = filter\n+\n+    def get(self, filter_id):","path":"opengever/tabbedview/filters.py","position":54,"original_position":54,"commit_id":"b959eebdb5b25eed11d04b527ff013201ab8cfee","original_commit_id":"b959eebdb5b25eed11d04b527ff013201ab8cfee","user":{"login":"lukasgraf","id":405124,"avatar_url":"https://avatars.githubusercontent.com/u/405124?v=3","gravatar_id":"","url":"https://api.github.com/users/lukasgraf","html_url":"https://github.com/lukasgraf","followers_url":"https://api.github.com/users/lukasgraf/followers","following_url":"https://api.github.com/users/lukasgraf/following{/other_user}","gists_url":"https://api.github.com/users/lukasgraf/gists{/gist_id}","starred_url":"https://api.github.com/users/lukasgraf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukasgraf/subscriptions","organizations_url":"https://api.github.com/users/lukasgraf/orgs","repos_url":"https://api.github.com/users/lukasgraf/repos","events_url":"https://api.github.com/users/lukasgraf/events{/privacy}","received_events_url":"https://api.github.com/users/lukasgraf/received_events","type":"User","site_admin":false},"body":"This could potentially be implemented as `__getitem__`...","created_at":"2016-04-14T09:45:25Z","updated_at":"2016-04-14T09:45:25Z","html_url":"https://github.com/4teamwork/opengever.core/pull/1716#discussion_r59689428","pull_request_url":"https://api.github.com/repos/4teamwork/opengever.core/pulls/1716","_links":{"self":{"href":"https://api.github.com/repos/4teamwork/opengever.core/pulls/comments/59689428"},"html":{"href":"https://github.com/4teamwork/opengever.core/pull/1716#discussion_r59689428"},"pull_request":{"href":"https://api.github.com/repos/4teamwork/opengever.core/pulls/1716"}}},"pull_request":{"url":"https://api.github.com/repos/4teamwork/opengever.core/pulls/1716","id":66448226,"html_url":"https://github.com/4teamwork/opengever.core/pull/1716","diff_url":"https://github.com/4teamwork/opengever.core/pull/1716.diff","patch_url":"https://github.com/4teamwork/opengever.core/pull/1716.patch","issue_url":"https://api.github.com/repos/4teamwork/opengever.core/issues/1716","number":1716,"state":"open","locked":false,"title":"Refactored state_filter functionality for tabbedview listings.","user":{"login":"phgross","id":485755,"avatar_url":"https://avatars.githubusercontent.com/u/485755?v=3","gravatar_id":"","url":"https://api.github.com/users/phgross","html_url":"https://github.com/phgross","followers_url":"https://api.github.com/users/phgross/followers","following_url":"https://api.github.com/users/phgross/following{/other_user}","gists_url":"https://api.github.com/users/phgross/gists{/gist_id}","starred_url":"https://api.github.com/users/phgross/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phgross/subscriptions","organizations_url":"https://api.github.com/users/phgross/orgs","repos_url":"https://api.github.com/users/phgross/repos","events_url":"https://api.github.com/users/phgross/events{/privacy}","received_events_url":"https://api.github.com/users/phgross/received_events","type":"User","site_admin":false},"body":"The current implementation for the `Active` `All` filter is circuitous and very limited to the current use case. Because we'll extend the dossier listing filters with an additional one, I've had to rework the current implementation.\r\n\r\nTherefore I've created new objects `Filter` and `FilterList` which should make the code easier to understand and read and allow additional and more complicated filters. \r\n\r\nThe changes are only refactoring, the functionality itself is not changed.\r\n\r\n@deiferni @lukasgraf please review ...  ","created_at":"2016-04-14T08:46:08Z","updated_at":"2016-04-14T09:45:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8a260e0019124c541a80fe8204fd57327efbe3ab","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/4teamwork/opengever.core/pulls/1716/commits","review_comments_url":"https://api.github.com/repos/4teamwork/opengever.core/pulls/1716/comments","review_comment_url":"https://api.github.com/repos/4teamwork/opengever.core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/4teamwork/opengever.core/issues/1716/comments","statuses_url":"https://api.github.com/repos/4teamwork/opengever.core/statuses/b959eebdb5b25eed11d04b527ff013201ab8cfee","head":{"label":"4teamwork:pg_statefilter_rework","ref":"pg_statefilter_rework","sha":"b959eebdb5b25eed11d04b527ff013201ab8cfee","user":{"login":"4teamwork","id":681821,"avatar_url":"https://avatars.githubusercontent.com/u/681821?v=3","gravatar_id":"","url":"https://api.github.com/users/4teamwork","html_url":"https://github.com/4teamwork","followers_url":"https://api.github.com/users/4teamwork/followers","following_url":"https://api.github.com/users/4teamwork/following{/other_user}","gists_url":"https://api.github.com/users/4teamwork/gists{/gist_id}","starred_url":"https://api.github.com/users/4teamwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4teamwork/subscriptions","organizations_url":"https://api.github.com/users/4teamwork/orgs","repos_url":"https://api.github.com/users/4teamwork/repos","events_url":"https://api.github.com/users/4teamwork/events{/privacy}","received_events_url":"https://api.github.com/users/4teamwork/received_events","type":"Organization","site_admin":false},"repo":{"id":9788097,"name":"opengever.core","full_name":"4teamwork/opengever.core","owner":{"login":"4teamwork","id":681821,"avatar_url":"https://avatars.githubusercontent.com/u/681821?v=3","gravatar_id":"","url":"https://api.github.com/users/4teamwork","html_url":"https://github.com/4teamwork","followers_url":"https://api.github.com/users/4teamwork/followers","following_url":"https://api.github.com/users/4teamwork/following{/other_user}","gists_url":"https://api.github.com/users/4teamwork/gists{/gist_id}","starred_url":"https://api.github.com/users/4teamwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4teamwork/subscriptions","organizations_url":"https://api.github.com/users/4teamwork/orgs","repos_url":"https://api.github.com/users/4teamwork/repos","events_url":"https://api.github.com/users/4teamwork/events{/privacy}","received_events_url":"https://api.github.com/users/4teamwork/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/4teamwork/opengever.core","description":"OneGov GEVER core package","fork":false,"url":"https://api.github.com/repos/4teamwork/opengever.core","forks_url":"https://api.github.com/repos/4teamwork/opengever.core/forks","keys_url":"https://api.github.com/repos/4teamwork/opengever.core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/4teamwork/opengever.core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/4teamwork/opengever.core/teams","hooks_url":"https://api.github.com/repos/4teamwork/opengever.core/hooks","issue_events_url":"https://api.github.com/repos/4teamwork/opengever.core/issues/events{/number}","events_url":"https://api.github.com/repos/4teamwork/opengever.core/events","assignees_url":"https://api.github.com/repos/4teamwork/opengever.core/assignees{/user}","branches_url":"https://api.github.com/repos/4teamwork/opengever.core/branches{/branch}","tags_url":"https://api.github.com/repos/4teamwork/opengever.core/tags","blobs_url":"https://api.github.com/repos/4teamwork/opengever.core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/4teamwork/opengever.core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/4teamwork/opengever.core/git/refs{/sha}","trees_url":"https://api.github.com/repos/4teamwork/opengever.core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/4teamwork/opengever.core/statuses/{sha}","languages_url":"https://api.github.com/repos/4teamwork/opengever.core/languages","stargazers_url":"https://api.github.com/repos/4teamwork/opengever.core/stargazers","contributors_url":"https://api.github.com/repos/4teamwork/opengever.core/contributors","subscribers_url":"https://api.github.com/repos/4teamwork/opengever.core/subscribers","subscription_url":"https://api.github.com/repos/4teamwork/opengever.core/subscription","commits_url":"https://api.github.com/repos/4teamwork/opengever.core/commits{/sha}","git_commits_url":"https://api.github.com/repos/4teamwork/opengever.core/git/commits{/sha}","comments_url":"https://api.github.com/repos/4teamwork/opengever.core/comments{/number}","issue_comment_url":"https://api.github.com/repos/4teamwork/opengever.core/issues/comments{/number}","contents_url":"https://api.github.com/repos/4teamwork/opengever.core/contents/{+path}","compare_url":"https://api.github.com/repos/4teamwork/opengever.core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/4teamwork/opengever.core/merges","archive_url":"https://api.github.com/repos/4teamwork/opengever.core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/4teamwork/opengever.core/downloads","issues_url":"https://api.github.com/repos/4teamwork/opengever.core/issues{/number}","pulls_url":"https://api.github.com/repos/4teamwork/opengever.core/pulls{/number}","milestones_url":"https://api.github.com/repos/4teamwork/opengever.core/milestones{/number}","notifications_url":"https://api.github.com/repos/4teamwork/opengever.core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/4teamwork/opengever.core/labels{/name}","releases_url":"https://api.github.com/repos/4teamwork/opengever.core/releases{/id}","deployments_url":"https://api.github.com/repos/4teamwork/opengever.core/deployments","created_at":"2013-05-01T08:28:16Z","updated_at":"2016-01-11T16:37:49Z","pushed_at":"2016-04-14T09:11:59Z","git_url":"git://github.com/4teamwork/opengever.core.git","ssh_url":"git@github.com:4teamwork/opengever.core.git","clone_url":"https://github.com/4teamwork/opengever.core.git","svn_url":"https://github.com/4teamwork/opengever.core","homepage":"","size":22956,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":156,"forks":0,"open_issues":156,"watchers":2,"default_branch":"master"}},"base":{"label":"4teamwork:master","ref":"master","sha":"8901fab1958ec20b5bae692a8d17a37d6f0fd317","user":{"login":"4teamwork","id":681821,"avatar_url":"https://avatars.githubusercontent.com/u/681821?v=3","gravatar_id":"","url":"https://api.github.com/users/4teamwork","html_url":"https://github.com/4teamwork","followers_url":"https://api.github.com/users/4teamwork/followers","following_url":"https://api.github.com/users/4teamwork/following{/other_user}","gists_url":"https://api.github.com/users/4teamwork/gists{/gist_id}","starred_url":"https://api.github.com/users/4teamwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4teamwork/subscriptions","organizations_url":"https://api.github.com/users/4teamwork/orgs","repos_url":"https://api.github.com/users/4teamwork/repos","events_url":"https://api.github.com/users/4teamwork/events{/privacy}","received_events_url":"https://api.github.com/users/4teamwork/received_events","type":"Organization","site_admin":false},"repo":{"id":9788097,"name":"opengever.core","full_name":"4teamwork/opengever.core","owner":{"login":"4teamwork","id":681821,"avatar_url":"https://avatars.githubusercontent.com/u/681821?v=3","gravatar_id":"","url":"https://api.github.com/users/4teamwork","html_url":"https://github.com/4teamwork","followers_url":"https://api.github.com/users/4teamwork/followers","following_url":"https://api.github.com/users/4teamwork/following{/other_user}","gists_url":"https://api.github.com/users/4teamwork/gists{/gist_id}","starred_url":"https://api.github.com/users/4teamwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4teamwork/subscriptions","organizations_url":"https://api.github.com/users/4teamwork/orgs","repos_url":"https://api.github.com/users/4teamwork/repos","events_url":"https://api.github.com/users/4teamwork/events{/privacy}","received_events_url":"https://api.github.com/users/4teamwork/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/4teamwork/opengever.core","description":"OneGov GEVER core package","fork":false,"url":"https://api.github.com/repos/4teamwork/opengever.core","forks_url":"https://api.github.com/repos/4teamwork/opengever.core/forks","keys_url":"https://api.github.com/repos/4teamwork/opengever.core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/4teamwork/opengever.core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/4teamwork/opengever.core/teams","hooks_url":"https://api.github.com/repos/4teamwork/opengever.core/hooks","issue_events_url":"https://api.github.com/repos/4teamwork/opengever.core/issues/events{/number}","events_url":"https://api.github.com/repos/4teamwork/opengever.core/events","assignees_url":"https://api.github.com/repos/4teamwork/opengever.core/assignees{/user}","branches_url":"https://api.github.com/repos/4teamwork/opengever.core/branches{/branch}","tags_url":"https://api.github.com/repos/4teamwork/opengever.core/tags","blobs_url":"https://api.github.com/repos/4teamwork/opengever.core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/4teamwork/opengever.core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/4teamwork/opengever.core/git/refs{/sha}","trees_url":"https://api.github.com/repos/4teamwork/opengever.core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/4teamwork/opengever.core/statuses/{sha}","languages_url":"https://api.github.com/repos/4teamwork/opengever.core/languages","stargazers_url":"https://api.github.com/repos/4teamwork/opengever.core/stargazers","contributors_url":"https://api.github.com/repos/4teamwork/opengever.core/contributors","subscribers_url":"https://api.github.com/repos/4teamwork/opengever.core/subscribers","subscription_url":"https://api.github.com/repos/4teamwork/opengever.core/subscription","commits_url":"https://api.github.com/repos/4teamwork/opengever.core/commits{/sha}","git_commits_url":"https://api.github.com/repos/4teamwork/opengever.core/git/commits{/sha}","comments_url":"https://api.github.com/repos/4teamwork/opengever.core/comments{/number}","issue_comment_url":"https://api.github.com/repos/4teamwork/opengever.core/issues/comments{/number}","contents_url":"https://api.github.com/repos/4teamwork/opengever.core/contents/{+path}","compare_url":"https://api.github.com/repos/4teamwork/opengever.core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/4teamwork/opengever.core/merges","archive_url":"https://api.github.com/repos/4teamwork/opengever.core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/4teamwork/opengever.core/downloads","issues_url":"https://api.github.com/repos/4teamwork/opengever.core/issues{/number}","pulls_url":"https://api.github.com/repos/4teamwork/opengever.core/pulls{/number}","milestones_url":"https://api.github.com/repos/4teamwork/opengever.core/milestones{/number}","notifications_url":"https://api.github.com/repos/4teamwork/opengever.core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/4teamwork/opengever.core/labels{/name}","releases_url":"https://api.github.com/repos/4teamwork/opengever.core/releases{/id}","deployments_url":"https://api.github.com/repos/4teamwork/opengever.core/deployments","created_at":"2013-05-01T08:28:16Z","updated_at":"2016-01-11T16:37:49Z","pushed_at":"2016-04-14T09:11:59Z","git_url":"git://github.com/4teamwork/opengever.core.git","ssh_url":"git@github.com:4teamwork/opengever.core.git","clone_url":"https://github.com/4teamwork/opengever.core.git","svn_url":"https://github.com/4teamwork/opengever.core","homepage":"","size":22956,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":156,"forks":0,"open_issues":156,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/4teamwork/opengever.core/pulls/1716"},"html":{"href":"https://github.com/4teamwork/opengever.core/pull/1716"},"issue":{"href":"https://api.github.com/repos/4teamwork/opengever.core/issues/1716"},"comments":{"href":"https://api.github.com/repos/4teamwork/opengever.core/issues/1716/comments"},"review_comments":{"href":"https://api.github.com/repos/4teamwork/opengever.core/pulls/1716/comments"},"review_comment":{"href":"https://api.github.com/repos/4teamwork/opengever.core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/4teamwork/opengever.core/pulls/1716/commits"},"statuses":{"href":"https://api.github.com/repos/4teamwork/opengever.core/statuses/b959eebdb5b25eed11d04b527ff013201ab8cfee"}}}}