Skip to content

Commit

Permalink
replaced double quotes with single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
erdem committed Apr 1, 2020
1 parent c559b92 commit 152c5d4
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions mapwidgets/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ def minify_if_not_debug(asset):
"""
Transform template string `asset` by inserting '.min' if DEBUG=False
"""
return asset.format("" if not mw_settings.MINIFED else ".min")
return asset.format('' if not mw_settings.MINIFED else '.min')


class BasePointFieldMapWidget(BaseGeometryWidget):
settings_namespace = None
settings = None

def __init__(self, *args, **kwargs):
attrs = kwargs.get("attrs")
attrs = kwargs.get('attrs')
self.attrs = {}
for key in ('geom_type', 'map_srid', 'map_width', 'map_height', 'display_raw'):
if key in kwargs:
Expand All @@ -37,8 +37,8 @@ def __init__(self, *args, **kwargs):
self.attrs.update(attrs)

self.custom_settings = False
if kwargs.get("settings"):
self.settings = kwargs.pop("settings")
if kwargs.get('settings'):
self.settings = kwargs.pop('settings')
self.custom_settings = True

def map_options(self):
Expand All @@ -55,35 +55,35 @@ def map_options(self):


class GooglePointFieldWidget(BasePointFieldMapWidget):
template_name = "mapwidgets/google-point-field-widget.html"
template_name = 'mapwidgets/google-point-field-widget.html'
settings = mw_settings.GooglePointFieldWidget
settings_namespace = "GooglePointFieldWidget"
settings_namespace = 'GooglePointFieldWidget'
google_map_srid = 4326

@property
def media(self):
css = {
"all": [
minify_if_not_debug("mapwidgets/css/map_widgets{}.css"),
'all': [
minify_if_not_debug('mapwidgets/css/map_widgets{}.css'),
]
}

js = [
"https://maps.googleapis.com/maps/api/js?libraries=places&language={}&key={}".format(
'https://maps.googleapis.com/maps/api/js?libraries=places&language={}&key={}'.format(
mw_settings.LANGUAGE, mw_settings.GOOGLE_MAP_API_KEY
)
]

if not mw_settings.MINIFED: # pragma: no cover
js = js + [
"mapwidgets/js/jquery_init.js",
"mapwidgets/js/jquery_class.js",
"mapwidgets/js/django_mw_base.js",
"mapwidgets/js/mw_google_point_field.js",
'mapwidgets/js/jquery_init.js',
'mapwidgets/js/jquery_class.js',
'mapwidgets/js/django_mw_base.js',
'mapwidgets/js/mw_google_point_field.js',
]
else:
js = js + [
"mapwidgets/js/mw_google_point_field.min.js"
'mapwidgets/js/mw_google_point_field.min.js'
]

return forms.Media(js=js, css=css)
Expand All @@ -96,8 +96,8 @@ def render(self, name, value, attrs=None, renderer=None):
if value and isinstance(value, six.string_types):
value = self.deserialize(value)
longitude, latitude = value.coords
field_value["lng"] = longitude
field_value["lat"] = latitude
field_value['lng'] = longitude
field_value['lat'] = latitude

if isinstance(value, Point):
if value.srid and value.srid != self.google_map_srid:
Expand All @@ -106,12 +106,12 @@ def render(self, name, value, attrs=None, renderer=None):
value = ogr

longitude, latitude = value.coords
field_value["lng"] = longitude
field_value["lat"] = latitude
field_value['lng'] = longitude
field_value['lat'] = latitude

extra_attrs = {
"options": self.map_options(),
"field_value": json.dumps(field_value)
'options': self.map_options(),
'field_value': json.dumps(field_value)
}
attrs.update(extra_attrs)
self.as_super = super(GooglePointFieldWidget, self)
Expand All @@ -124,28 +124,28 @@ def render(self, name, value, attrs=None, renderer=None):
class PointFieldInlineWidgetMixin(object):

def get_js_widget_data(self, name, element_id):
map_elem_selector = "#%s-mw-wrap" % name
map_elem_id = "%s-map-elem" % name
google_auto_input_id = "%s-mw-google-address-input" % name
location_input_id = "#%s" % element_id
map_elem_selector = '#%s-mw-wrap' % name
map_elem_id = '%s-map-elem' % name
google_auto_input_id = '%s-mw-google-address-input' % name
location_input_id = '#%s' % element_id
js_widget_params = {
"wrapElemSelector": map_elem_selector,
"mapElemID": map_elem_id,
"googleAutoInputID": google_auto_input_id,
"locationInputID": location_input_id
'wrapElemSelector': map_elem_selector,
'mapElemID': map_elem_id,
'googleAutoInputID': google_auto_input_id,
'locationInputID': location_input_id
}
return js_widget_params

def render(self, name, value, attrs=None, renderer=None):
if not attrs:
attrs = dict()

element_id = attrs.get("id")
is_formset_empty_form_template = "__prefix__" in name
element_id = attrs.get('id')
is_formset_empty_form_template = '__prefix__' in name
widget_data = self.get_js_widget_data(name, element_id)
attrs.update({
"js_widget_data": json.dumps(widget_data),
"is_formset_empty_form_template": is_formset_empty_form_template
'js_widget_data': json.dumps(widget_data),
'is_formset_empty_form_template': is_formset_empty_form_template
})
self.as_super = super(PointFieldInlineWidgetMixin, self)
if renderer is not None:
Expand All @@ -155,35 +155,35 @@ def render(self, name, value, attrs=None, renderer=None):


class GooglePointFieldInlineWidget(PointFieldInlineWidgetMixin, GooglePointFieldWidget):
template_name = "mapwidgets/google-point-field-inline-widget.html"
template_name = 'mapwidgets/google-point-field-inline-widget.html'
settings = mw_settings.GooglePointFieldWidget
settings_namespace = "GooglePointFieldWidget"
settings_namespace = 'GooglePointFieldWidget'

@property
def media(self):
css = {
"all": [
minify_if_not_debug("mapwidgets/css/map_widgets{}.css"),
'all': [
minify_if_not_debug('mapwidgets/css/map_widgets{}.css'),
]
}

js = [
"https://maps.googleapis.com/maps/api/js?libraries=places&language={}&key={}".format(
'https://maps.googleapis.com/maps/api/js?libraries=places&language={}&key={}'.format(
mw_settings.LANGUAGE, mw_settings.GOOGLE_MAP_API_KEY
)
]

if not mw_settings.MINIFED: # pragma: no cover
js = js + [
"mapwidgets/js/jquery_init.js",
"mapwidgets/js/jquery_class.js",
"mapwidgets/js/django_mw_base.js",
"mapwidgets/js/mw_google_point_field.js",
"mapwidgets/js/mw_google_point_field_generater.js"
'mapwidgets/js/jquery_init.js',
'mapwidgets/js/jquery_class.js',
'mapwidgets/js/django_mw_base.js',
'mapwidgets/js/mw_google_point_field.js',
'mapwidgets/js/mw_google_point_field_generater.js'
]
else:
js = js + [
"mapwidgets/js/mw_google_point_inline_field.min.js"
'mapwidgets/js/mw_google_point_inline_field.min.js'
]

return forms.Media(js=js, css=css)
Expand Down

0 comments on commit 152c5d4

Please sign in to comment.