{"action":"created","comment":{"url":"https://api.github.com/repos/Parisson/Telemeta/pulls/comments/63614340","id":63614340,"diff_hunk":"@@ -153,12 +153,117 @@ def extra_context(self):\n \n         if self.type == 'item':\n             extra['type'] = 'item'\n-        elif  self.type == 'fonds':\n+        elif self.type == 'fonds':\n             extra['type'] = 'fonds'\n-        elif(self.type == 'corpus'):\n+        elif (self.type == 'corpus'):\n             extra['type'] = 'corpus'\n         else:\n             extra['type'] = 'collection'\n \n         extra['results_page'] = self.results_per_page\n+        extra['booleanForm'] = formset_factory(BooleanSearch, extra=2)\n+        extra['request_url'] = self.requestURL\n         return extra\n+\n+\n+def autocomplete(request):\n+    attribut = request.GET.get('attr', '')\n+    sqs = SearchQuerySet().load_all()\n+    if attribut == \"code\":\n+        sqs = sqs.filter(code__contains=request.GET.get('q', ''))\n+        suggestions = [result.code for result in sqs]\n+\n+    elif attribut == \"collectors\":\n+        sqs = sqs.filter(collectors__startswith=request.GET.get('q', ''))\n+        collecteurs = [result.collectors for result in sqs]\n+        suggestions = []\n+        for chaine in collecteurs:\n+            for word in chaine.split('; '):\n+                if word != \"\" and escapeAccentAndLower(request.GET.get('q', '')) in escapeAccentAndLower(word):\n+                    suggestions.append(word)\n+    elif attribut == \"location\" or attribut == \"instruments\":\n+        sqs = SearchQuerySet().using('autocomplete')\n+\n+        if attribut == \"location\":\n+            sqs = sqs.models(Location, LocationAlias)\n+        else:\n+            sqs = sqs.models(Instrument, InstrumentAlias)\n+        sqs = sqs.filter(content__startswith=request.GET.get('q', ''))\n+        suggestions = [obj.text for obj in sqs]\n+    else:\n+        suggestions = []\n+\n+    if request.GET.get('attr', '') != 'code':\n+        suggestions = list(set([word.strip().lower().title() for word in suggestions]))\n+    else:\n+        suggestions = list(set(suggestions))\n+    suggestions.sort()\n+\n+    the_data = json.dumps({\n+        'results': suggestions\n+    })\n+    return HttpResponse(the_data, content_type='application/json')\n+\n+\n+import unicodedata\n+\n+\n+def escapeAccentAndLower(chaine):\n+    return unicodedata.normalize('NFD', chaine).encode('ascii', 'ignore').lower()\n+\n+\n+class BooleanSearchView(object):\n+    form = formset_factory(BooleanSearch)\n+\n+    def getBooleanQuery(self, request):","path":"telemeta/views/search.py","position":160,"original_position":160,"commit_id":"fe6e2bdb81c245fbebb0d37064f835cd7f9cb600","original_commit_id":"fe6e2bdb81c245fbebb0d37064f835cd7f9cb600","user":{"login":"yomguy","id":135213,"avatar_url":"https://avatars.githubusercontent.com/u/135213?v=3","gravatar_id":"","url":"https://api.github.com/users/yomguy","html_url":"https://github.com/yomguy","followers_url":"https://api.github.com/users/yomguy/followers","following_url":"https://api.github.com/users/yomguy/following{/other_user}","gists_url":"https://api.github.com/users/yomguy/gists{/gist_id}","starred_url":"https://api.github.com/users/yomguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yomguy/subscriptions","organizations_url":"https://api.github.com/users/yomguy/orgs","repos_url":"https://api.github.com/users/yomguy/repos","events_url":"https://api.github.com/users/yomguy/events{/privacy}","received_events_url":"https://api.github.com/users/yomguy/received_events","type":"User","site_admin":false},"body":"lowercase + underscore","created_at":"2016-05-17T22:18:14Z","updated_at":"2016-05-17T22:18:14Z","html_url":"https://github.com/Parisson/Telemeta/pull/113#discussion_r63614340","pull_request_url":"https://api.github.com/repos/Parisson/Telemeta/pulls/113","_links":{"self":{"href":"https://api.github.com/repos/Parisson/Telemeta/pulls/comments/63614340"},"html":{"href":"https://github.com/Parisson/Telemeta/pull/113#discussion_r63614340"},"pull_request":{"href":"https://api.github.com/repos/Parisson/Telemeta/pulls/113"}}},"pull_request":{"url":"https://api.github.com/repos/Parisson/Telemeta/pulls/113","id":70364381,"html_url":"https://github.com/Parisson/Telemeta/pull/113","diff_url":"https://github.com/Parisson/Telemeta/pull/113.diff","patch_url":"https://github.com/Parisson/Telemeta/pull/113.patch","issue_url":"https://api.github.com/repos/Parisson/Telemeta/issues/113","number":113,"state":"open","locked":false,"title":"Improve Search Engine + Playlist","user":{"login":"maths28","id":17071790,"avatar_url":"https://avatars.githubusercontent.com/u/17071790?v=3","gravatar_id":"","url":"https://api.github.com/users/maths28","html_url":"https://github.com/maths28","followers_url":"https://api.github.com/users/maths28/followers","following_url":"https://api.github.com/users/maths28/following{/other_user}","gists_url":"https://api.github.com/users/maths28/gists{/gist_id}","starred_url":"https://api.github.com/users/maths28/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maths28/subscriptions","organizations_url":"https://api.github.com/users/maths28/orgs","repos_url":"https://api.github.com/users/maths28/repos","events_url":"https://api.github.com/users/maths28/events{/privacy}","received_events_url":"https://api.github.com/users/maths28/received_events","type":"User","site_admin":false},"body":"Search Engine (closes #105 ):\r\n     - Modify Mapping ES (change analyzers )\r\n     -Add autocomplete on code, instruments, locations and collectors (indexed in '\"autocomplete\" index for quick autocomplete, start autocomplete at 3 letters)\r\n     - Fix results lists ( fix sort lists with tablesorter )\r\n     -Boolean Query in instruments fields (Advanced Search) (Boolean keywords AND and OR in french for the moment => ET and OU )\r\n    - Fix filters (Online and access with an account, Videos\r\n     -Fix list recorded_from and recorded_to (restricted on used years )\r\n    -Fix display collector + period in results search list\r\n    - Patch haystack for filter __contains (goto https://github.com/maths28/django-haystack/blob/master/haystack/backends/elasticsearch_backend.py)\r\n\r\n\r\nInstruments/Alias : Number of items in relation with instrument + list of items\r\n\r\nPlaylist : - Fix sort list\r\n               - When open \"desk\", all lists are closed\r\n               -when delete a resource in a playlist, that playlist stay open after refresh.\r\n               - Add items to playlist for \"item list\", \"items in collection list' and \"items with instruments/alias list\"\r\n\r\nTraduction : Update locale\r\n\r\n\r\n","created_at":"2016-05-17T14:14:58Z","updated_at":"2016-05-17T22:18:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d1053c48e47b85155ff2c5fde680c29b289daed1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Parisson/Telemeta/pulls/113/commits","review_comments_url":"https://api.github.com/repos/Parisson/Telemeta/pulls/113/comments","review_comment_url":"https://api.github.com/repos/Parisson/Telemeta/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Parisson/Telemeta/issues/113/comments","statuses_url":"https://api.github.com/repos/Parisson/Telemeta/statuses/fe6e2bdb81c245fbebb0d37064f835cd7f9cb600","head":{"label":"maths28:dev","ref":"dev","sha":"fe6e2bdb81c245fbebb0d37064f835cd7f9cb600","user":{"login":"maths28","id":17071790,"avatar_url":"https://avatars.githubusercontent.com/u/17071790?v=3","gravatar_id":"","url":"https://api.github.com/users/maths28","html_url":"https://github.com/maths28","followers_url":"https://api.github.com/users/maths28/followers","following_url":"https://api.github.com/users/maths28/following{/other_user}","gists_url":"https://api.github.com/users/maths28/gists{/gist_id}","starred_url":"https://api.github.com/users/maths28/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maths28/subscriptions","organizations_url":"https://api.github.com/users/maths28/orgs","repos_url":"https://api.github.com/users/maths28/repos","events_url":"https://api.github.com/users/maths28/events{/privacy}","received_events_url":"https://api.github.com/users/maths28/received_events","type":"User","site_admin":false},"repo":{"id":55000476,"name":"Telemeta","full_name":"maths28/Telemeta","owner":{"login":"maths28","id":17071790,"avatar_url":"https://avatars.githubusercontent.com/u/17071790?v=3","gravatar_id":"","url":"https://api.github.com/users/maths28","html_url":"https://github.com/maths28","followers_url":"https://api.github.com/users/maths28/followers","following_url":"https://api.github.com/users/maths28/following{/other_user}","gists_url":"https://api.github.com/users/maths28/gists{/gist_id}","starred_url":"https://api.github.com/users/maths28/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maths28/subscriptions","organizations_url":"https://api.github.com/users/maths28/orgs","repos_url":"https://api.github.com/users/maths28/repos","events_url":"https://api.github.com/users/maths28/events{/privacy}","received_events_url":"https://api.github.com/users/maths28/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maths28/Telemeta","description":"Collaborative multimedia asset management system","fork":true,"url":"https://api.github.com/repos/maths28/Telemeta","forks_url":"https://api.github.com/repos/maths28/Telemeta/forks","keys_url":"https://api.github.com/repos/maths28/Telemeta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maths28/Telemeta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maths28/Telemeta/teams","hooks_url":"https://api.github.com/repos/maths28/Telemeta/hooks","issue_events_url":"https://api.github.com/repos/maths28/Telemeta/issues/events{/number}","events_url":"https://api.github.com/repos/maths28/Telemeta/events","assignees_url":"https://api.github.com/repos/maths28/Telemeta/assignees{/user}","branches_url":"https://api.github.com/repos/maths28/Telemeta/branches{/branch}","tags_url":"https://api.github.com/repos/maths28/Telemeta/tags","blobs_url":"https://api.github.com/repos/maths28/Telemeta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maths28/Telemeta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maths28/Telemeta/git/refs{/sha}","trees_url":"https://api.github.com/repos/maths28/Telemeta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maths28/Telemeta/statuses/{sha}","languages_url":"https://api.github.com/repos/maths28/Telemeta/languages","stargazers_url":"https://api.github.com/repos/maths28/Telemeta/stargazers","contributors_url":"https://api.github.com/repos/maths28/Telemeta/contributors","subscribers_url":"https://api.github.com/repos/maths28/Telemeta/subscribers","subscription_url":"https://api.github.com/repos/maths28/Telemeta/subscription","commits_url":"https://api.github.com/repos/maths28/Telemeta/commits{/sha}","git_commits_url":"https://api.github.com/repos/maths28/Telemeta/git/commits{/sha}","comments_url":"https://api.github.com/repos/maths28/Telemeta/comments{/number}","issue_comment_url":"https://api.github.com/repos/maths28/Telemeta/issues/comments{/number}","contents_url":"https://api.github.com/repos/maths28/Telemeta/contents/{+path}","compare_url":"https://api.github.com/repos/maths28/Telemeta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maths28/Telemeta/merges","archive_url":"https://api.github.com/repos/maths28/Telemeta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maths28/Telemeta/downloads","issues_url":"https://api.github.com/repos/maths28/Telemeta/issues{/number}","pulls_url":"https://api.github.com/repos/maths28/Telemeta/pulls{/number}","milestones_url":"https://api.github.com/repos/maths28/Telemeta/milestones{/number}","notifications_url":"https://api.github.com/repos/maths28/Telemeta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maths28/Telemeta/labels{/name}","releases_url":"https://api.github.com/repos/maths28/Telemeta/releases{/id}","deployments_url":"https://api.github.com/repos/maths28/Telemeta/deployments","created_at":"2016-03-29T18:29:38Z","updated_at":"2016-05-06T18:12:53Z","pushed_at":"2016-05-17T13:25:48Z","git_url":"git://github.com/maths28/Telemeta.git","ssh_url":"git@github.com:maths28/Telemeta.git","clone_url":"https://github.com/maths28/Telemeta.git","svn_url":"https://github.com/maths28/Telemeta","homepage":"http://telemeta.org","size":27332,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"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":"Parisson:dev","ref":"dev","sha":"f93391335f541dac8ad6aa65a63a6effbdcb49c4","user":{"login":"Parisson","id":1722761,"avatar_url":"https://avatars.githubusercontent.com/u/1722761?v=3","gravatar_id":"","url":"https://api.github.com/users/Parisson","html_url":"https://github.com/Parisson","followers_url":"https://api.github.com/users/Parisson/followers","following_url":"https://api.github.com/users/Parisson/following{/other_user}","gists_url":"https://api.github.com/users/Parisson/gists{/gist_id}","starred_url":"https://api.github.com/users/Parisson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Parisson/subscriptions","organizations_url":"https://api.github.com/users/Parisson/orgs","repos_url":"https://api.github.com/users/Parisson/repos","events_url":"https://api.github.com/users/Parisson/events{/privacy}","received_events_url":"https://api.github.com/users/Parisson/received_events","type":"Organization","site_admin":false},"repo":{"id":2642511,"name":"Telemeta","full_name":"Parisson/Telemeta","owner":{"login":"Parisson","id":1722761,"avatar_url":"https://avatars.githubusercontent.com/u/1722761?v=3","gravatar_id":"","url":"https://api.github.com/users/Parisson","html_url":"https://github.com/Parisson","followers_url":"https://api.github.com/users/Parisson/followers","following_url":"https://api.github.com/users/Parisson/following{/other_user}","gists_url":"https://api.github.com/users/Parisson/gists{/gist_id}","starred_url":"https://api.github.com/users/Parisson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Parisson/subscriptions","organizations_url":"https://api.github.com/users/Parisson/orgs","repos_url":"https://api.github.com/users/Parisson/repos","events_url":"https://api.github.com/users/Parisson/events{/privacy}","received_events_url":"https://api.github.com/users/Parisson/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Parisson/Telemeta","description":"Collaborative multimedia asset management system","fork":false,"url":"https://api.github.com/repos/Parisson/Telemeta","forks_url":"https://api.github.com/repos/Parisson/Telemeta/forks","keys_url":"https://api.github.com/repos/Parisson/Telemeta/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Parisson/Telemeta/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Parisson/Telemeta/teams","hooks_url":"https://api.github.com/repos/Parisson/Telemeta/hooks","issue_events_url":"https://api.github.com/repos/Parisson/Telemeta/issues/events{/number}","events_url":"https://api.github.com/repos/Parisson/Telemeta/events","assignees_url":"https://api.github.com/repos/Parisson/Telemeta/assignees{/user}","branches_url":"https://api.github.com/repos/Parisson/Telemeta/branches{/branch}","tags_url":"https://api.github.com/repos/Parisson/Telemeta/tags","blobs_url":"https://api.github.com/repos/Parisson/Telemeta/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Parisson/Telemeta/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Parisson/Telemeta/git/refs{/sha}","trees_url":"https://api.github.com/repos/Parisson/Telemeta/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Parisson/Telemeta/statuses/{sha}","languages_url":"https://api.github.com/repos/Parisson/Telemeta/languages","stargazers_url":"https://api.github.com/repos/Parisson/Telemeta/stargazers","contributors_url":"https://api.github.com/repos/Parisson/Telemeta/contributors","subscribers_url":"https://api.github.com/repos/Parisson/Telemeta/subscribers","subscription_url":"https://api.github.com/repos/Parisson/Telemeta/subscription","commits_url":"https://api.github.com/repos/Parisson/Telemeta/commits{/sha}","git_commits_url":"https://api.github.com/repos/Parisson/Telemeta/git/commits{/sha}","comments_url":"https://api.github.com/repos/Parisson/Telemeta/comments{/number}","issue_comment_url":"https://api.github.com/repos/Parisson/Telemeta/issues/comments{/number}","contents_url":"https://api.github.com/repos/Parisson/Telemeta/contents/{+path}","compare_url":"https://api.github.com/repos/Parisson/Telemeta/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Parisson/Telemeta/merges","archive_url":"https://api.github.com/repos/Parisson/Telemeta/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Parisson/Telemeta/downloads","issues_url":"https://api.github.com/repos/Parisson/Telemeta/issues{/number}","pulls_url":"https://api.github.com/repos/Parisson/Telemeta/pulls{/number}","milestones_url":"https://api.github.com/repos/Parisson/Telemeta/milestones{/number}","notifications_url":"https://api.github.com/repos/Parisson/Telemeta/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Parisson/Telemeta/labels{/name}","releases_url":"https://api.github.com/repos/Parisson/Telemeta/releases{/id}","deployments_url":"https://api.github.com/repos/Parisson/Telemeta/deployments","created_at":"2011-10-25T10:03:13Z","updated_at":"2016-05-14T09:41:58Z","pushed_at":"2016-05-17T14:14:58Z","git_url":"git://github.com/Parisson/Telemeta.git","ssh_url":"git@github.com:Parisson/Telemeta.git","clone_url":"https://github.com/Parisson/Telemeta.git","svn_url":"https://github.com/Parisson/Telemeta","homepage":"http://telemeta.org","size":27544,"stargazers_count":31,"watchers_count":31,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":17,"mirror_url":null,"open_issues_count":40,"forks":17,"open_issues":40,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Parisson/Telemeta/pulls/113"},"html":{"href":"https://github.com/Parisson/Telemeta/pull/113"},"issue":{"href":"https://api.github.com/repos/Parisson/Telemeta/issues/113"},"comments":{"href":"https://api.github.com/repos/Parisson/Telemeta/issues/113/comments"},"review_comments":{"href":"https://api.github.com/repos/Parisson/Telemeta/pulls/113/comments"},"review_comment":{"href":"https://api.github.com/repos/Parisson/Telemeta/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Parisson/Telemeta/pulls/113/commits"},"statuses":{"href":"https://api.github.com/repos/Parisson/Telemeta/statuses/fe6e2bdb81c245fbebb0d37064f835cd7f9cb600"}}}}