witten
/
luminotes
Archived
1
0
Fork 0

If a user's rate plan storage quota is None (indicate no quota), don't calculate the user's storage quota.

This commit is contained in:
Dan Helfman 2008-08-18 18:00:45 -07:00
parent 9d4a33218f
commit ef83061d12
2 changed files with 24 additions and 4 deletions

View File

@ -674,7 +674,8 @@ class Users( object ):
def update_storage( self, user_id, commit = True ):
"""
Calculate and record total storage utilization for the given user.
If there is a storage quota for the user's rate plan, calculate and record total storage
utilization for the given user. If there isn't a storage quota, then bail.
@type user_id: unicode
@param user_id: id of user for which to calculate storage utilization
@ -685,9 +686,15 @@ class Users( object ):
"""
user = self.__database.load( User, user_id )
if user:
user.storage_bytes = self.calculate_storage( user )
self.__database.save( user, commit )
if user is None:
return None
plan = self.__rate_plans[ user.rate_plan ]
if not plan[ "storage_quota_bytes" ]:
return user
user.storage_bytes = self.calculate_storage( user )
self.__database.save( user, commit )
return user

View File

@ -877,6 +877,19 @@ class Test_users( Test_controller ):
assert self.user.group_storage_bytes == 0
assert self.user.revision == original_revision
def test_update_storage_without_quota( self ):
original_revision = self.user.revision
self.settings[ u"global" ][ u"luminotes.rate_plans" ][ 0 ][ u"storage_bytes" ] = None
cherrypy.root.users.update_storage( self.user.object_id )
expected_size = cherrypy.root.users.calculate_storage( self.user )
user = self.database.load( User, self.user.object_id )
assert self.user.storage_bytes == 0
assert self.user.group_storage_bytes == 0
assert self.user.revision == original_revision
def test_check_access( self ):
access = cherrypy.root.users.check_access( self.user.object_id, self.notebooks[ 0 ].object_id )