summaryrefslogtreecommitdiff
path: root/chimere/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/widgets.py')
-rw-r--r--chimere/widgets.py48
1 files changed, 25 insertions, 23 deletions
diff --git a/chimere/widgets.py b/chimere/widgets.py
index 95a9526..810ae69 100644
--- a/chimere/widgets.py
+++ b/chimere/widgets.py
@@ -57,8 +57,9 @@ AREA_JS = tuple(
def getMapJS(area_name=''):
- '''Variable initialization for drawing the map
- '''
+ """
+ Variable initialization for drawing the map
+ """
# projection, center and bounds definitions
js = "var epsg_display_projection = 'EPSG:%d';\n" \
% settings.CHIMERE_EPSG_DISPLAY_PROJECTION
@@ -143,9 +144,7 @@ class ChosenSelectWidget(forms.Select):
"</script>\n" % kwargs['attrs']['id']
return mark_safe(rendered)
-"""
-JQuery UI button select widget.
-"""
+# JQuery UI button select widget.
class ButtonRadioInput(RadioSelect):
@@ -201,9 +200,9 @@ class ButtonSelectWidget(forms.RadioSelect):
class ImporterChoicesWidget(forms.Select):
- '''
+ """
Importer select widget.
- '''
+ """
class Media:
js = ["%schimere/js/importer_interface.js" % settings.STATIC_URL]
@@ -405,9 +404,9 @@ class PointChooserWidget(forms.TextInput):
js = BASE_JS
def render(self, name, value, attrs=None, area_name='', initialized=True):
- '''
+ """
Render a map and latitude, longitude information field
- '''
+ """
val = ''
value_x, value_y = 0, 0
if value:
@@ -464,9 +463,9 @@ class HiddenPointChooserWidget(PointChooserWidget):
class PointField(models.PointField, forms.Field):
- '''
+ """
Set the widget for the form field
- '''
+ """
def __init__(self, *args, **kwargs):
self.widget = kwargs.pop('widget') if 'widget' in kwargs \
else PointChooserWidget
@@ -493,6 +492,9 @@ class RouteChooserWidget(forms.TextInput):
def render(self, name, value, attrs=None, area_name='', routefile_id=None,
initialized=True):
+ # bad initialization
+ if value == 'None':
+ value = ''
val = ''
if value:
val = str(value)
@@ -523,9 +525,9 @@ class RouteChooserWidget(forms.TextInput):
class RouteField(models.LineStringField):
- '''
+ """
Set the widget for the form field
- '''
+ """
def formfield(self, **keys):
defaults = {'widget': RouteChooserWidget}
keys.update(defaults)
@@ -541,9 +543,9 @@ class AreaWidget(forms.TextInput):
js = AREA_JS
def get_bounding_box_from_value(self, value):
- '''
+ """
Return upper left lat/lon and lower lat/lon from the input value
- '''
+ """
upper_left_lat, upper_left_lon = 0, 0
lower_right_lat, lower_right_lon = 0, 0
if not value:
@@ -669,9 +671,9 @@ class PolygonChooserWidget(forms.TextInput):
class PolygonField(models.PolygonField):
- '''
+ """
Set the widget for the form field
- '''
+ """
def formfield(self, **keys):
defaults = {'widget': PolygonChooserWidget}
keys.update(defaults)
@@ -749,10 +751,10 @@ class ImportFiltrWidget(AreaWidget):
return data.get('id_' + name, None)
def get_bounding_box_from_value(self, value):
- '''
+ """
Return upper left lat/lon, lower lat/lon from the input value.
Get also xapi type and xapi tag
- '''
+ """
upper_left_lat, upper_left_lon = 0, 0
lower_right_lat, lower_right_lon = 0, 0
self.xapi_type, self.xapi_tag, self.bounding_box = None, '', None
@@ -772,9 +774,9 @@ class ImportFiltrWidget(AreaWidget):
class AreaField(forms.MultiValueField):
- '''
+ """
Set the widget for the form field
- '''
+ """
widget = AreaWidget
def compress(self, data_list):
@@ -813,9 +815,9 @@ class MultiSelectWidget(forms.SelectMultiple):
class SelectMultipleField(models.ManyToManyField):
- '''
+ """
Set the widget for the category field
- '''
+ """
def formfield(self, **keys):
self.help_text = ""
defaults = {'widget': MultiSelectWidget}