Show More
@@ -68,7 +68,7 b' def user_and_ui_processor(request):' | |||||
68 | context[CONTEXT_VERSION] = settings.get('Version', 'Version') |
|
68 | context[CONTEXT_VERSION] = settings.get('Version', 'Version') | |
69 | context[CONTEXT_SITE_NAME] = settings.get('Version', 'SiteName') |
|
69 | context[CONTEXT_SITE_NAME] = settings.get('Version', 'SiteName') | |
70 |
|
70 | |||
71 | if settings.get_bool('Forms', 'LimitPostingSpeed'): |
|
71 | if settings.get_bool('Forms', 'LimitPostingSpeed') and not settings_manager.get_setting('confirmed_user'): | |
72 | context[CONTEXT_POW_DIFFICULTY] = settings.get_int('Forms', 'PowDifficulty') |
|
72 | context[CONTEXT_POW_DIFFICULTY] = settings.get_int('Forms', 'PowDifficulty') | |
73 |
|
73 | |||
74 | context[CONTEXT_IMAGE_VIEWER] = settings_manager.get_setting( |
|
74 | context[CONTEXT_IMAGE_VIEWER] = settings_manager.get_setting( |
@@ -12,6 +12,7 b' from django.forms.utils import ErrorList' | |||||
12 | from django.utils.translation import ugettext_lazy as _, ungettext_lazy |
|
12 | from django.utils.translation import ugettext_lazy as _, ungettext_lazy | |
13 | from django.utils import timezone |
|
13 | from django.utils import timezone | |
14 |
|
14 | |||
|
15 | from boards.abstracts.settingsmanager import get_settings_manager | |||
15 | from boards.mdx_neboard import formatters |
|
16 | from boards.mdx_neboard import formatters | |
16 | from boards.models.attachment.downloaders import Downloader |
|
17 | from boards.models.attachment.downloaders import Downloader | |
17 | from boards.models.post import TITLE_MAX_LENGTH |
|
18 | from boards.models.post import TITLE_MAX_LENGTH | |
@@ -269,12 +270,21 b' class PostForm(NeboardForm):' | |||||
269 | self._clean_text_file() |
|
270 | self._clean_text_file() | |
270 |
|
271 | |||
271 | limit_speed = board_settings.get_bool('Forms', 'LimitPostingSpeed') |
|
272 | limit_speed = board_settings.get_bool('Forms', 'LimitPostingSpeed') | |
272 | if not self.errors and limit_speed: |
|
273 | ||
|
274 | settings_manager = get_settings_manager(self) | |||
|
275 | if not self.errors and limit_speed and not settings_manager.get_setting('confirmed_user'): | |||
273 | pow_difficulty = board_settings.get_int('Forms', 'PowDifficulty') |
|
276 | pow_difficulty = board_settings.get_int('Forms', 'PowDifficulty') | |
274 | if pow_difficulty > 0 and cleaned_data['timestamp'] and cleaned_data['iteration'] and cleaned_data['guess']: |
|
277 | if pow_difficulty > 0: | |
275 | self._validate_hash(cleaned_data['timestamp'], cleaned_data['iteration'], cleaned_data['guess'], cleaned_data['text']) |
|
278 | # Limit only first post | |
|
279 | if cleaned_data['timestamp'] \ | |||
|
280 | and cleaned_data['iteration'] and cleaned_data['guess'] \ | |||
|
281 | and not settings_manager.get_setting('confirmed_user'): | |||
|
282 | self._validate_hash(cleaned_data['timestamp'], cleaned_data['iteration'], cleaned_data['guess'], cleaned_data['text']) | |||
276 | else: |
|
283 | else: | |
|
284 | # Limit every post | |||
277 | self._validate_posting_speed() |
|
285 | self._validate_posting_speed() | |
|
286 | settings_manager.set_setting('confirmed_user', True) | |||
|
287 | ||||
278 |
|
288 | |||
279 | return cleaned_data |
|
289 | return cleaned_data | |
280 |
|
290 | |||
@@ -363,9 +373,6 b' class PostForm(NeboardForm):' | |||||
363 | def _validate_hash(self, timestamp: str, iteration: str, guess: str, message: str): |
|
373 | def _validate_hash(self, timestamp: str, iteration: str, guess: str, message: str): | |
364 | post_time = timezone.datetime.fromtimestamp( |
|
374 | post_time = timezone.datetime.fromtimestamp( | |
365 | int(timestamp[:-3]), tz=timezone.get_current_timezone()) |
|
375 | int(timestamp[:-3]), tz=timezone.get_current_timezone()) | |
366 | timedelta = (timezone.now() - post_time).seconds / 60 |
|
|||
367 | if timedelta > POW_LIFE_MINUTES: |
|
|||
368 | self._errors['text'] = self.error_class([_('Stale PoW.')]) |
|
|||
369 |
|
376 | |||
370 | payload = timestamp + message.replace('\r\n', '\n') |
|
377 | payload = timestamp + message.replace('\r\n', '\n') | |
371 | difficulty = board_settings.get_int('Forms', 'PowDifficulty') |
|
378 | difficulty = board_settings.get_int('Forms', 'PowDifficulty') | |
@@ -380,6 +387,7 b' class PostForm(NeboardForm):' | |||||
380 | [_('Invalid PoW.')]) |
|
387 | [_('Invalid PoW.')]) | |
381 |
|
388 | |||
382 |
|
389 | |||
|
390 | ||||
383 | class ThreadForm(PostForm): |
|
391 | class ThreadForm(PostForm): | |
384 |
|
392 | |||
385 | tags = forms.CharField( |
|
393 | tags = forms.CharField( |
General Comments 0
You need to be logged in to leave comments.
Login now