From f308f38fc5fe998d137421f0de29096c2f5d9ffd Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Wed, 31 Aug 2011 18:09:24 +0200 Subject: [PATCH] feature #788: Add delete quota functionality --- src/authm_mad/remotes/quota/onequota | 8 ++++++++ src/authm_mad/remotes/quota/quota.rb | 15 ++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/authm_mad/remotes/quota/onequota b/src/authm_mad/remotes/quota/onequota index dd0705cd60..a6fd24e669 100755 --- a/src/authm_mad/remotes/quota/onequota +++ b/src/authm_mad/remotes/quota/onequota @@ -130,6 +130,14 @@ cmd=CommandParser::CmdParser.new(ARGV) do exit_with_code 0 end + ######################################################################## + delete_desc = "Delete the defined quotas for the given user" + + command :delete, delete_desc, :userid do + quota.delete_quota(args[0]) + exit_with_code 0 + end + ######################################################################## show_desc = "Show the user's quota and usage. (usage/quota)" diff --git a/src/authm_mad/remotes/quota/quota.rb b/src/authm_mad/remotes/quota/quota.rb index 93014848c1..9e259e271d 100644 --- a/src/authm_mad/remotes/quota/quota.rb +++ b/src/authm_mad/remotes/quota/quota.rb @@ -127,13 +127,22 @@ class Quota if limit limit else - @conf[:defaults] + @conf[:defaults].merge!(:uid => uid) end else @db[table].all end end + # Delete user limits + def delete(table, uid) + quotas=@db[table].filter(:uid => uid) + + if quotas.first + quotas.delete + end + end + ########################################################################### # Quota Client ########################################################################### @@ -145,6 +154,10 @@ class Quota get(QUOTA_TABLE, uid) end + def delete_quota(uid) + delete(QUOTA_TABLE, uid) + end + ########################################################################### # Authorization ###########################################################################