From 5f852a3d8e8c197a260fc6fa4cccd7980c5e0a6d Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 29 Apr 2008 21:26:09 +0000 Subject: [PATCH] Bug fix: Used to get access error when you loaded the children links for a note that was in the trash. --- controller/Notebooks.py | 6 +++++- controller/test/Test_notebooks.py | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/controller/Notebooks.py b/controller/Notebooks.py index ced345a..6e3a297 100644 --- a/controller/Notebooks.py +++ b/controller/Notebooks.py @@ -543,8 +543,12 @@ class Notebooks( object ): if not self.__users.check_access( user_id, notebook_id ): raise Access_error() + notebook = self.__database.load( Notebook, notebook_id ) + if not notebook: + raise Access_error() + note = self.__database.load( Note, note_id ) - if note is None or note.notebook_id != notebook_id: + if note is None or note.notebook_id not in ( notebook_id, notebook.trash_id ): raise Access_error() items = [] diff --git a/controller/test/Test_notebooks.py b/controller/test/Test_notebooks.py index b0b7172..1a18223 100644 --- a/controller/test/Test_notebooks.py +++ b/controller/test/Test_notebooks.py @@ -1183,6 +1183,25 @@ class Test_notebooks( Test_controller ): assert link % u' class="note_tree_link"' in html assert u"tree_expander_empty" in html + def test_load_note_links_of_note_in_trash( self ): + self.login() + + link = u'link to note2' + self.note.contents = u"

blah

this is a %s" % ( link % "" ) + self.note.deleted_from_id = self.note.notebook_id + self.note.notebook_id = self.trash.object_id + self.database.save( self.note ) + + result = self.http_post( "/notebooks/load_note_links/", dict( + notebook_id = self.notebook.object_id, + note_id = self.note.object_id, + ), session_id = self.session_id ) + + html = result.get( "tree_html" ) + assert u"