Browse Source

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.
Baptiste Jonglez 6 years ago
parent
commit
8910759960
2 changed files with 2 additions and 2 deletions
  1. 1 1
      panorama/models.py
  2. 1 1
      panorama/templates/panorama/view.html

+ 1 - 1
panorama/models.py

@@ -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),

+ 1 - 1
panorama/templates/panorama/view.html

@@ -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" %} />