Code

Ticket #11611: prefix_for_comment.2.diff

File prefix_for_comment.2.diff, 1.6 KB (added by oduvan, 5 years ago)
Line 
1Index: django/contrib/comments/forms.py
2===================================================================
3--- django/contrib/comments/forms.py    (revision 11372)
4+++ django/contrib/comments/forms.py    (working copy)
5@@ -22,12 +22,12 @@
6     timestamp     = forms.IntegerField(widget=forms.HiddenInput)
7     security_hash = forms.CharField(min_length=40, max_length=40, widget=forms.HiddenInput)
8 
9-    def __init__(self, target_object, data=None, initial=None):
10+    def __init__(self, target_object, data=None, initial=None,**kwargs):
11         self.target_object = target_object
12         if initial is None:
13             initial = {}
14         initial.update(self.generate_security_data())
15-        super(CommentSecurityForm, self).__init__(data=data, initial=initial)
16+        super(CommentSecurityForm, self).__init__(data=data, initial=initial,**kwargs)
17         
18     def security_errors(self):
19         """Return just those errors associated with security"""
20@@ -40,9 +40,9 @@
21     def clean_security_hash(self):
22         """Check the security hash."""
23         security_hash_dict = {
24-            'content_type' : self.data.get("content_type", ""),
25-            'object_pk' : self.data.get("object_pk", ""),
26-            'timestamp' : self.data.get("timestamp", ""),
27+            'content_type' : self.cleaned_data.get("content_type", ""),
28+            'object_pk' : self.cleaned_data.get("object_pk", ""),
29+            'timestamp' : str(self.cleaned_data.get("timestamp", "")),
30         }
31         expected_hash = self.generate_security_hash(**security_hash_dict)
32         actual_hash = self.cleaned_data["security_hash"]