{"action":"created","comment":{"url":"https://api.github.com/repos/OCA/website/pulls/comments/45444410","id":45444410,"diff_hunk":"@@ -0,0 +1,155 @@\n+# -*- coding: utf-8 -*-\n+##############################################################################\n+#\n+#     This file is part of website_hr_contact, an Odoo module.\n+#\n+#     Copyright (c) 2015 ACSONE SA/NV (<http://acsone.eu>)\n+#\n+#     website_hr_contact is free software: you can redistribute it and/or\n+#     modify it under the terms of the GNU Affero General Public License\n+#     as published by the Free Software Foundation, either version 3 of\n+#     the License, or (at your option) any later version.\n+#\n+#     website_hr_contact is distributed in the hope that it will be useful,\n+#     but WITHOUT ANY WARRANTY; without even the implied warranty of\n+#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+#     GNU Affero General Public License for more details.\n+#\n+#     You should have received a copy of the\n+#     GNU Affero General Public License\n+#     along with website_hr_contact.\n+#     If not, see <http://www.gnu.org/licenses/>.\n+#\n+##############################################################################\n+\n+import werkzeug\n+\n+from openerp import http\n+from openerp.addons.website.models.website import slug\n+from openerp.osv.orm import browse_record\n+\n+\n+class QueryURL(object):\n+    def __init__(self, path='', path_args=None, **args):\n+        self.path = path\n+        self.args = args\n+        self.path_args = set(path_args or [])\n+\n+    def __call__(self, path=None, path_args=None, **kw):\n+        path = path or self.path\n+        for k, v in self.args.items():\n+            kw.setdefault(k, v)\n+        path_args = set(path_args or []).union(self.path_args)\n+        paths, fragments = [], []\n+        for key, value in kw.items():\n+            if value and key in path_args:\n+                if isinstance(value, browse_record):\n+                    paths.append((key, slug(value)))\n+                else:\n+                    paths.append((key, value))\n+            elif value:\n+                if isinstance(value, list) or isinstance(value, set):\n+                    fragments.append(\n+                        werkzeug.url_encode([(key, item) for item in value]))\n+                else:\n+                    fragments.append(werkzeug.url_encode([(key, value)]))\n+        for key, value in paths:\n+            path += '/' + key + '/%s' % value\n+        if fragments:\n+            path += '?' + '&'.join(fragments)\n+        return path\n+\n+\n+class WebsiteHrAddressbook(http.Controller):\n+    _items_per_page = 20\n+\n+    def _get_children_department_recursive(self, root, visible_departments):\n+        tree = []\n+        for department in root.child_ids:\n+            children = self._get_children_department_recursive(\n+                department, visible_departments)\n+            if department in visible_departments:\n+                tree.append({\n+                    'department': visible_departments.filtered(\n+                        lambda rec: rec.id == department.id),\n+                    'children': children\n+                    })\n+            else:\n+                tree.extend(children)\n+        return tree\n+\n+    def _get_departments_tree(self, department=None, search=None, **post):\n+        \"\"\" Build a department tree with only published departments\n+        The tree only contains published department even if the parent\n+        department is not published.\n+        \"\"\"\n+        tree = []\n+        request = http.request\n+        hr_department = request.env['hr.department']\n+        sudo_hr_department = hr_department.sudo()\n+        visible_departments = hr_department.search([(1, '=', 1)])\n+        departments = sudo_hr_department.search([('parent_id', '=', False)])\n+        for department in departments:\n+            children = self._get_children_department_recursive(\n+                department, visible_departments)\n+            if department in visible_departments:\n+                tree.append({\n+                    'department': visible_departments.filtered(\n+                        lambda rec: rec.id == department.id),","path":"website_hr_contact/controllers/main.py","position":98,"original_position":98,"commit_id":"80e670463415386f1791793574f2b0589e8faeb5","original_commit_id":"80e670463415386f1791793574f2b0589e8faeb5","user":{"login":"lmignon","id":544090,"avatar_url":"https://avatars.githubusercontent.com/u/544090?v=3","gravatar_id":"","url":"https://api.github.com/users/lmignon","html_url":"https://github.com/lmignon","followers_url":"https://api.github.com/users/lmignon/followers","following_url":"https://api.github.com/users/lmignon/following{/other_user}","gists_url":"https://api.github.com/users/lmignon/gists{/gist_id}","starred_url":"https://api.github.com/users/lmignon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmignon/subscriptions","organizations_url":"https://api.github.com/users/lmignon/orgs","repos_url":"https://api.github.com/users/lmignon/repos","events_url":"https://api.github.com/users/lmignon/events{/privacy}","received_events_url":"https://api.github.com/users/lmignon/received_events","type":"User","site_admin":false},"body":"@andreparames good catch","created_at":"2015-11-20T08:15:49Z","updated_at":"2015-11-20T08:15:49Z","html_url":"https://github.com/OCA/website/pull/82#discussion_r45444410","pull_request_url":"https://api.github.com/repos/OCA/website/pulls/82","_links":{"self":{"href":"https://api.github.com/repos/OCA/website/pulls/comments/45444410"},"html":{"href":"https://github.com/OCA/website/pull/82#discussion_r45444410"},"pull_request":{"href":"https://api.github.com/repos/OCA/website/pulls/82"}}},"pull_request":{"url":"https://api.github.com/repos/OCA/website/pulls/82","id":46790265,"html_url":"https://github.com/OCA/website/pull/82","diff_url":"https://github.com/OCA/website/pull/82.diff","patch_url":"https://github.com/OCA/website/pull/82.patch","issue_url":"https://api.github.com/repos/OCA/website/issues/82","number":82,"state":"open","locked":false,"title":"New module displaying the address book of your employees in the website","user":{"login":"lmignon","id":544090,"avatar_url":"https://avatars.githubusercontent.com/u/544090?v=3","gravatar_id":"","url":"https://api.github.com/users/lmignon","html_url":"https://github.com/lmignon","followers_url":"https://api.github.com/users/lmignon/followers","following_url":"https://api.github.com/users/lmignon/following{/other_user}","gists_url":"https://api.github.com/users/lmignon/gists{/gist_id}","starred_url":"https://api.github.com/users/lmignon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmignon/subscriptions","organizations_url":"https://api.github.com/users/lmignon/orgs","repos_url":"https://api.github.com/users/lmignon/repos","events_url":"https://api.github.com/users/lmignon/events{/privacy}","received_events_url":"https://api.github.com/users/lmignon/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-05T14:51:03Z","updated_at":"2015-11-20T08:15:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0c7063f2fc259873f09b366ea1d012a4b17c5e17","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OCA/website/pulls/82/commits","review_comments_url":"https://api.github.com/repos/OCA/website/pulls/82/comments","review_comment_url":"https://api.github.com/repos/OCA/website/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OCA/website/issues/82/comments","statuses_url":"https://api.github.com/repos/OCA/website/statuses/80e670463415386f1791793574f2b0589e8faeb5","head":{"label":"acsone:8.0-add-website_hr_cotnact-lmi","ref":"8.0-add-website_hr_cotnact-lmi","sha":"80e670463415386f1791793574f2b0589e8faeb5","user":{"login":"acsone","id":7601056,"avatar_url":"https://avatars.githubusercontent.com/u/7601056?v=3","gravatar_id":"","url":"https://api.github.com/users/acsone","html_url":"https://github.com/acsone","followers_url":"https://api.github.com/users/acsone/followers","following_url":"https://api.github.com/users/acsone/following{/other_user}","gists_url":"https://api.github.com/users/acsone/gists{/gist_id}","starred_url":"https://api.github.com/users/acsone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acsone/subscriptions","organizations_url":"https://api.github.com/users/acsone/orgs","repos_url":"https://api.github.com/users/acsone/repos","events_url":"https://api.github.com/users/acsone/events{/privacy}","received_events_url":"https://api.github.com/users/acsone/received_events","type":"Organization","site_admin":false},"repo":{"id":29392738,"name":"website","full_name":"acsone/website","owner":{"login":"acsone","id":7601056,"avatar_url":"https://avatars.githubusercontent.com/u/7601056?v=3","gravatar_id":"","url":"https://api.github.com/users/acsone","html_url":"https://github.com/acsone","followers_url":"https://api.github.com/users/acsone/followers","following_url":"https://api.github.com/users/acsone/following{/other_user}","gists_url":"https://api.github.com/users/acsone/gists{/gist_id}","starred_url":"https://api.github.com/users/acsone/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acsone/subscriptions","organizations_url":"https://api.github.com/users/acsone/orgs","repos_url":"https://api.github.com/users/acsone/repos","events_url":"https://api.github.com/users/acsone/events{/privacy}","received_events_url":"https://api.github.com/users/acsone/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/acsone/website","description":"","fork":true,"url":"https://api.github.com/repos/acsone/website","forks_url":"https://api.github.com/repos/acsone/website/forks","keys_url":"https://api.github.com/repos/acsone/website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/acsone/website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/acsone/website/teams","hooks_url":"https://api.github.com/repos/acsone/website/hooks","issue_events_url":"https://api.github.com/repos/acsone/website/issues/events{/number}","events_url":"https://api.github.com/repos/acsone/website/events","assignees_url":"https://api.github.com/repos/acsone/website/assignees{/user}","branches_url":"https://api.github.com/repos/acsone/website/branches{/branch}","tags_url":"https://api.github.com/repos/acsone/website/tags","blobs_url":"https://api.github.com/repos/acsone/website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/acsone/website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/acsone/website/git/refs{/sha}","trees_url":"https://api.github.com/repos/acsone/website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/acsone/website/statuses/{sha}","languages_url":"https://api.github.com/repos/acsone/website/languages","stargazers_url":"https://api.github.com/repos/acsone/website/stargazers","contributors_url":"https://api.github.com/repos/acsone/website/contributors","subscribers_url":"https://api.github.com/repos/acsone/website/subscribers","subscription_url":"https://api.github.com/repos/acsone/website/subscription","commits_url":"https://api.github.com/repos/acsone/website/commits{/sha}","git_commits_url":"https://api.github.com/repos/acsone/website/git/commits{/sha}","comments_url":"https://api.github.com/repos/acsone/website/comments{/number}","issue_comment_url":"https://api.github.com/repos/acsone/website/issues/comments{/number}","contents_url":"https://api.github.com/repos/acsone/website/contents/{+path}","compare_url":"https://api.github.com/repos/acsone/website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/acsone/website/merges","archive_url":"https://api.github.com/repos/acsone/website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/acsone/website/downloads","issues_url":"https://api.github.com/repos/acsone/website/issues{/number}","pulls_url":"https://api.github.com/repos/acsone/website/pulls{/number}","milestones_url":"https://api.github.com/repos/acsone/website/milestones{/number}","notifications_url":"https://api.github.com/repos/acsone/website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/acsone/website/labels{/name}","releases_url":"https://api.github.com/repos/acsone/website/releases{/id}","created_at":"2015-01-17T13:58:14Z","updated_at":"2015-04-20T07:45:38Z","pushed_at":"2015-11-11T17:07:25Z","git_url":"git://github.com/acsone/website.git","ssh_url":"git@github.com:acsone/website.git","clone_url":"https://github.com/acsone/website.git","svn_url":"https://github.com/acsone/website","homepage":null,"size":4837,"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":"8.0"}},"base":{"label":"OCA:8.0","ref":"8.0","sha":"bb2964188c194aaf2ef3645f68fa771043712fc9","user":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"repo":{"id":21942491,"name":"website","full_name":"OCA/website","owner":{"login":"OCA","id":7600578,"avatar_url":"https://avatars.githubusercontent.com/u/7600578?v=3","gravatar_id":"","url":"https://api.github.com/users/OCA","html_url":"https://github.com/OCA","followers_url":"https://api.github.com/users/OCA/followers","following_url":"https://api.github.com/users/OCA/following{/other_user}","gists_url":"https://api.github.com/users/OCA/gists{/gist_id}","starred_url":"https://api.github.com/users/OCA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OCA/subscriptions","organizations_url":"https://api.github.com/users/OCA/orgs","repos_url":"https://api.github.com/users/OCA/repos","events_url":"https://api.github.com/users/OCA/events{/privacy}","received_events_url":"https://api.github.com/users/OCA/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OCA/website","description":"Odoo website builder addons","fork":false,"url":"https://api.github.com/repos/OCA/website","forks_url":"https://api.github.com/repos/OCA/website/forks","keys_url":"https://api.github.com/repos/OCA/website/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OCA/website/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OCA/website/teams","hooks_url":"https://api.github.com/repos/OCA/website/hooks","issue_events_url":"https://api.github.com/repos/OCA/website/issues/events{/number}","events_url":"https://api.github.com/repos/OCA/website/events","assignees_url":"https://api.github.com/repos/OCA/website/assignees{/user}","branches_url":"https://api.github.com/repos/OCA/website/branches{/branch}","tags_url":"https://api.github.com/repos/OCA/website/tags","blobs_url":"https://api.github.com/repos/OCA/website/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OCA/website/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OCA/website/git/refs{/sha}","trees_url":"https://api.github.com/repos/OCA/website/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OCA/website/statuses/{sha}","languages_url":"https://api.github.com/repos/OCA/website/languages","stargazers_url":"https://api.github.com/repos/OCA/website/stargazers","contributors_url":"https://api.github.com/repos/OCA/website/contributors","subscribers_url":"https://api.github.com/repos/OCA/website/subscribers","subscription_url":"https://api.github.com/repos/OCA/website/subscription","commits_url":"https://api.github.com/repos/OCA/website/commits{/sha}","git_commits_url":"https://api.github.com/repos/OCA/website/git/commits{/sha}","comments_url":"https://api.github.com/repos/OCA/website/comments{/number}","issue_comment_url":"https://api.github.com/repos/OCA/website/issues/comments{/number}","contents_url":"https://api.github.com/repos/OCA/website/contents/{+path}","compare_url":"https://api.github.com/repos/OCA/website/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OCA/website/merges","archive_url":"https://api.github.com/repos/OCA/website/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OCA/website/downloads","issues_url":"https://api.github.com/repos/OCA/website/issues{/number}","pulls_url":"https://api.github.com/repos/OCA/website/pulls{/number}","milestones_url":"https://api.github.com/repos/OCA/website/milestones{/number}","notifications_url":"https://api.github.com/repos/OCA/website/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OCA/website/labels{/name}","releases_url":"https://api.github.com/repos/OCA/website/releases{/id}","created_at":"2014-07-17T13:16:54Z","updated_at":"2015-11-13T20:10:18Z","pushed_at":"2015-11-20T06:41:14Z","git_url":"git://github.com/OCA/website.git","ssh_url":"git@github.com:OCA/website.git","clone_url":"https://github.com/OCA/website.git","svn_url":"https://github.com/OCA/website","homepage":"","size":11455,"stargazers_count":25,"watchers_count":25,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":97,"mirror_url":null,"open_issues_count":43,"forks":97,"open_issues":43,"watchers":25,"default_branch":"9.0"}},"_links":{"self":{"href":"https://api.github.com/repos/OCA/website/pulls/82"},"html":{"href":"https://github.com/OCA/website/pull/82"},"issue":{"href":"https://api.github.com/repos/OCA/website/issues/82"},"comments":{"href":"https://api.github.com/repos/OCA/website/issues/82/comments"},"review_comments":{"href":"https://api.github.com/repos/OCA/website/pulls/82/comments"},"review_comment":{"href":"https://api.github.com/repos/OCA/website/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OCA/website/pulls/82/commits"},"statuses":{"href":"https://api.github.com/repos/OCA/website/statuses/80e670463415386f1791793574f2b0589e8faeb5"}}}}