# HG changeset patch # User neko259 # Date 2015-03-30 15:45:19 # Node ID eb6bb3e8ae57ff05fba6bd145ec57590e9e32db1 # Parent da5d56ec73c8782a547bb81bdaeeb9c720495ea1 Added timezone support (time zone is selected in settings) diff --git a/boards/forms.py b/boards/forms.py --- a/boards/forms.py +++ b/boards/forms.py @@ -1,5 +1,6 @@ import re import time +import pytz from django import forms from django.core.files.uploadedfile import SimpleUploadedFile @@ -47,6 +48,13 @@ HTTP_RESULT_OK = 200 TEXTAREA_ROWS = 4 +def get_timezones(): + timezones = [] + for tz in pytz.common_timezones: + timezones.append((tz, tz),) + return timezones + + class FormatPanel(forms.Textarea): """ Panel for text formatting. Consists of buttons to add different tags to the @@ -321,9 +329,9 @@ class ThreadForm(PostForm): class SettingsForm(NeboardForm): - theme = forms.ChoiceField(choices=settings.THEMES, - label=_('Theme')) + theme = forms.ChoiceField(choices=settings.THEMES, label=_('Theme')) username = forms.CharField(label=_('User name'), required=False) + timezone = forms.ChoiceField(choices=get_timezones(), label=_('Time zone')) def clean_username(self): username = self.cleaned_data['username'] diff --git a/boards/locale/ru/LC_MESSAGES/django.mo b/boards/locale/ru/LC_MESSAGES/django.mo index 34c16f9e0e0a9b30a8f68a6aba9d15d6f0d53db3..276c48cea3ffc8b9eb795283871a1d8b0fb7e6e6 GIT binary patch literal 6810 zc$|$_Yiu0V6~3X+#%tp|?1Y$7xB-$9!Y;c>fUt=}oY+YWe&Gic`okUXPV5Q0Gt11Z z6Sqh>aYLX^F$$p4P@0-lR8>J3W5>@pt z|BJ8U@_AqiSOGi%i~xPT{~|6MfaidlfZqk)4Ezwd7C5EtT?K9f{!;J%16T$8m&P?~ z`TXj&d`>M;0`CNF1wIC>0~%}D-ZwO!1KtXJ9as$<2Yv}Sq3!$zxDNP-we0t&TJE2~ zF9UC?U_19$u>8XnZ0}$N``K2(@ptLxXDirFZw1GHLd&}q?EkP{e@Q>TTEXYPq4j>K z?R=>1PE~N87Jx~rPX*WMf7;F+P}&H*H^TCd06zy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z$kUBgcQzGYhO|i z*Oad+qh%kY6qEJ<6h`@UQb}8tPnklr56JMG5+Z(rwn!)yNPDejc*&OH1tyAenuq22 z(#PzIPMA|&%#5N!s;K99I;l|}o>Lr}$Nq?#P|Le=oF*bAnieP#CDKk1dkPd-D2<|G z7t!mfjN{AbzUp{Ywq}&K3)};eDS|mbOUfb=xpI83)?m}CcDl;nyQKijY!!Thdf5yu zWcnOW(ehD8bzLPzWeKDt(Fu!m^MNYz+;xPeAg`)EVHPPhv^2ALT)p^}S~0QeVVX<7 z@~fUnj+9*gO}~;G$i$D-i+4%IGpAm&;TRQ}Uh*FoVx(cV%F=Zin`H-!@15{``0|Z% zc0oN%sqR}jA~+kb(xgMR-=Z%A^=3IA%pfnt**Bry6AN_U6o3Z2I$@ek(oyP#NM0Ae zQxq4LeJO=wF?I-j5T3>0D86-yb8WHk38H*pRZXce9uZUOutGo_GjU)9rlvTr>g85; ztKW0v953q6kB^Bf7l;;%$}qL(1W&10*~S&c1~ypi6788D9Ey~aBLUqdiDMZ#b@wMno*a;tt!s(02TTJQ=dhAc@^n^^Jj zsw1Qqksz=6QBX>i^*Krw7I;Re>qqLXaSj4t=c=#R8%WF2zr6&_54=@KVTPDTN-G*= sl_f=f{-#<)2^JK?XSw5x6EIOW4SUJOUKPb@)x^Xl%GTLlP1Z^Af4y-PcmMzZ 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: 2015-03-29 16:19+0300\n" +"POT-Creation-Date: 2015-03-30 18:42+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -38,93 +38,97 @@ msgstr "разработчик javascript" msgid "designer" msgstr "дизайнер" -#: forms.py:33 +#: forms.py:34 msgid "Type message here. Use formatting panel for more advanced usage." msgstr "" "Вводите сообщение сюда. Используйте панель для более сложного форматирования." -#: forms.py:34 +#: forms.py:35 msgid "tag1 several_words_tag" msgstr "метка1 метка_из_нескольких_слов" -#: forms.py:36 +#: forms.py:37 msgid "Title" msgstr "Заголовок" -#: forms.py:37 +#: forms.py:38 msgid "Text" msgstr "Текст" -#: forms.py:38 +#: forms.py:39 msgid "Tag" msgstr "Метка" -#: forms.py:39 templates/boards/base.html:36 templates/search/search.html:13 +#: forms.py:40 templates/boards/base.html:36 templates/search/search.html:13 #: templates/search/search.html.py:17 msgid "Search" msgstr "Поиск" -#: forms.py:131 +#: forms.py:139 msgid "Image" msgstr "Изображение" -#: forms.py:134 +#: forms.py:142 msgid "Image URL" msgstr "URL изображения" -#: forms.py:140 +#: forms.py:148 msgid "e-mail" msgstr "" -#: forms.py:151 +#: forms.py:159 #, python-format msgid "Title must have less than %s characters" msgstr "Заголовок должен иметь меньше %s символов" -#: forms.py:160 +#: forms.py:168 #, python-format msgid "Text must have less than %s characters" msgstr "Текст должен быть короче %s символов" -#: forms.py:182 +#: forms.py:190 msgid "Invalid URL" msgstr "Неверный URL" -#: forms.py:219 +#: forms.py:227 msgid "Either text or image must be entered." msgstr "Текст или картинка должны быть введены." -#: forms.py:235 +#: forms.py:243 #, python-format msgid "Wait %s seconds after last posting" msgstr "Подождите %s секунд после последнего постинга" -#: forms.py:247 +#: forms.py:255 #, python-format msgid "Image must be less than %s bytes" msgstr "Изображение должно быть менее %s байт" -#: forms.py:294 templates/boards/rss/post.html:10 templates/boards/tags.html:7 +#: forms.py:302 templates/boards/rss/post.html:10 templates/boards/tags.html:7 msgid "Tags" msgstr "Метки" -#: forms.py:301 +#: forms.py:309 msgid "Inappropriate characters in tags." msgstr "Недопустимые символы в метках." -#: forms.py:312 +#: forms.py:320 msgid "Need at least 1 required tag." msgstr "Нужна хотя бы 1 обязательная метка." -#: forms.py:325 +#: forms.py:332 msgid "Theme" msgstr "Тема" -#: forms.py:326 +#: forms.py:333 msgid "User name" msgstr "Имя пользователя" -#: forms.py:332 +#: forms.py:334 +msgid "Time zone" +msgstr "Часовой пояс" + +#: forms.py:340 msgid "Inappropriate characters." msgstr "Недопустимые символы." @@ -169,7 +173,7 @@ msgstr "Управление метками" msgid "Notifications" msgstr "Уведомления" -#: templates/boards/base.html:47 templates/boards/settings.html:8 +#: templates/boards/base.html:47 templates/boards/settings.html:9 msgid "Settings" msgstr "Настройки" @@ -187,12 +191,12 @@ msgid "Up" msgstr "Вверх" #: templates/boards/notifications.html:17 -#: templates/boards/posting_general.html:79 templates/search/search.html:26 +#: templates/boards/posting_general.html:81 templates/search/search.html:26 msgid "Previous page" msgstr "Предыдущая страница" #: templates/boards/notifications.html:27 -#: templates/boards/posting_general.html:119 templates/search/search.html:37 +#: templates/boards/posting_general.html:121 templates/search/search.html:37 msgid "Next page" msgstr "Следующая страница" @@ -216,52 +220,52 @@ msgstr "Изменить тему" msgid "Replies" msgstr "Ответы" -#: templates/boards/post.html:86 templates/boards/thread.html:28 +#: templates/boards/post.html:86 templates/boards/thread.html:30 msgid "messages" msgstr "сообщений" -#: templates/boards/post.html:87 templates/boards/thread.html:29 +#: templates/boards/post.html:87 templates/boards/thread.html:31 msgid "images" msgstr "изображений" -#: templates/boards/posting_general.html:63 +#: templates/boards/posting_general.html:65 msgid "Edit tag" msgstr "Изменить метку" -#: templates/boards/posting_general.html:66 +#: templates/boards/posting_general.html:68 #, python-format msgid "This tag has %(thread_count)s threads and %(post_count)s posts." msgstr "С этой меткой есть %(thread_count)s тем и %(post_count)s сообщений." -#: templates/boards/posting_general.html:94 +#: templates/boards/posting_general.html:96 #, python-format msgid "Skipped %(count)s replies. Open thread to see all replies." msgstr "Пропущено %(count)s ответов. Откройте тред, чтобы увидеть все ответы." -#: templates/boards/posting_general.html:124 +#: templates/boards/posting_general.html:126 msgid "No threads exist. Create the first one!" msgstr "Нет тем. Создайте первую!" -#: templates/boards/posting_general.html:130 +#: templates/boards/posting_general.html:132 msgid "Create new thread" msgstr "Создать новую тему" -#: templates/boards/posting_general.html:135 templates/boards/preview.html:16 -#: templates/boards/thread_normal.html:44 +#: templates/boards/posting_general.html:137 templates/boards/preview.html:16 +#: templates/boards/thread_normal.html:46 msgid "Post" msgstr "Отправить" -#: templates/boards/posting_general.html:141 +#: templates/boards/posting_general.html:143 msgid "Tags must be delimited by spaces. Text or image is required." msgstr "" "Метки должны быть разделены пробелами. Текст или изображение обязательны." -#: templates/boards/posting_general.html:144 -#: templates/boards/thread_normal.html:50 +#: templates/boards/posting_general.html:146 +#: templates/boards/thread_normal.html:51 msgid "Text syntax" msgstr "Синтаксис текста" -#: templates/boards/posting_general.html:156 +#: templates/boards/posting_general.html:158 msgid "Pages:" msgstr "Страницы: " @@ -273,19 +277,19 @@ msgstr "Предпросмотр" msgid "Post image" msgstr "Изображение сообщения" -#: templates/boards/settings.html:16 +#: templates/boards/settings.html:17 msgid "You are moderator." msgstr "Вы модератор." -#: templates/boards/settings.html:20 +#: templates/boards/settings.html:21 msgid "Hidden tags:" msgstr "Скрытые метки:" -#: templates/boards/settings.html:28 +#: templates/boards/settings.html:29 msgid "No hidden tags." msgstr "Нет скрытых меток." -#: templates/boards/settings.html:37 +#: templates/boards/settings.html:38 msgid "Save" msgstr "Сохранить" @@ -342,36 +346,36 @@ msgstr "Вы можете попробовать вставить текст и проверить результат здесь:" msgid "No tags found." msgstr "Метки не найдены." -#: templates/boards/thread.html:30 +#: templates/boards/thread.html:32 msgid "Last update: " msgstr "Последнее обновление: " -#: templates/boards/thread_gallery.html:20 -#: templates/boards/thread_normal.html:14 +#: templates/boards/thread_gallery.html:21 +#: templates/boards/thread_normal.html:16 msgid "Normal mode" msgstr "Нормальный режим" -#: templates/boards/thread_gallery.html:21 -#: templates/boards/thread_normal.html:15 +#: templates/boards/thread_gallery.html:22 +#: templates/boards/thread_normal.html:17 msgid "Gallery mode" msgstr "Режим галереи" -#: templates/boards/thread_gallery.html:51 +#: templates/boards/thread_gallery.html:52 msgid "No images." msgstr "Нет изображений." -#: templates/boards/thread_normal.html:23 +#: templates/boards/thread_normal.html:25 msgid "posts to bumplimit" msgstr "сообщений до бамплимита" -#: templates/boards/thread_normal.html:37 +#: templates/boards/thread_normal.html:39 msgid "Reply to thread" msgstr "Ответить в тему" -#: templates/boards/thread_normal.html:51 +#: templates/boards/thread_normal.html:52 msgid "Close form" msgstr "Закрыть форму" -#: templates/boards/thread_normal.html:67 +#: templates/boards/thread_normal.html:68 msgid "Update" msgstr "Обновить" diff --git a/boards/middlewares.py b/boards/middlewares.py --- a/boards/middlewares.py +++ b/boards/middlewares.py @@ -1,4 +1,8 @@ +import pytz + from django.shortcuts import redirect +from django.utils import timezone + from boards import utils from boards.models import Ban @@ -26,3 +30,13 @@ class BanMiddleware: ban = bans[0] if not ban.can_read: return redirect('banned') + + +class TimezoneMiddleware(object): + def process_request(self, request): + tzname = request.session.get('django_timezone') + if tzname: + timezone.activate(pytz.timezone(tzname)) + else: + timezone.deactivate() + diff --git a/boards/static/js/main.js b/boards/static/js/main.js --- a/boards/static/js/main.js +++ b/boards/static/js/main.js @@ -23,17 +23,6 @@ for the JavaScript code in this page. */ -if (window.Intl) { - var LOCALE = window.navigator.language; - var FORMATTER = new Intl.DateTimeFormat( - LOCALE, - { - weekday: 'short', year: 'numeric', month: 'short', day: 'numeric', - hour: 'numeric', minute: '2-digit', second: '2-digit' - } - ); -} - /** * An email is a hidden file to prevent spam bots from posting. It has to be * hidden. @@ -51,36 +40,6 @@ function highlightCode(node) { }); } -/** - * Translate timestamps to local ones for all