diff --git a/NEWS b/NEWS index 7239d73..75a775a 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ 1.4.11: June 29, 2008: * Fixed bug in which bolding of suggest-as-you-type search text was case sensitive. Now it's case insensitive. + * controller.Root.guide() now accepts an optional note_id parameter. 1.4.10: June 29, 2008: * New suggest-as-you-type feature for creating a new link, setting a link's diff --git a/controller/Root.py b/controller/Root.py index 7490c6a..460b29d 100644 --- a/controller/Root.py +++ b/controller/Root.py @@ -229,6 +229,8 @@ class Root( object ): @param start: index of recent note to start with (defaults to 0, the most recent note) @type count: int or NoneType @param count: number of recent notes to display (defaults to 10 notes) + @type note_id: unicode or NoneType + @param note_id: id of single note to load (optional) @rtype: unicode @return: rendered HTML page @raise Validation_error: one of the arguments is invalid @@ -250,12 +252,15 @@ class Root( object ): @end_transaction @grab_user_id @validate( + note_id = Valid_id( none_okay = True ), user_id = Valid_id( none_okay = True ), ) - def guide( self, user_id = None ): + def guide( self, note_id = None, user_id = None ): """ Provide the information necessary to display the Luminotes user guide. + @type note_id: unicode or NoneType + @param note_id: id of single note to load (optional) @rtype: unicode @return: rendered HTML page @raise Validation_error: one of the arguments is invalid @@ -265,6 +270,10 @@ class Root( object ): result.update( self.__notebooks.contents( guide_notebooks[ 0 ].object_id, user_id = user_id ) ) + # if a single note was requested, just return that one note + if note_id: + result[ "startup_notes" ] = [ note for note in result[ "startup_notes" ] if note.object_id == note_id ] + return result @expose( view = Main_page ) diff --git a/controller/test/Test_root.py b/controller/test/Test_root.py index be7ffb2..7cde88d 100644 --- a/controller/test/Test_root.py +++ b/controller/test/Test_root.py @@ -347,6 +347,15 @@ class Test_root( Test_controller ): assert u"error" not in result assert result[ u"notebook" ].object_id == self.guide_notebook.object_id + def test_guide_with_note_id( self ): + result = self.http_get( + "/guide?note_id=%s" % self.guide_note.object_id, + ) + + assert result + assert u"error" not in result + assert result[ u"notebook" ].object_id == self.guide_notebook.object_id + def test_privacy( self ): result = self.http_get( "/privacy",