Пример #1
0
 def test_render_returns_blank_for_value_when_none(self):
     widget = GoogleMapsAddressWidget()
     results = widget.render('name', None, attrs={'a1': 1, 'a2': 2})
     expected = '<input a1="1" a2="2" name="name" type="text" />'
     expected += '<div class="map_canvas_wrapper">'
     expected += '<div id="map_canvas"></div></div>'
     self.assertEqual(expected, results)
Пример #2
0
 def test_render_returns_xxxxxxx(self):
     widget = GoogleMapsAddressWidget()
     results = widget.render('name', 'value', attrs={'a1': 1, 'a2': 2})
     expected = '<input a1="1" a2="2" name="name" type="text" value="value" />'
     expected += '<div class="map_canvas_wrapper">'
     expected += '<div id="map_canvas"></div></div>'
     self.assertHTMLEqual(expected, results)
Пример #3
0
 def test_render_returns_xxxxxxx(self):
     widget = GoogleMapsAddressWidget()
     results = widget.render('name', 'value', attrs={'a1': 1, 'a2': 2})
     expected = '<input a1="1" a2="2" name="name" type="text" value="value" />'
     expected += '<div class="map_canvas_wrapper">'
     expected += '<div id="map_canvas"></div></div>'
     self.assertEqual(expected, results)
Пример #4
0
 def test_render_returns_blank_for_value_when_none(self):
     widget = GoogleMapsAddressWidget()
     results = widget.render('name', None, attrs={'a1': 1, 'a2': 2})
     expected = '<input a1="1" a2="2" name="name" type="text" />'
     expected += '<div class="map_canvas_wrapper">'
     expected += '<div id="map_canvas"></div></div>'
     self.assertHTMLEqual(expected, results)
Пример #5
0
 class Meta:
     model = Order
     fields = ['employee_order', 'address', 'geolocation']
     widgets = {
         "address":
         GoogleMapsAddressWidget(
             attrs={
                 'data-map-type':
                 'roadmap',
                 'data-autocomplete-options':
                 json.dumps({
                     'types': ['geocode', 'establishment'],
                     'componentRestrictions': {
                         'country': 'NZ'
                     }
                 })
             }),
     }
Пример #6
0
 def test_maps_js_uses_api_key(self):
     widget = GoogleMapsAddressWidget()
     google_maps_js = "https://maps.google.com/maps/api/js?key={}".format(
         settings.GOOGLE_MAPS_API_KEY)
     self.assertEqual(google_maps_js, widget.Media().js[1])
Пример #7
0
 class Meta(object):
     model = Product
     fields = ['address', 'geolocation']
     widgets = {
         "address": GoogleMapsAddressWidget(attrs={'disabled': 'disabled'}),
     }