Commits

Morgan LEFIEUX  committed b7eb278

Ajout d'un pot de miel pour les commentaires.

  • Participants
  • Parent commits 6725885

Comments (0)

Files changed (8)

File my_comment_app/__init__.py

+from my_comment_app.forms import CommentFormWithHoneyP
+
+def get_form():
+    return CommentFormWithHoneyP

File my_comment_app/forms.py

+from django import forms
+from django.contrib.comments.forms import CommentForm
+
+class CommentFormWithHoneyP(CommentForm):
+    "Ajout d'un pot de miel pour les robots spammeurs"
+    accept_terms = forms.BooleanField(label="", required=False)
+    
+    
+    def clean_accept_terms(self):
+        "Verification du honeypot"
+        value = self.cleaned_data["accept_terms"]
+        if value:
+            raise forms.ValidationError("Vas-t-en vilain spammer !")
+        return value 

File my_comment_app/models.py

+from django.db import models
+
+# Create your models here.

File my_comment_app/tests.py

+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+    def test_basic_addition(self):
+        """
+        Tests that 1 + 1 always equals 2.
+        """
+        self.assertEqual(1 + 1, 2)

File my_comment_app/views.py

+# Create your views here.

File templates/blog/entry_detail.html

 {% extends "base.html" %}
-{% load comments %}
+{% load comments i18n %}
 
 {% block title %}Blog - {{ object.title }}{% endblock %}
 

File templates/blog/entry_list.html

 {% extends "base.html" %}
-{% load comments %}
+{% load comments i18n %}
 
 {% block title %}Derniers billets{% endblock %}
 

File templates/comments/posted.html

 {% extends "base.html" %}
+{% load comments %}
 
 {% block title %}Commentaire posté{% endblock %}