Commits

Luke Plant committed a6ba33e Merge

Merged from default

Comments (0)

Files changed (4)

cciw/cciwmain/static/js/cciwutils.js

             }
         });
     };
+    $('html').ajaxSend(function(event, xhr, settings) {
+        function getCookie(name) {
+            var cookieValue = null;
+            if (document.cookie && document.cookie != '') {
+                var cookies = document.cookie.split(';');
+                for (var i = 0; i < cookies.length; i++) {
+                    var cookie = jQuery.trim(cookies[i]);
+                    // Does this cookie string begin with the name we want?
+                    if (cookie.substring(0, name.length + 1) == (name + '=')) {
+                        cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
+                        break;
+                    }
+                }
+            }
+            return cookieValue;
+        }
+        if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
+            // Only send the token to relative URLs i.e. locally.
+            xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
+        }
+    });
 })(jQuery);
 
 var cciw = (function(pub, $) {

cciw/cciwmain/tests/forums.py

         response = self.client.get(self.forum.get_absolute_url(), {'format':'atom'})
         self.assertEqual(response.status_code, 200)
         self.assertContains(response, "Jill &amp; Jane")
-        self.assertEqual(response['Content-Type'], 'application/atom+xml')
+        self.assertTrue(response['Content-Type'].startswith('application/atom+xml'))
 
     def test_query_count(self):
         """
         response = self.client.get(self.path(), {'format':'atom'})
         self.assertEqual(response.status_code, 200)
         self.assertContains(response, "Jill &amp; Jane")
-        self.assertEqual(response['Content-Type'], 'application/atom+xml')
+        self.assertTrue(response['Content-Type'].startswith('application/atom+xml'))
 
     def test_query_count(self):
         """
         self.assertEqual(response.status_code, 200)
         self.assertContains(response, '<title>CCIW - Posts on topic "&lt;Jill &amp; Jane&gt;"</title>')
         self.assertContains(response, 'A &lt;b&gt;unique message&lt;/b&gt; with some bbcode &amp;amp; &amp;lt;stuff&amp;gt; to be escaped')
-        self.assertEqual(response['Content-Type'], 'application/atom+xml')
+        self.assertTrue(response['Content-Type'].startswith('application/atom+xml'))
 
     def test_query_count(self):
         """
     def test_atom(self):
         response = self.client.get(self.gallery.get_absolute_url(), {'format':'atom'})
         self.assertEqual(response.status_code, 200)
-        self.assertEqual(response['Content-Type'], 'application/atom+xml')
+        self.assertTrue(response['Content-Type'].startswith('application/atom+xml'))
 
     def test_query_count(self):
         """
 
         self.assertContains(response, '<title>CCIW - Posts on photo Photo: 2000-1-a-nice-photo.jpeg</title>')
         self.assertContains(response, 'A &lt;b&gt;photo message&lt;/b&gt; with &amp;lt;stuff&amp;gt; to be escaped')
-        self.assertEqual(response['Content-Type'], 'application/atom+xml')
+        self.assertTrue(response['Content-Type'].startswith('application/atom+xml'))
 
     def test_query_count(self):
         """
         response = self.client.get(self.path(), {'format':'atom'})
         self.assertEqual(response.status_code, 200)
         self.assertContains(response, "Jill &amp;amp; Jane")
-        self.assertEqual(response['Content-Type'], 'application/atom+xml')
+        self.assertTrue(response['Content-Type'].startswith('application/atom+xml'))
 
     def test_query_count_topics(self):
         """

cciw/cciwmain/tests/members.py

         # Just test for no error
         resp = self.client.get(reverse('cciwmain.members.index'), {'format':'atom'})
         self.assertEqual(resp.status_code, 200)
-        self.assertEqual(resp['Content-Type'], 'application/atom+xml')
+        self.assertTrue(resp['Content-Type'].startswith('application/atom+xml'))
         self.assertContains(resp, TEST_MEMBER_USERNAME)
 
     def test_query_count(self):
                                        kwargs={'user_name':TEST_MEMBER_USERNAME}),
                                {'format':'atom'})
         self.assertEqual(resp.status_code, 200)
-        self.assertEqual(resp['Content-Type'], 'application/atom+xml')
+        self.assertTrue(resp['Content-Type'].startswith('application/atom+xml'))
         self.assertContains(resp, TEST_MEMBER_USERNAME)
         self.assertContains(resp, "unique message", count=1)

cciw/cciwmain/tests/news.py

         with self.assertNumQueries(2):
             response = forums.news(request)
             resp.render()
-            self.assertEqual(response['Content-Type'], 'application/atom+xml')
+            self.assertTrue(response['Content-Type'].startswith('application/atom+xml'))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.