diff --git a/controller/Root.py b/controller/Root.py index d4d7a3e..40b5e37 100644 --- a/controller/Root.py +++ b/controller/Root.py @@ -134,7 +134,29 @@ class Root( object ): result = self.__users.current( user_id = None ) blog_notebooks = [ nb for nb in result[ "notebooks" ] if nb.name == u"Luminotes blog" ] - return self.__notebooks.load_recent_notes( blog_notebooks[ 0 ].object_id, start, count, user_id ) + result.update( self.__notebooks.load_recent_notes( blog_notebooks[ 0 ].object_id, start, count, user_id ) ) + + return result + + @expose( view = Main_page ) + @grab_user_id + @validate( + user_id = Valid_id( none_okay = True ), + ) + def guide( self, user_id = None ): + """ + Provide the information necessary to display the Luminotes user guide. + + @rtype: unicode + @return: rendered HTML page + @raise Validation_error: one of the arguments is invalid + """ + result = self.__users.current( user_id = None ) + guide_notebooks = [ nb for nb in result[ "notebooks" ] if nb.name == u"Luminotes user guide" ] + + result.update( self.__notebooks.contents( guide_notebooks[ 0 ].object_id, user_id = user_id ) ) + + return result # TODO: move this method to controller.Notebooks, and maybe give it a more sensible name @expose( view = Json ) diff --git a/controller/test/Test_root.py b/controller/test/Test_root.py index be1df63..57f1e77 100644 --- a/controller/test/Test_root.py +++ b/controller/test/Test_root.py @@ -29,6 +29,14 @@ class Test_root( Test_controller ): ) self.database.save( self.blog_note ) + self.guide_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes user guide" ) + self.database.save( self.guide_notebook ) + self.guide_note = Note.create( + self.database.next_id( Note ), u"

it's all self-explanatory

", + notebook_id = self.guide_notebook.object_id, + ) + self.database.save( self.guide_note ) + self.username = u"mulder" self.password = u"trustno1" self.email_address = u"outthere@example.com" @@ -43,6 +51,7 @@ class Test_root( Test_controller ): self.database.save( self.anonymous ) self.database.execute( self.anonymous.sql_save_notebook( self.anon_notebook.object_id ) ) self.database.execute( self.anonymous.sql_save_notebook( self.blog_notebook.object_id ) ) + self.database.execute( self.anonymous.sql_save_notebook( self.guide_notebook.object_id ) ) def test_index( self ): result = self.http_get( "/" ) @@ -116,6 +125,13 @@ class Test_root( Test_controller ): assert result + def test_guide( self ): + result = self.http_get( + "/guide", + ) + + assert result + def test_next_id( self ): result = self.http_get( "/next_id" )