From cf064e4198a58c57da5f5b8917d5b89fe9cf6912 Mon Sep 17 00:00:00 2001 From: Pavlov Ivan Date: Sat, 10 May 2014 15:26:35 +0400 Subject: [PATCH] fixed crashes with empty database --- handlers/recalc_rating_handler.py | 1 + handlers/statistics/word_statistics_handler.py | 3 ++- templates/statistics/total_statistic.html | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/handlers/recalc_rating_handler.py b/handlers/recalc_rating_handler.py index 1db9040..a9af1d2 100644 --- a/handlers/recalc_rating_handler.py +++ b/handlers/recalc_rating_handler.py @@ -38,6 +38,7 @@ def get_date(time): class AddGameHandler(ServiceRequestHandler): ratings = [] + @staticmethod def check_word(word): if GlobalDictionaryWord.get(word) is None: diff --git a/handlers/statistics/word_statistics_handler.py b/handlers/statistics/word_statistics_handler.py index 7ca24ba..9ae7ee6 100644 --- a/handlers/statistics/word_statistics_handler.py +++ b/handlers/statistics/word_statistics_handler.py @@ -39,5 +39,6 @@ def get(self, *args, **kwargs): rand = q.fetch(limit=10, offset=randint(0, c-10)) self.draw_page('statistics/word_statistic', word=word, word_entity=entity, - top=top, bottom=bottom, rand=rand, danger=danger_top) + top=top if top else [], bottom=bottom if bottom else [], rand=rand if rand else [], + danger=danger_top if danger_top else []) diff --git a/templates/statistics/total_statistic.html b/templates/statistics/total_statistic.html index 646d493..fb8ea72 100644 --- a/templates/statistics/total_statistic.html +++ b/templates/statistics/total_statistic.html @@ -337,10 +337,11 @@

В нашем словаре содержится {{ label(words_in_dictionary, "слово", "слова", "слов") }}. Из них {{ used_words }} когда-либо объяснялось нашими пользователями.

- + {% if longest_time %}

Дольше всего наши пользователи объясняли слово "{{ longest_word }}": {{ time(longest_time) }}

+ {% endif %}