diff --git a/boards/forms.py b/boards/forms.py --- a/boards/forms.py +++ b/boards/forms.py @@ -14,6 +14,8 @@ from neboard import settings from boards import utils import boards.settings as board_settings +VETERAN_POSTING_DELAY = 5 + ATTRIBUTE_PLACEHOLDER = 'placeholder' LAST_POST_TIME = 'last_post_time' @@ -178,15 +180,21 @@ class PostForm(NeboardForm): def _validate_posting_speed(self): can_post = True + user = User.objects.get(id=self.session['user_id']) + if user.is_veteran(): + posting_delay = VETERAN_POSTING_DELAY + else: + posting_delay = settings.POSTING_DELAY + if LAST_POST_TIME in self.session: now = time.time() last_post_time = self.session[LAST_POST_TIME] current_delay = int(now - last_post_time) - if current_delay < settings.POSTING_DELAY: + if current_delay < posting_delay: error_message = _('Wait %s seconds after last posting') % str( - settings.POSTING_DELAY - current_delay) + posting_delay - current_delay) self._errors['text'] = self.error_class([error_message]) can_post = False 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-02-08 20:55+0200\n" +"POT-Creation-Date: 2014-03-08 12:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -89,36 +89,36 @@ msgstr "Изображение должно быть менее %s байт" msgid "Either text or image must be entered." msgstr "Текст или картинка должны быть введены." -#: forms.py:188 +#: forms.py:193 #, python-format msgid "Wait %s seconds after last posting" msgstr "Подождите %s секунд после последнего постинга" -#: forms.py:204 templates/boards/tags.html:7 templates/boards/rss/post.html:10 +#: forms.py:209 templates/boards/tags.html:7 templates/boards/rss/post.html:10 msgid "Tags" msgstr "Теги" -#: forms.py:212 forms.py:331 +#: forms.py:217 forms.py:336 msgid "Inappropriate characters in tags." msgstr "Недопустимые символы в тегах." -#: forms.py:240 forms.py:261 +#: forms.py:245 forms.py:266 msgid "Captcha validation failed" msgstr "Проверка капчи провалена" -#: forms.py:267 +#: forms.py:272 msgid "Theme" msgstr "Тема" -#: forms.py:272 +#: forms.py:277 msgid "Enable moderation panel" msgstr "Включить панель модерации" -#: forms.py:287 +#: forms.py:292 msgid "No such user found" msgstr "Данный пользователь не найден" -#: forms.py:301 +#: forms.py:306 #, python-format msgid "Wait %s minutes after last login" msgstr "Подождите %s минут после последнего входа" @@ -281,22 +281,26 @@ msgid "You are moderator." msgstr "Вы модератор." #: templates/boards/settings.html:19 +msgid "You are veteran." +msgstr "Вы ветеран." + +#: templates/boards/settings.html:22 msgid "Posts:" msgstr "Сообщений:" -#: templates/boards/settings.html:20 +#: templates/boards/settings.html:23 msgid "First access:" msgstr "Первый доступ:" -#: templates/boards/settings.html:22 +#: templates/boards/settings.html:25 msgid "Last access:" msgstr "Последний доступ: " -#: templates/boards/settings.html:26 +#: templates/boards/settings.html:29 msgid "Hidden tags:" msgstr "Скрытые теги:" -#: templates/boards/settings.html:41 +#: templates/boards/settings.html:44 msgid "Save" msgstr "Сохранить" diff --git a/boards/models/user.py b/boards/models/user.py --- a/boards/models/user.py +++ b/boards/models/user.py @@ -13,6 +13,8 @@ RANK_USER = 100 BAN_REASON_AUTO = 'Auto' BAN_REASON_MAX_LENGTH = 200 +VETERAN_POSTS = 1000 + class User(models.Model): @@ -95,6 +97,13 @@ class User(models.Model): def unhide_tag(self, tag): self.hidden_tags.remove(tag) + def is_veteran(self): + """ + Returns if a user is old (veteran). + """ + + return self.get_post_count() >= VETERAN_POSTS + def _get_tag_cache_key(self): return self.user_id + '_tags' diff --git a/boards/templates/boards/settings.html b/boards/templates/boards/settings.html --- a/boards/templates/boards/settings.html +++ b/boards/templates/boards/settings.html @@ -15,6 +15,9 @@ {% if user.is_moderator %} {% trans 'You are moderator.' %} {% endif %} + {% if user.is_veteran %} + {% trans 'You are veteran.' %} + {% endif %}

{% trans 'Posts:' %} {{ user.get_post_count }}

{% trans 'First access:' %} {{ user.registration_time|naturaltime }}