Ejemplo n.º 1
0
 def render(self, context):
     slot = self._get_slot(context)
     if not slot.enabled:
         logging.debug('Ad slot %s is disabled' % slot)
         return ''
     
     # annoying method to append additional query parameters
     url = reverse('slot_detail', args=[slot.id])
     kwargs = {}
     for key, value in self.keyword_arguments.iteritems():
         kwargs[key] = self._resolve(value, context)
     url = append_params(url, kwargs)
     
     local_ctx = {'slot': slot, 'iframe_url': url }
     return render_to_string('adinv/adslot.html', local_ctx, context)
Ejemplo n.º 2
0
 def test_append_params(self):
     url = "http://www.fish.com/dir/page.html"
     url = append_params(url, {"a": 1, "b": "a i"})
     expected = "http://www.fish.com/dir/page.html?a=1&b=a+i"
     self.assertEqual(expected, url)
Ejemplo n.º 3
0
 def test_append_params_with_existing(self):
     url = "http://www.fish.com/dir/page.html?a=b"
     url = append_params(url, {"u": 1234})
     expected = "http://www.fish.com/dir/page.html?a=b&u=1234"
     self.assertEqual(expected, url)
Ejemplo n.º 4
0
 def test_append_params(self):
     url = 'http://www.fish.com/dir/page.html'
     url = append_params(url, {'a': 1, 'b': 'a i'})
     expected = 'http://www.fish.com/dir/page.html?a=1&b=a+i'
     self.assertEqual(expected, url)
Ejemplo n.º 5
0
 def test_append_params_with_existing(self):
     url = 'http://www.fish.com/dir/page.html?a=b'
     url = append_params(url, {'u': 1234})
     expected = 'http://www.fish.com/dir/page.html?a=b&u=1234'
     self.assertEqual(expected, url)