On 10/15/10 - 03:32:37PM, [email protected] wrote: > From: martyntaylor <[email protected]> > > --- > src/app/controllers/quota_controller.rb | 3 ++- > src/app/models/quota.rb | 13 +++++++++++-- > 2 files changed, 13 insertions(+), 3 deletions(-) > > diff --git a/src/app/controllers/quota_controller.rb > b/src/app/controllers/quota_controller.rb > index 0cc1e2f..dc14d34 100644 > --- a/src/app/controllers/quota_controller.rb > +++ b/src/app/controllers/quota_controller.rb > @@ -51,7 +51,8 @@ class QuotaController < ApplicationController > flash[:notice] = "Quota updated!" > redirect_to :action => 'show', :id => @parent, :parent_type => > @parent_type > else > - render :action => :edit > + flash[:notice] = "Could not update quota, please check you have > entered valid values" > + redirect_to :action => :edit, :id => @parent, :parent_type => > @parent_type > end > end > > diff --git a/src/app/models/quota.rb b/src/app/models/quota.rb > index ad35076..83c20c4 100644 > --- a/src/app/models/quota.rb > +++ b/src/app/models/quota.rb > @@ -25,8 +25,17 @@ class Quota < ActiveRecord::Base > has_one :cloud_account > has_one :user > > - validates_numericality_of :maximum_total_instances, > :greater_than_or_equal_to => 0, :allow_nil => true > - validates_numericality_of :maximum_running_instances, > :greater_than_or_equal_to => 0, :allow_nil => true > + validates_numericality_of :maximum_total_instances, > + :greater_than_or_equal_to => 0, > + :less_than_or_equal_to => 2147483647, > + :integer_only => true, > + :allow_nil => true > + > + validates_numericality_of :maximum_running_instances, > + :greater_than_or_equal_to => 0, > + :less_than_or_equal_to => 2147483647, > + :integer_only => true, > + :allow_nil => true > > QuotaResource = Struct.new(:name, :used, :max, :available, :unit)
The model update looks fine. There are two problems I ran into with the controller part: 1) There is no way to navigate to the Edit Pool page anymore in the UI, so I had to go directly to: http://host/deltacloud/quota/edit/1?parent_type=pool. That's fine. If I fill in the fields with bogus numbers, it fails with the "flash" message as expected, but what it does not do is highlight the offending fields in red. Other validation errors seem to do this, so there might be a bug in the controller here. 2) You *can* navigate directly to editing quotas for users (System Settings-> Manage Users->edit). In that case, the validation still happens, but we don't have the flash message, so there is no indication that there is a problem. On top of that, the page returned looks ugly (there is a huge gap of whitespace), so I think we still need to fix the controller here. -- Chris Lalancette _______________________________________________ deltacloud-devel mailing list [email protected] https://fedorahosted.org/mailman/listinfo/deltacloud-devel
