witten
/
luminotes
Archived
1
0
Fork 0

When redirected to a note in the main notebook as a result of accessing, for

instance, the "/upgrade" URL, your no longer appear to get logged out.
This commit is contained in:
Dan Helfman 2008-01-05 00:42:50 +00:00
parent 0086c6366b
commit 980ad74e79
3 changed files with 29 additions and 8 deletions

View File

@ -43,11 +43,13 @@ class Root( object ):
self.__notebooks = Notebooks( database, self.__users )
@expose( Main_page )
@grab_user_id
@validate(
note_title = unicode,
invite_id = Valid_id( none_okay = True ),
user_id = Valid_id( none_okay = True ),
)
def default( self, note_title, invite_id = None ):
def default( self, note_title, invite_id = None, user_id = None ):
"""
Convenience method for accessing a note in the main notebook by name rather than by note id.
@ -69,16 +71,18 @@ class Root( object ):
else:
return dict( redirect = u"%s/%s" % ( https_url, note_title ) )
result = self.__users.current( user_id = None )
first_notebook = result[ u"notebooks" ][ 0 ]
user_id = result[ u"user" ].object_id
anonymous = self.__database.select_one( User, User.sql_load_by_username( u"anonymous" ) )
if anonymous:
main_notebook = self.__database.select_one( Notebook, anonymous.sql_load_notebooks( undeleted_only = True ) )
result = self.__users.current( user_id = user_id )
note_title = note_title.replace( u"_", " " )
note = self.__database.select_one( Note, first_notebook.sql_load_note_by_title( note_title ) )
note = self.__database.select_one( Note, main_notebook.sql_load_note_by_title( note_title ) )
if not note:
raise cherrypy.NotFound
result.update( self.__notebooks.contents( first_notebook.object_id, user_id = user_id, note_id = note.object_id ) )
result.update( self.__notebooks.contents( main_notebook.object_id, user_id = user_id, note_id = note.object_id ) )
if invite_id:
result[ "invite_id" ] = invite_id

View File

@ -102,6 +102,7 @@ class Test_root( Test_controller ):
assert len( result[ u"notes" ] ) == 1
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
assert result[ u"user" ].object_id == self.anonymous.object_id
def test_default_with_invite_id( self ):
result = self.http_get(
@ -114,6 +115,22 @@ class Test_root( Test_controller ):
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
assert result[ u"invite_id" ] == u"whee"
assert result[ u"user" ].object_id == self.anonymous.object_id
def test_default_after_login( self ):
self.login()
result = self.http_get(
"/my_note",
session_id = self.session_id,
)
assert result
assert result[ u"notes" ]
assert len( result[ u"notes" ] ) == 1
assert result[ u"notes" ][ 0 ].object_id == self.anon_note.object_id
assert result[ u"notebook" ].object_id == self.anon_notebook.object_id
assert result[ u"user" ].object_id == self.user.object_id
def test_default_with_unknown_note( self ):
result = self.http_get(

View File

@ -1,6 +1,6 @@
<h3>this is a demo</h3>
<p>
Once you've finished trying out the demo, feel free to logout and sign up for
an actual account. Then you can get started creating your own wiki!
Once you've finished trying out the demo, feel free to click the "sign up"
link above to get started creating your own wiki!
</p>