# HG changeset patch # User neko259 # Date 2013-09-18 12:27:35 # Node ID b89107f50e6a19089451d92ade4c5bbe4bd93ebf # Parent 46eb401a3ec064e6a9d977ccf5688ff4f4536b71 Added a hidden antispam field to the forms. diff --git a/boards/forms.py b/boards/forms.py --- a/boards/forms.py +++ b/boards/forms.py @@ -48,6 +48,9 @@ class PostForm(NeboardForm): text = forms.CharField(widget=forms.Textarea, required=False) image = forms.ImageField(required=False) + # This field is for spam prevention only + email = forms.CharField(max_length=100, required=False) + session = None def clean_title(self): @@ -80,6 +83,9 @@ class PostForm(NeboardForm): def clean(self): cleaned_data = super(PostForm, self).clean() + if cleaned_data['email']: + raise forms.ValidationError('A human cannot enter a hidden field') + if not self.errors: self._clean_text_image() @@ -206,4 +212,4 @@ class LoginForm(NeboardForm): def clean(self): cleaned_data = super(LoginForm, self).clean() - return cleaned_data \ No newline at end of file + return cleaned_data diff --git a/boards/static/css/md/base_page.css b/boards/static/css/md/base_page.css --- a/boards/static/css/md/base_page.css +++ b/boards/static/css/md/base_page.css @@ -304,4 +304,8 @@ input[type="submit"]:hover { .role { text-decoration: underline; -} \ No newline at end of file +} + +.form-email { + display: none; +} diff --git a/boards/static/css/pg/base_page.css b/boards/static/css/pg/base_page.css --- a/boards/static/css/pg/base_page.css +++ b/boards/static/css/pg/base_page.css @@ -301,4 +301,8 @@ input[type="submit"]:hover { .role { text-decoration: underline; -} \ No newline at end of file +} + +.form-email { + display: none; +} diff --git a/boards/static/css/sw/base_page.css b/boards/static/css/sw/base_page.css --- a/boards/static/css/sw/base_page.css +++ b/boards/static/css/sw/base_page.css @@ -284,4 +284,8 @@ li { .role { text-decoration: underline; -} \ No newline at end of file +} + +.form-email { + display: none; +} diff --git a/boards/templates/boards/posting_general.html b/boards/templates/boards/posting_general.html --- a/boards/templates/boards/posting_general.html +++ b/boards/templates/boards/posting_general.html @@ -151,6 +151,11 @@
{{ form.tags }}
{{ form.tags.errors }}
+
+
{% trans 'e-mail' %}
+
{{ form.email }}
+
{{ form.email.errors }}
+
{{ form.captcha }}
{{ form.captcha.errors }}
diff --git a/boards/templates/boards/thread.html b/boards/templates/boards/thread.html --- a/boards/templates/boards/thread.html +++ b/boards/templates/boards/thread.html @@ -91,6 +91,11 @@
{{ form.image }}
{{ form.image.errors }}
+
+
{% trans 'e-mail' %}
+
{{ form.email }}
+
{{ form.email.errors }}
+
{{ form.captcha }}
{{ form.captcha.errors }}