Commit de6187c6d996597c383cc236d8f0d13d5887a3d8

Authored by Łukasz Banasiak
Committed by Claude Paroz
1 parent 5d565503

Added COMMENTS_TIMEOUT setting to configure form timeout

... ... @@ -17,6 +17,7 @@ from django.utils.translation import ungettext, ugettext, ugettext_lazy as _
17 17 from django_comments.models import Comment
18 18
19 19 COMMENT_MAX_LENGTH = getattr(settings, 'COMMENT_MAX_LENGTH', 3000)
  20 +DEFAULT_COMMENTS_TIMEOUT = getattr(settings, 'COMMENTS_TIMEOUT', (2 * 60 * 60)) # 2h
20 21
21 22
22 23 class CommentSecurityForm(forms.Form):
... ... @@ -57,9 +58,9 @@ class CommentSecurityForm(forms.Form):
57 58 return actual_hash
58 59
59 60 def clean_timestamp(self):
60   - """Make sure the timestamp isn't too far (> 2 hours) in the past."""
  61 + """Make sure the timestamp isn't too far (default is > 2 hours) in the past."""
61 62 ts = self.cleaned_data["timestamp"]
62   - if time.time() - ts > (2 * 60 * 60):
  63 + if time.time() - ts > DEFAULT_COMMENTS_TIMEOUT:
63 64 raise forms.ValidationError("Timestamp check failed")
64 65 return ts
65 66
... ...
... ... @@ -31,3 +31,11 @@ An app which provides :doc:`customization of the comments framework
31 31 <custom>`. Use the same dotted-string notation
32 32 as in :setting:`INSTALLED_APPS`. Your custom :setting:`COMMENTS_APP`
33 33 must also be listed in :setting:`INSTALLED_APPS`.
  34 +
  35 +.. setting:: COMMENTS_TIMEOUT
  36 +
  37 +COMMENT_TIMEOUT
  38 +------------------
  39 +
  40 +The maximum comment form timeout in seconds. The default value is
  41 +``2 * 60 * 60`` (2 hours).
... ...
Please register or login to post a comment