summaryrefslogtreecommitdiff
path: root/chimere/main/widgets.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/main/widgets.py')
-rw-r--r--chimere/main/widgets.py39
1 files changed, 24 insertions, 15 deletions
diff --git a/chimere/main/widgets.py b/chimere/main/widgets.py
index caac0ea..083fbec 100644
--- a/chimere/main/widgets.py
+++ b/chimere/main/widgets.py
@@ -147,7 +147,7 @@ class RouteChooserWidget(forms.TextInput):
js = ["%sedit_route_map.js" % settings.MEDIA_URL,
"%sbase.js" % settings.MEDIA_URL,] + URL_OSM_JS
- def render(self, name, value, attrs=None, area_name=''):
+ def render(self, name, value, attrs=None, area_name='', routefile_id=None):
'''
Render a map and latitude, longitude information field
'''
@@ -159,25 +159,35 @@ class RouteChooserWidget(forms.TextInput):
<p>%s</p>
<p>%s</p>
<p>%s</p>
-<p>%s</p>""" % (_("Creation mode"),
-_("To start drawing the route click on the toggle button : \"Start drawing\"."),
-_("Then click on the map to begin the drawing."),
-_("You can add points by clicking again."),
-_("To finish the drawing double click. When the drawing is finished you can \
+<p>%s</p>""" % (_(u"Creation mode"),
+_(u"To start drawing the route click on the toggle button : \"Start drawing\"."),
+_(u"Then click on the map to begin the drawing."),
+_(u"You can add points by clicking again."),
+_(u"To finish the drawing double click. When the drawing is finished you can \
edit it."),
-_("While creating to undo a drawing click again on the toggle button \"Stop \
+_(u"While creating to undo a drawing click again on the toggle button \"Stop \
drawing\"."))
help_modify = """<h3>%s</h3>
<p>%s</p>
<p>%s</p>
-<p>%s</p>""" % (_("Modification mode"),
-_("To move a point click on it and drag it to the desired position."),
-_("To delete a point move the mouse cursor over it and press the \"d\" key."),
-_("To add a point click in the middle of a segment and drag the new point to \
+<p>%s</p>""" % (_(u"Modification mode"),
+_(u"To move a point click on it and drag it to the desired position."),
+_(u"To delete a point move the mouse cursor over it and press the \"d\" or \
+\"Del\" key."),
+_(u"To add a point click in the middle of a segment and drag the new point to \
the desired position"))
tpl += u'<script src="%sedit_route_map.js"></script>\n' % \
settings.MEDIA_URL
if not value:
+ # upload a file
+ tpl += u"""<script type='text/javascript'><!--
+ var error_msg = "%s";
+// --></script>
+""" % _(u"Give a name and set category before uploading a file.")
+ tpl += u'<div class="upload"><a href="#" class="upload-button" '\
+ u'onclick="uploadFile(error_msg);return false;">%s</a></div>' % (
+ _(u"Upload a route file (GPX or KML)"))
+
tpl += u"""<div id='draw-toggle-off' class='toggle-button' \
onclick='toggleDrawOn();'>%s</div>
<div id='draw-toggle-on' class='toggle-button' \
@@ -195,7 +205,9 @@ onclick='toggleDrawOff();'>%s</div>
<div class='help-route' id='help-route-modify'%s>%s</div>
<hr class='spacer'/>
<input type='hidden' name='%s' id='id_%s' value="%s"/>
-""" % (style, help_modify, name, name, value)
+<input type='hidden' name='associated_file_id' id='id_associated_file_id' \
+value="%s"/>
+""" % (style, help_modify, name, name, value, routefile_id)
tpl += "<script type='text/javascript'><!--\n"
tpl += "init();\n"
if value:
@@ -212,9 +224,6 @@ initFeature(geometry);""" % val.json
tpl += """
// --></script>
"""
- tpl += u'<a href="#" class="add-button" '\
- u'onclick="open_window(\'%supload_file\');">%s</a>' % (
- settings.BASE_URL, _(u"Upload a route file (GPX or KML)"))
return mark_safe(tpl)
class RouteField(models.LineStringField):