Ghini / ghini.desktop

plant collections manager (desktop version)
http://ghini.github.io/
GNU General Public License v2.0
24 stars 14 forks source link

Source names not sorted #459

Closed cwyse closed 3 years ago

cwyse commented 5 years ago

As a user, I want to see the source drop down list in alphabetical order, so that I can easily find existing sources.

Expected behaviour

Source dropdown menu in Accessions Editor should be sorted.

Actual behaviour

Sources are ordered by when they were added to the database.

Steps to reproduce the behaviour

From Accessions editor, click on sources dropdown.

How to set up the same initial situation

I'm running Windows 10, Ghini 1.0.90.

Which actions to take in sequence, which contribute to create the critical situation

Just click the dropdown.

Last step, with the unexpected result

Opinions and suggestions

Here's what I did:

diff --git a/bauble/plugins/garden/accession.py b/bauble/plugins/garden/accession.py
index e9a52710..6698b530 100755
--- a/bauble/plugins/garden/accession.py
+++ b/bauble/plugins/garden/accession.py
@@ -1632,7 +1632,7 @@ class SourcePresenter(editor.GenericEditorPresenter):
         model = gtk.ListStore(object)
         none_iter = model.append([''])
         model.append([self.garden_prop_str])
-        map(lambda x: model.append([x]), self.session.query(Contact))
+        map(lambda x: model.append([x]), self.session.query(Contact).order_by(Contact.name))
         combo.set_model(model)
         combo.child.get_completion().set_model(model)