# HG changeset patch # User neko259 # Date 2014-06-15 09:40:00 # Node ID a8dffe4798b4cc135a384cea6f68355e1ecd29cb # Parent 3d81370eec799a17d105500c19410cfa51b395ba Implemented search over posts. Moved get_user and get_theme to utils module. Use context processors instead of creating context in the base view. Removed unused imports in some modules diff --git a/boards/context_processors.py b/boards/context_processors.py new file mode 100644 --- /dev/null +++ b/boards/context_processors.py @@ -0,0 +1,31 @@ +from boards import utils +from boards.models import Post +from boards.models.post import SETTING_MODERATE +import neboard + +__author__ = 'neko259' + + +def user_and_ui_processor(request): + context = {} + + user = utils.get_user(request) + context['user'] = user + context['tags'] = user.fav_tags.all() + context['posts_per_day'] = float(Post.objects.get_posts_per_day()) + + theme = utils.get_theme(request, user) + context['theme'] = theme + context['theme_css'] = 'css/' + theme + '/base_page.css' + + # This shows the moderator panel + moderate = user.get_setting(SETTING_MODERATE) + if moderate == 'True': + context['moderator'] = user.is_moderator() + else: + context['moderator'] = False + + context['version'] = neboard.settings.VERSION + context['site_name'] = neboard.settings.SITE_NAME + + return context \ No newline at end of file diff --git a/boards/locale/ru/LC_MESSAGES/django.mo b/boards/locale/ru/LC_MESSAGES/django.mo index 2b736cfb530f4f34f3b2a4013788800385e7cc59..782ec18751bb3beec2ca0120c7c64b8cbe958db3 GIT binary patch literal 7091 zc$|$_eQ;D)6~DEuB}*^?0u-?A#TJCNyUhk#=|X@&5{OMg%7)g~QRZd$C3&!UZ~NZc z(9E9mlu!AMH4ft&Wc4*NjfJ{-O1E?zwMw z3Crk%eZP0_J@?%6@jK_e{A$@vUlh1Lf!~Mm`{f6Ocn0|L%|cx-+#qdwe~jA)fp2Pj3s?bs8@L+yM=f{rA|aLnmn>qrJAf;I8-OBnus`3^;~xPdz@O^*xAb{$>vR5E!SQ%kkN*v< z0^S(meaj=P=k^Hizca#q-mP&nFhTK(aK4U4Sl{yzw)^D>=j+=Mw)ZDm&o6*C0)HK0 zzkaLF`8#ks@VyAzbN^zV-v-w7?t zTYxKp4+AgXAVe>)31e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EgaVulMWe1%<9 zQ%W1MbnP3YyyI%>oO)~P`qo8zq0qT6l*X~3HM9?Kt^rR)#uynN5rf3?ub+%^#_`opF0SvITQ5DPxb$|sV% zol%{s&~#N#)1NQ+jS<@mA8x@&O#2D$pA5gOu6YL}cx7C97Y2mhy;oFv2ZWrwUf?uLFtK9A+8&qr z&+(T6ed(4Is3f=4hsQ`5yONHtT5EzLHJuAu{Wbvi!K}(L^_j(8)t8%e3Ra Dm>ZIb diff --git a/boards/locale/ru/LC_MESSAGES/django.po b/boards/locale/ru/LC_MESSAGES/django.po --- a/boards/locale/ru/LC_MESSAGES/django.po +++ b/boards/locale/ru/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-08 21:35+0300\n" +"POT-Creation-Date: 2014-06-15 12:34+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -98,27 +98,27 @@ msgstr "Подождите %s секунд после последнего постинга" msgid "Tags" msgstr "Теги" -#: forms.py:225 forms.py:344 +#: forms.py:224 forms.py:343 msgid "Inappropriate characters in tags." msgstr "Недопустимые символы в тегах." -#: forms.py:253 forms.py:274 +#: forms.py:252 forms.py:273 msgid "Captcha validation failed" msgstr "Проверка капчи провалена" -#: forms.py:280 +#: forms.py:279 msgid "Theme" msgstr "Тема" -#: forms.py:285 +#: forms.py:284 msgid "Enable moderation panel" msgstr "Включить панель модерации" -#: forms.py:300 +#: forms.py:299 msgid "No such user found" msgstr "Данный пользователь не найден" -#: forms.py:314 +#: forms.py:313 #, python-format msgid "Wait %s minutes after last login" msgstr "Подождите %s минут после последнего входа" @@ -147,41 +147,41 @@ msgstr "лицензией" msgid "Repository" msgstr "Репозиторий" -#: templates/boards/base.html:14 +#: templates/boards/base.html:11 msgid "Feed" msgstr "Лента" -#: templates/boards/base.html:31 +#: templates/boards/base.html:28 msgid "All threads" msgstr "Все темы" -#: templates/boards/base.html:36 +#: templates/boards/base.html:33 msgid "Tag management" msgstr "Управление тегами" -#: templates/boards/base.html:38 templates/boards/settings.html:7 +#: templates/boards/base.html:35 templates/boards/settings.html:7 msgid "Settings" msgstr "Настройки" -#: templates/boards/base.html:50 templates/boards/login.html:6 -#: templates/boards/login.html.py:21 +#: templates/boards/base.html:47 templates/boards/login.html:6 +#: templates/boards/login.html.py:16 msgid "Login" msgstr "Вход" -#: templates/boards/base.html:52 +#: templates/boards/base.html:48 +msgid "Search" +msgstr "Поиск" + +#: templates/boards/base.html:50 #, python-format msgid "Speed: %(ppd)s posts per day" msgstr "Скорость: %(ppd)s сообщений в день" -#: templates/boards/base.html:54 +#: templates/boards/base.html:52 msgid "Up" msgstr "Вверх" -#: templates/boards/login.html:15 -msgid "User ID" -msgstr "ID пользователя" - -#: templates/boards/login.html:24 +#: templates/boards/login.html:19 msgid "Insert your user id above" msgstr "Вставьте свой ID пользователя выше" @@ -386,5 +386,5 @@ msgstr "Перед этими тегами нужна новая строка:" msgid "Comment" msgstr "Комментарий" -#~ msgid "Archive" -#~ msgstr "Архив" +#~ msgid "User ID" +#~ msgstr "ID пользователя" diff --git a/boards/middlewares.py b/boards/middlewares.py --- a/boards/middlewares.py +++ b/boards/middlewares.py @@ -1,8 +1,9 @@ from django.shortcuts import redirect -from boards import views, utils +from boards import utils from boards.models import Ban from django.utils.html import strip_spaces_between_tags from django.conf import settings +from boards.views.banned import BannedView RESPONSE_CONTENT_TYPE = 'Content-Type' @@ -17,7 +18,7 @@ class BanMiddleware: def process_view(self, request, view_func, view_args, view_kwargs): - if view_func != views.banned.BannedView.as_view: + if view_func != BannedView.as_view: ip = utils.get_client_ip(request) bans = Ban.objects.filter(ip=ip) diff --git a/boards/search_indexes.py b/boards/search_indexes.py new file mode 100644 --- /dev/null +++ b/boards/search_indexes.py @@ -0,0 +1,14 @@ +from haystack import indexes +from boards.models import Post + +__author__ = 'neko259' + + +class PostIndex(indexes.SearchIndex, indexes.Indexable): + text = indexes.CharField(document=True, use_template=True) + + def get_model(self): + return Post + + def index_queryset(self, using=None): + return self.get_model().objects.all() \ No newline at end of file diff --git a/boards/templates/boards/base.html b/boards/templates/boards/base.html --- a/boards/templates/boards/base.html +++ b/boards/templates/boards/base.html @@ -6,12 +6,9 @@ - - - + + + @@ -48,6 +45,7 @@