From 799e0c12b004b4cebdf9787045751ca2f3b39c7c Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Sat, 13 Dec 2008 00:19:15 -0800 Subject: [PATCH] Fixed a bug in which forum post permalinks didn't work on posts after the first ten in a particular thread. --- NEWS | 4 ++- controller/Forums.py | 6 ++++- controller/test/Test_forums.py | 48 ++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 7b0193a..4c75467 100644 --- a/NEWS +++ b/NEWS @@ -2,9 +2,11 @@ * Added a font selection button to the toolbar. * Decreased the default note text font size, so now you can see more of your note text at once. - * Added more rounded corners to several display elements. + * Added rounded corners to several display elements. * Fixed a Luminotes Desktop bug in which creating and then clicking on a new note link sometimes caused a red error message. + * Fixed a bug in which forum post permalinks didn't work on posts after the + first ten in a particular thread. 1.5.10: December 4, 2008 * Fixed a bug in which certain new installations of Luminotes Desktop diff --git a/controller/Forums.py b/controller/Forums.py index 44652df..c9f47c5 100644 --- a/controller/Forums.py +++ b/controller/Forums.py @@ -212,7 +212,11 @@ class Forum( object ): # if a single note was requested, just return that one note if note_id: - result[ "notes" ] = [ note for note in result[ "notes" ] if note.object_id == note_id ] + note = self.__database.load( Note, note_id ) + if note: + result[ "notes" ] = [ note ] + else: + result[ "notes" ] = [] return result diff --git a/controller/test/Test_forums.py b/controller/test/Test_forums.py index 2ab4e61..041a39a 100644 --- a/controller/test/Test_forums.py +++ b/controller/test/Test_forums.py @@ -268,6 +268,54 @@ class Test_forums( Test_controller ): user = self.database.load( User, self.user.object_id ) assert user.storage_bytes == 0 + def test_general_thread_default_with_unknown_note_id( self ): + result = self.http_get( "/forums/general/%s?note_id=unknownid" % self.general_thread.object_id ) + + assert result.get( u"user" ).object_id == self.anonymous.object_id + assert len( result.get( u"notebooks" ) ) == 4 + assert result.get( u"notebooks" )[ 0 ].object_id == self.anon_notebook.object_id + assert result.get( u"login_url" ) + assert result.get( u"logout_url" ) + assert result.get( u"rate_plan" ) + assert result.get( u"notebook" ).object_id == self.general_thread.object_id + assert len( result.get( u"startup_notes" ) ) == 0 + assert result.get( u"notes" ) == [] + assert result.get( u"parent_id" ) == None + assert result.get( u"note_read_write" ) in ( None, True ) + assert result.get( u"total_notes_count" ) == 0 + + invites = result[ "invites" ] + assert len( invites ) == 0 + + user = self.database.load( User, self.user.object_id ) + assert user.storage_bytes == 0 + + def test_general_thread_default_with_note_id( self ): + self.__make_notes() + + result = self.http_get( "/forums/general/%s?note_id=%s" % ( self.general_thread.object_id, self.note.object_id ) ) + + assert result.get( u"user" ).object_id == self.anonymous.object_id + assert len( result.get( u"notebooks" ) ) == 4 + assert result.get( u"notebooks" )[ 0 ].object_id == self.anon_notebook.object_id + assert result.get( u"login_url" ) + assert result.get( u"logout_url" ) + assert result.get( u"rate_plan" ) + assert result.get( u"notebook" ).object_id == self.general_thread.object_id + assert len( result.get( u"startup_notes" ) ) == 3 + assert len( result.get( u"notes" ) ) == 1 + assert result.get( u"notes" )[ 0 ].object_id == self.note.object_id + assert result[ u"notes" ][ 0 ].title == u"foo" + assert result.get( u"parent_id" ) == None + assert result.get( u"note_read_write" ) in ( None, True ) + assert result.get( u"total_notes_count" ) == 3 + + invites = result[ "invites" ] + assert len( invites ) == 0 + + user = self.database.load( User, self.user.object_id ) + assert user.storage_bytes == 0 + def test_general_thread_default_with_login( self ): self.login()