Commit 98797d9b authored by Serge S. Koval's avatar Serge S. Koval

Minor fixes and improvements

parent 2f272f28
...@@ -10,6 +10,8 @@ def lng(pt): ...@@ -10,6 +10,8 @@ def lng(pt):
class LeafletWidget(TextArea): class LeafletWidget(TextArea):
data_role = 'leaflet'
""" """
`Leaflet <http://leafletjs.com/>`_ styled map widget. Inherits from `Leaflet <http://leafletjs.com/>`_ styled map widget. Inherits from
`TextArea` so that geographic data can be stored via the <textarea> `TextArea` so that geographic data can be stored via the <textarea>
...@@ -31,7 +33,7 @@ class LeafletWidget(TextArea): ...@@ -31,7 +33,7 @@ class LeafletWidget(TextArea):
self.max_bounds = max_bounds self.max_bounds = max_bounds
def __call__(self, field, **kwargs): def __call__(self, field, **kwargs):
kwargs.setdefault('data-role', 'leaflet') kwargs.setdefault('data-role', self.data_role)
gtype = getattr(field, "geometry_type", "GEOMETRY") gtype = getattr(field, "geometry_type", "GEOMETRY")
kwargs.setdefault('data-geometry-type', gtype) kwargs.setdefault('data-geometry-type', gtype)
......
...@@ -56,7 +56,7 @@ def is_form_submitted(): ...@@ -56,7 +56,7 @@ def is_form_submitted():
""" """
Check if current method is PUT or POST Check if current method is PUT or POST
""" """
return request and request.method in ("PUT", "POST") return request and request.method in ('PUT', 'POST')
def validate_form_on_submit(form): def validate_form_on_submit(form):
......
...@@ -1432,4 +1432,4 @@ class BaseModelView(BaseView, ActionsMixin): ...@@ -1432,4 +1432,4 @@ class BaseModelView(BaseView, ActionsMixin):
abort(404) abort(404)
data = [loader.format(m) for m in loader.get_list(query, offset, limit)] data = [loader.format(m) for m in loader.get_list(query, offset, limit)]
return Response(json.dumps(data), mimetype='application/json') return Response(json.dumps(data), mimetype='application/json')
\ No newline at end of file
...@@ -26,8 +26,8 @@ class AjaxSelect2Widget(object): ...@@ -26,8 +26,8 @@ class AjaxSelect2Widget(object):
self.multiple = multiple self.multiple = multiple
def __call__(self, field, **kwargs): def __call__(self, field, **kwargs):
kwargs['data-role'] = u'select2-ajax' kwargs.setdefault('data-role', 'select2-ajax')
kwargs['data-url'] = get_url('.ajax_lookup', name=field.loader.name) kwargs.setdefault('data-url', get_url('.ajax_lookup', name=field.loader.name))
allow_blank = getattr(field, 'allow_blank', False) allow_blank = getattr(field, 'allow_blank', False)
if allow_blank and not self.multiple: if allow_blank and not self.multiple:
......
...@@ -476,7 +476,7 @@ ...@@ -476,7 +476,7 @@
* @param {converter} function($el, name) * @param {converter} function($el, name)
*/ */
this.addFieldConverter = function(converter) { this.addFieldConverter = function(converter) {
fieldConverters.push(converter); fieldConverters.push(converter);
}; };
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment