[PATCH conductor] bug 861483: Fix default quota

Scott Seago sseago at redhat.com
Thu Oct 4 15:07:30 UTC 2012


https://bugzilla.redhat.com/show_bug.cgi?id=861483

Default quota now shows itself in two ways:
1) for admin-created users, the default quota is set as the default
 for the user quota in the new user form. It can still be edited
 before submitting, of course.
2) For ldap users, when a new conductor user is created, we now
   create the user with a quota value taken from the default.
---
 src/app/controllers/users_controller.rb | 2 +-
 src/app/models/quota.rb                 | 6 ++++++
 src/app/models/user.rb                  | 4 ++--
 src/config/locales/en.yml               | 6 +++---
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/app/controllers/users_controller.rb b/src/app/controllers/users_controller.rb
index 4a2868f..1aab7fe 100644
--- a/src/app/controllers/users_controller.rb
+++ b/src/app/controllers/users_controller.rb
@@ -39,7 +39,7 @@ class UsersController < ApplicationController
     require_privilege(Privilege::CREATE, User)
     @title = t'users.new.new_user'
     @user = User.new
-    @user.quota = Quota.new
+    @user.quota = Quota.new_for_user
   end
 
   def create
diff --git a/src/app/models/quota.rb b/src/app/models/quota.rb
index 2c8dcee..6615f3e 100644
--- a/src/app/models/quota.rb
+++ b/src/app/models/quota.rb
@@ -157,4 +157,10 @@ class Quota < ActiveRecord::Base
     end
     return false
   end
+
+  def self.new_for_user
+    self.new(:maximum_running_instances =>
+             MetadataObject.lookup("self_service_default_quota").
+             maximum_running_instances)
+  end
 end
diff --git a/src/app/models/user.rb b/src/app/models/user.rb
index ee7ba1f..5db8e95 100644
--- a/src/app/models/user.rb
+++ b/src/app/models/user.rb
@@ -199,11 +199,11 @@ class User < ActiveRecord::Base
   end
 
   def self.create_ldap_user!(username)
-    User.create!(:username => username, :quota => Quota.new, :ignore_password => true)
+    User.create!(:username => username, :quota => Quota.new_for_user, :ignore_password => true)
   end
 
   def self.create_krb_user!(username)
-    User.create!(:username => username, :quota => Quota.new, :ignore_password => true)
+    User.create!(:username => username, :quota => Quota.new_for_user, :ignore_password => true)
   end
 
   def ensure_not_running_any_instances
diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
index 1955d2d..8a1dd24 100644
--- a/src/config/locales/en.yml
+++ b/src/config/locales/en.yml
@@ -1146,10 +1146,10 @@ en:
   settings:
     settings: Settings
     index:
-      permissions: Permissions
-      permissions_desc: Modify self-service default quota.
+      permissions: User defaults
+      permissions_desc: Modify default user settings
     self_service:
-      self_service_default: 'User Treatment: Self-service default'
+      self_service_default: 'Default user settings'
       account: Account
       instances_quota: "Instances Quota:"
       self_service_settings: "Self-service Settings"
-- 
1.7.11.4




More information about the aeolus-devel mailing list