From ebd427d667b57c98c38854ed704180277c1d9e04 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 13 Nov 2007 00:59:19 +0000 Subject: [PATCH] Make privacy policy accessible from sane URL. --- controller/Root.py | 20 ++++++++++++++++++++ controller/test/Test_root.py | 17 +++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/controller/Root.py b/controller/Root.py index d132359..b4fa32a 100644 --- a/controller/Root.py +++ b/controller/Root.py @@ -166,6 +166,26 @@ class Root( object ): return result + @expose( view = Main_page ) + @grab_user_id + @validate( + user_id = Valid_id( none_okay = True ), + ) + def privacy( self, user_id = None ): + """ + Provide the information necessary to display the Luminotes privacy policy. + + @rtype: unicode + @return: rendered HTML page + @raise Validation_error: one of the arguments is invalid + """ + result = self.__users.current( user_id ) + privacy_notebooks = [ nb for nb in result[ "notebooks" ] if nb.name == u"Luminotes privacy policy" ] + + result.update( self.__notebooks.contents( privacy_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 ) def next_id( self ): diff --git a/controller/test/Test_root.py b/controller/test/Test_root.py index 735e11a..2fc7964 100644 --- a/controller/test/Test_root.py +++ b/controller/test/Test_root.py @@ -37,6 +37,14 @@ class Test_root( Test_controller ): ) self.database.save( self.guide_note ) + self.privacy_notebook = Notebook.create( self.database.next_id( Notebook ), u"Luminotes privacy policy" ) + self.database.save( self.privacy_notebook ) + self.privacy_note = Note.create( + self.database.next_id( Note ), u"

yay privacy

", + notebook_id = self.privacy_notebook.object_id, + ) + self.database.save( self.privacy_note ) + self.username = u"mulder" self.password = u"trustno1" self.email_address = u"outthere@example.com" @@ -52,6 +60,7 @@ class Test_root( Test_controller ): 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 ) ) + self.database.execute( self.anonymous.sql_save_notebook( self.privacy_notebook.object_id ) ) def test_index( self ): result = self.http_get( "/" ) @@ -150,6 +159,14 @@ class Test_root( Test_controller ): assert result assert u"error" not in result + def test_privacy( self ): + result = self.http_get( + "/privacy", + ) + + assert result + assert u"error" not in result + def test_next_id( self ): result = self.http_get( "/next_id" )