witten
/
luminotes
Archived
1
0
Fork 0

Handy way to load the user's guide.

This commit is contained in:
Dan Helfman 2007-11-06 22:42:53 +00:00
parent 051339330c
commit 7552157865
2 changed files with 39 additions and 1 deletions

View File

@ -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 )

View File

@ -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"<h3>it's all self-explanatory</h3>",
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" )