From 203a21fdda4609a610c3b4242b6c8057d30c42ff Mon Sep 17 00:00:00 2001 From: Alexander Kondratyev Date: Wed, 8 Mar 2017 00:17:26 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B2=20=D1=84=D0=BE=D0=BD=D0=B5=20=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D0=BD=20=D1=80=D0=B0=D0=B7=20=D0=BF=D1=80=D0=B8=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=81=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/deploy/hosts.py | 2 +- trademark/views.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/deploy/hosts.py b/app/deploy/hosts.py index fec0139..f6dfea3 100644 --- a/app/deploy/hosts.py +++ b/app/deploy/hosts.py @@ -9,7 +9,7 @@ class WebHost(SSHHost): slug = 'web' address = '151.248.125.130' username = 'web' - password = '9oijffDf2vi@D!' + password = '0cg@XA$b$h8LKQf' class DatabaseHost(WebHost): slug = 'database' diff --git a/trademark/views.py b/trademark/views.py index 0c9f88a..f7c2149 100644 --- a/trademark/views.py +++ b/trademark/views.py @@ -93,7 +93,9 @@ class SearchResultsThread(threading.Thread): super(SearchResultsThread, self).__init__(**kwargs) def run(self): - self.keyword.load_results() + loaded = false + while not loaded: + loaded = self.keyword.load_results() class Search(generic.View): @@ -104,10 +106,6 @@ class Search(generic.View): def get(self, request, slug): keyword = get_object_or_404(Keyword, slug=slug) - loading = SearchResultsThread(keyword=keyword) - loading.start() - - identity = keyword.searches.filter(similarity=146)[0] contains = keyword.searches.filter(similarity=100)[0] @@ -145,6 +143,9 @@ class Search(generic.View): else: return HttpResponse(json.dumps({ 'status': 'error', 'description': 'Empty request'}), content_type="application/json") + loading = SearchResultsThread(keyword=keyword) + loading.start() + identity = k.searches.filter(similarity=146)[0] contains = k.searches.filter(similarity=100)[0] @@ -172,6 +173,8 @@ class Search(generic.View): 'status': 'ok' } + + return HttpResponse(json.dumps(response), content_type="application/json")