diff --git a/controller/Notebooks.py b/controller/Notebooks.py index 1bd816f..cbd2e7c 100644 --- a/controller/Notebooks.py +++ b/controller/Notebooks.py @@ -118,7 +118,7 @@ class Notebooks( object ): if not notebook: raise Access_error() if notebook.name != u"Luminotes": - result[ "recent_notes" ] = self.__database.select_many( Note, notebook.sql_load_recent_notes( start = 0, count = 10 ) ) + result[ "recent_notes" ] = self.__database.select_many( Note, notebook.sql_load_notes( start = 0, count = 10 ) ) # if the user doesn't have any storage bytes yet, they're a new user, so see what type of # conversion this is (demo or signup) diff --git a/controller/test/Test_controller.py b/controller/test/Test_controller.py index 953a910..950f402 100644 --- a/controller/test/Test_controller.py +++ b/controller/test/Test_controller.py @@ -216,7 +216,7 @@ class Test_controller( object ): Note.sql_load_revisions = lambda self: \ lambda database: sql_load_revisions( self, database ) - def sql_load_notes( self, database ): + def sql_load_notes( self, start, count, database ): notes = [] for ( object_id, obj_list ) in database.objects.items(): @@ -225,10 +225,13 @@ class Test_controller( object ): notes.append( obj ) notes.sort( lambda a, b: -cmp( a.revision, b.revision ) ) - return notes + if count is None: + return notes[ start : ] + else: + return notes[ start : start + count ] - Notebook.sql_load_notes = lambda self: \ - lambda database: sql_load_notes( self, database ) + Notebook.sql_load_notes = lambda self, start = 0, count = None: \ + lambda database: sql_load_notes( self, start, count, database ) def sql_load_startup_notes( self, database ): notes = [] diff --git a/model/Notebook.py b/model/Notebook.py index cd9c99a..8323e68 100644 --- a/model/Notebook.py +++ b/model/Notebook.py @@ -100,11 +100,16 @@ class Notebook( Persistent ): def sql_update( self ): return self.sql_create() - def sql_load_notes( self ): + def sql_load_notes( self, start = 0, count = None ): """ Return a SQL string to load a list of all the notes within this notebook. """ - return "select id, revision, title, contents, notebook_id, startup, deleted_from_id, rank, user_id from note_current where notebook_id = %s order by revision desc;" % quote( self.object_id ) + if count is not None: + limit_clause = " limit %s" % count + else: + limit_clause = "" + + return "select id, revision, title, contents, notebook_id, startup, deleted_from_id, rank, user_id from note_current where notebook_id = %s order by revision desc offset %s%s;" % ( quote( self.object_id ), start, limit_clause ) def sql_load_non_startup_notes( self ): """ diff --git a/view/Notebook_rss.py b/view/Notebook_rss.py index 9c058ab..051215c 100644 --- a/view/Notebook_rss.py +++ b/view/Notebook_rss.py @@ -26,6 +26,8 @@ class Notebook_rss( Rss_channel ): invites = None, invite_id = None, after_login = None, + signup_plan = None, + recent_notes = None, ): if notebook.name == u"Luminotes": notebook_path = u"/" @@ -47,7 +49,7 @@ class Notebook_rss( Rss_channel ): title = cgi.escape( note.title ), link = u"%s?note_id=%s" % ( notebook_path, note.object_id ), description = cgi.escape( note.contents ), - date = note.creation.strftime( "%Y-%m-%dT%H:%M:%SZ" ), + date = ( note.creation or note.revision ).strftime( "%Y-%m-%dT%H:%M:%SZ" ), guid = u"%s?note_id=%s" % ( notebook_path, note.object_id ), - ) for note in notes ], + ) for note in recent_notes or notes ], )