Commit 89107599 authored by Baptiste Jonglez's avatar Baptiste Jonglez

Sort reference points by name when inserting a new refpoint in a panorama

With lots of reference points, the current sorting by distance is really
not usable.  Sorting by name allows to more easily find a given refpoint
in the list.

While we're at it, display the distance in the dropdown menu so that it's
easier to check if it's the right refpoint.
parent ce2336fe
......@@ -208,7 +208,7 @@ class Panorama(ReferencePoint):
refpoints = [refpoint for refpoint in ReferencePoint.objects.all()
if self.great_circle_distance(refpoint) <= settings.PANORAMA_MAX_DISTANCE and refpoint.pk != self.pk]
refpoints.sort(key=lambda r: self.line_distance(r))
refpoints.sort(key=lambda r: r.name)
return enumerate([{"id": r.pk,
"name": r.name,
"url": get_url(r),
......
......@@ -189,7 +189,7 @@ style="padding-left:0px"
<p id="info"></p>
<p id="insert"><select id="sel_point" name="known_points">
{% for id, refpoint in panorama.refpoints_data %}
<option>{{ refpoint.name }}</option>
<option>{{ refpoint.name }} ({{ refpoint.distance|distance }})</option>
{% endfor %}
</select>
<input type="button" id="do-insert" class="btn btn-primary btn-sm" value={% trans "Insert" %} />
......
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