The following commit has been merged in the master branch:
commit 5ef454f902ee86ea50afeb40b6f991cdd51fd514
Author: Michal Čihař <[email protected]>
Date:   Wed Oct 7 12:58:02 2009 +0200

    Add anti robot protection.
    
    Javascript users will not be affected, others have to copy text to the
    irobot field.

diff --git a/html/phonedb/new.html b/html/phonedb/new.html
index 2c74b78..0727a8b 100644
--- a/html/phonedb/new.html
+++ b/html/phonedb/new.html
@@ -17,8 +17,21 @@
 <form action="/phones/new/" method="POST">
 <table>
 {{ form.as_table }}
-</table>
+<tr><td colspan="2">
+<noscript>{% trans "Please enter text 'nospam':" %} <input name="irobot" 
size="6" /></noscript>
+<script type="text/javascript">
+//<![CDATA[
+document.write(String.fromCharCode(60) + 'input type="hidden" name="irobot" 
value="no' + 'spam" />');
+//]]>
+</script>
+</td>
+</tr>
+<tr><td></td>
+<td>
 <input type="submit" value="{% trans "Go" %}" />
+</td>
+</tr>
+</table>
 </form>
 
 
diff --git a/phonedb/views.py b/phonedb/views.py
index 9483c5d..9344a1c 100644
--- a/phonedb/views.py
+++ b/phonedb/views.py
@@ -248,7 +248,7 @@ def phones_csv(request):
     return response
 
 def create(request):
-    if request.method == 'POST':
+    if request.method == 'POST' and request.POST.has_key('irobot') and 
request.POST['irobot'] in ['nospam', 'wammu']:
         form = NewForm(request.POST)
         if form.is_valid():
             newphone = form.save()

-- 
UNNAMED PROJECT

_______________________________________________
Wammu-svn mailing list
[email protected]
https://lists.cihar.com/cgi-bin/mailman/listinfo/wammu-svn

Reply via email to