From 96456efd7677a5557268bdadb7d37a6a7f07678a Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sun, 14 Jun 2009 21:45:08 -0700 Subject: [PATCH] Fixed a bug in which some printed or exported notes appeared in alphabetical order instead of your chosen ordering. --- NEWS | 4 ++++ controller/test/Test_notebooks.py | 33 +++++++++++++++++-------------- model/Notebook.py | 2 +- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/NEWS b/NEWS index cb5bfc5..371e83f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,7 @@ +1.6.14: June 14, 2009 + * Fixed a bug in which some printed or exported notes appeared in + alphabetical order instead of your chosen ordering. + 1.6.13: May 20, 2009 * Added a dynamic preview of your current color selections to the color picker. This lets you see what the selected colors will look like as you diff --git a/controller/test/Test_notebooks.py b/controller/test/Test_notebooks.py index 1e3345c..88fa1c8 100644 --- a/controller/test/Test_notebooks.py +++ b/controller/test/Test_notebooks.py @@ -4632,19 +4632,20 @@ class Test_notebooks( Test_controller ): notes = result.get( "notes" ) assert len( notes ) == self.database.select_one( int, self.notebook.sql_count_notes() ) startup_note_allowed = True - previous_revision = None + previous_rank = True - # assert that startup notes come first, then normal notes in alphabetical order + # assert that startup notes come first, then normal notes. each group should be ordered by rank for note in notes: if note.startup: assert startup_note_allowed else: + previous_rank = None startup_note_allowed = False - if previous_revision: - assert note.revision < previous_revision + if previous_rank: + assert note.rank >= previous_rank - previous_revision = note.revision + previous_rank = note.rank db_note = self.database.load( Note, note.object_id ) assert db_note @@ -4712,9 +4713,9 @@ class Test_notebooks( Test_controller ): expected_note_count = self.database.select_one( int, self.notebook.sql_count_notes() ) note_count = 0 startup_note_allowed = True - previous_revision = None + previous_rank = None - # assert that startup notes come first, then normal notes in alphabetical order + # assert that startup notes come first, then normal notes. each group should be ordered by rank for row in reader: note_count += 1 @@ -4724,12 +4725,13 @@ class Test_notebooks( Test_controller ): if startup: assert startup_note_allowed else: + previous_rank = None startup_note_allowed = False - if previous_revision: - assert revision_date < previous_revision + if previous_rank: + assert note.rank >= previous_rank - previous_revision = revision_date + previous_rank = note.rank db_note = self.database.load( Note, note_id ) assert db_note @@ -4788,19 +4790,20 @@ class Test_notebooks( Test_controller ): notes = result.get( "notes" ) assert len( notes ) == self.database.select_one( int, self.notebook.sql_count_notes() ) startup_note_allowed = True - previous_revision = None + previous_rank = None - # assert that startup notes come first, then normal notes in alphabetical order + # assert that startup notes come first, then normal notes. each group should be ordered by rank for note in notes: if note.startup: assert startup_note_allowed else: + previous_rank = None startup_note_allowed = False - if previous_revision: - assert note.revision < previous_revision + if previous_rank: + assert note.rank >= previous_rank - previous_revision = note.revision + previous_rank = note.rank db_note = self.database.load( Note, note.object_id ) assert db_note diff --git a/model/Notebook.py b/model/Notebook.py index 4d1f2e2..95d4968 100644 --- a/model/Notebook.py +++ b/model/Notebook.py @@ -172,7 +172,7 @@ class Notebook( Persistent ): """ Return a SQL string to load a list of the non-startup notes within this notebook. """ - return "select id, revision, title, contents, notebook_id, startup, deleted_from_id, rank, user_id from note_current where notebook_id = %s and startup = 'f' order by lower( title );" % quote( self.object_id ) + return "select id, revision, title, contents, notebook_id, startup, deleted_from_id, rank, user_id from note_current where notebook_id = %s and startup = 'f' order by rank;" % quote( self.object_id ) def sql_load_startup_notes( self ): """