From 45f94aa188aa11cc9a258e4b1e8fe4066cc7903f Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Mon, 19 Nov 2007 22:03:04 +0000 Subject: [PATCH] Deleting a notebook forever now updates the user's storage usage accordingly. --- controller/Notebooks.py | 5 +++-- static/js/Wiki.js | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/controller/Notebooks.py b/controller/Notebooks.py index be514c4..97e31c4 100644 --- a/controller/Notebooks.py +++ b/controller/Notebooks.py @@ -872,7 +872,7 @@ class Notebooks( object ): @type user_id: unicode or NoneType @param user_id: id of current logged-in user (if any) @rtype dict - @return {} + @return: { 'storage_bytes': current storage usage by user } @raise Access_error: the current user doesn't have access to the given notebook @raise Validation_error: one of the arguments is invalid """ @@ -894,9 +894,10 @@ class Notebooks( object ): raise Access_error() self.__database.execute( user.sql_remove_notebook( notebook_id ), commit = False ) + user = self.__users.update_storage( user_id, commit = False ) self.__database.commit() - return dict() + return dict( storage_bytes = user.storage_bytes ) @expose( view = Json ) @grab_user_id diff --git a/static/js/Wiki.js b/static/js/Wiki.js index ecd2e16..773454e 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -1544,9 +1544,10 @@ Wiki.prototype.delete_notebook_forever = function ( event, notebook_id ) { if ( items.length == 0 ) removeElement( "deleted_notebooks" ); + var self = this; this.invoker.invoke( "/notebooks/delete_forever", "POST", { "notebook_id": notebook_id - } ); + }, function ( result ) { self.display_storage_usage( result.storage_bytes ); } ); event.stop(); }