From 706fc1fd9b83364ba7cd83c6f61488dbb1979ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20=C3=81lvarez?= Date: Wed, 8 Jan 2014 09:09:56 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20para=20bucle=20infinito=20cuando=20no=20h?= =?UTF-8?q?ay=20palabras=20en=20Redis,=20y=20cuenta=20de=20twitter=20a?= =?UTF-8?q?=C3=B1adida=20al=20pie=20de=20p=C3=A1gina?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- home/views.py | 13 +++++++------ silabas/settings.py | 4 ++-- templates/base.html | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/home/views.py b/home/views.py index 377a4a1..c7e13d7 100644 --- a/home/views.py +++ b/home/views.py @@ -56,7 +56,7 @@ def index(request): else: sform = SilabasForm(initial={'texto': ''}) - + if request.method == 'POST': cform = ContactForm(request.POST) if cform.is_valid(): @@ -64,19 +64,20 @@ def index(request): else: cform = ContactForm(initial={'message': '', 'sender': ''}) - + response['sform'] = sform response['cform'] = cform response['randoms'] = set() - while len(response['randoms']) < 15: + silabas_all_len = r.scard("silabas:all") + while len(response['randoms']) < 15 and silabas_all_len > len(response['randoms']): response['randoms'].add( r.srandmember("silabas:all") ) - + response['mostused'] = r.zrevrange("silabas:mostused", 0, 14) if 'lista_silabas' in response and len(response['lista_silabas']) == 1: response['title'] = response['lista_silabas'][0] - + response.update(csrf(request)) - + return render_to_response('home/index.html', response) diff --git a/silabas/settings.py b/silabas/settings.py index f0f1e20..284a77f 100644 --- a/silabas/settings.py +++ b/silabas/settings.py @@ -71,7 +71,7 @@ STATICFILES_DIRS = ( # Put strings here, like "/home/html/static" or "C:/www/django/static". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. - '/home/salvarez/www/silabas/public/static', + '/home/salvarez/www/silabas.xrg.es/public/static', ) # List of finder classes that know how to find static files in @@ -108,7 +108,7 @@ ROOT_URLCONF = 'silabas.urls' WSGI_APPLICATION = 'silabas.wsgi.application' TEMPLATE_DIRS = ( - '/home/salvarez/www/silabas/templates' + '/home/salvarez/www/silabas.xrg.es/templates' # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. diff --git a/templates/base.html b/templates/base.html index 37b76a4..651aa3a 100644 --- a/templates/base.html +++ b/templates/base.html @@ -14,11 +14,11 @@