diff --git a/BrainPortal/app/controllers/quotas_controller.rb b/BrainPortal/app/controllers/quotas_controller.rb index db269b4b0..975c3c95e 100644 --- a/BrainPortal/app/controllers/quotas_controller.rb +++ b/BrainPortal/app/controllers/quotas_controller.rb @@ -113,7 +113,6 @@ def new def update #:nodoc: id = params[:id].presence # can be nil if we create() a new quota object @mode = params[:mode].to_s == 'cpu' ? :cpu : :disk - @quota = Quota.find(id) unless id.blank? if @quota # Set mode to sane version no matter what @@ -421,4 +420,3 @@ def guess_time_units(timestring) end end - diff --git a/BrainPortal/app/helpers/select_box_helper.rb b/BrainPortal/app/helpers/select_box_helper.rb index c0bc8869b..7ab30bdf6 100644 --- a/BrainPortal/app/helpers/select_box_helper.rb +++ b/BrainPortal/app/helpers/select_box_helper.rb @@ -33,6 +33,8 @@ module SelectBoxHelper # [selector] used for default selection. This can be a User object, a user id (String or Integer), # or any model that has a user_id attribute. # [users] the array of User objects used to build the select box. Defaults to +current_user.available_users+. + # [include_blank] - include blank value with specific label + # [special_label] - inject special value and label def user_select(parameter_name = "user_id", options = {}, select_tag_options = {} ) options = { :selector => options } unless options.is_a?(Hash) selector = options[:selector] @@ -52,6 +54,13 @@ def user_select(parameter_name = "user_id", options = {}, select_tag_options = { # Final HTML rendering of the options for select user_by_lock_status = regroup_users_by_lock_status(users) grouped_options = grouped_options_for_select user_by_lock_status, selected + + special_label = select_tag_options.delete(:special_label) || options[:special_label] + if special_label + label, value = special_label + grouped_options = "".html_safe + grouped_options + end + blank_label = select_tag_options.delete(:include_blank) || options[:include_blank] if blank_label blank_label = "" if blank_label == true @@ -617,4 +626,3 @@ def uploadable_data_providers(user=current_user) end end - diff --git a/BrainPortal/app/models/cpu_quota.rb b/BrainPortal/app/models/cpu_quota.rb index 631d45c5a..482fc9bf5 100644 --- a/BrainPortal/app/models/cpu_quota.rb +++ b/BrainPortal/app/models/cpu_quota.rb @@ -81,6 +81,11 @@ def is_for_user? #:nodoc: self.user_id != 0 end + # currently only for total task cap for all the users + def is_for_total? #:nodoc: + self.user_id == Quota::ALL_USERS + end + def is_for_resource? #:nodoc: self.remote_resource_id != 0 end @@ -280,10 +285,12 @@ def limits_are_reasonable # # - - y case 3 # # y y - case 4 # # - y y case 5 + # #Quota::ALL_USERSy - case 6 def user_exec_group_are_reasonable #:nodoc: uid = self.user_id || 0 rrid = self.remote_resource_id || 0 gid = self.group_id || 0 + return true if uid == Quota::ALL_USERS && rrid > 0 && gid == 0 # case #6 return true if uid > 0 && gid == 0 # case 1 and 4 return true if gid > 0 && uid == 0 # case 3 and 5 return true if rrid > 0 && uid == 0 && gid == 0 # case 2 diff --git a/BrainPortal/app/models/quota.rb b/BrainPortal/app/models/quota.rb index ed02aa41b..2bf7e72d7 100644 --- a/BrainPortal/app/models/quota.rb +++ b/BrainPortal/app/models/quota.rb @@ -28,4 +28,6 @@ class Quota < ApplicationRecord cbrain_abstract_model! # objects of this class are not to be instantiated + ALL_USERS = -7 # indicate total quota for all the users togeter + end diff --git a/BrainPortal/app/views/quotas/_cpu_quotas_table.html.erb b/BrainPortal/app/views/quotas/_cpu_quotas_table.html.erb index 265b44a7e..b1d363310 100644 --- a/BrainPortal/app/views/quotas/_cpu_quotas_table.html.erb +++ b/BrainPortal/app/views/quotas/_cpu_quotas_table.html.erb @@ -57,6 +57,9 @@ :sortable => true, :filters => default_filters_for(@base_scope, User) ) do |cq| + if cq.is_for_total? + html_colorize("(Total for all user)", 'orange') + end if ! cq.is_for_user? if cq.is_for_group? html_colorize("(For all users in project)", 'orange') @@ -65,6 +68,9 @@ end else link_to_user_if_accessible(cq.user) + if cq.is_for_total? + html_colorize("(Total for all users)", 'orange') + end end end diff --git a/BrainPortal/app/views/quotas/_show_cpu_quota.erb b/BrainPortal/app/views/quotas/_show_cpu_quota.erb index 8aa64ca0b..5eaa5bb22 100644 --- a/BrainPortal/app/views/quotas/_show_cpu_quota.erb +++ b/BrainPortal/app/views/quotas/_show_cpu_quota.erb @@ -47,16 +47,25 @@ <% t.cell("User", :show_width => 2) do %> <% if @quota.new_record? %> - <%= user_select("quota[user_id]", { :selector => @quota.user_id, :include_blank => '(Default For All Users)' }) %> + + <%= user_select("quota[user_id]", { :selector => @quota.user_id, + :include_blank => '(Default For All Users)', + :special_label => ["Max for all users together", Quota::ALL_USERS ] + }) %>
You can leave the user field blank and instead specify a project, below. You can also leave them both blank.
<% else %> - <%= @quota.is_for_user? ? + <% if @quota.is_for_total? %> + <%= html_colorize("(Server-wide task total)", 'orange') %> + <% else %> + <%= @quota.is_for_user? ? link_to_user_if_accessible(@quota.user) : html_colorize("(Default for all users)", 'orange') %> + <% end %> <% end %> + <% end %> <% t.cell("Project", :show_width => 2) do %> @@ -120,8 +129,7 @@ Leave blank to not set a limit. A value of zero will prevent any tasks from being launched. Note that projects are ignored for these values, and that if several quota records apply to a user and differ only by project, the minimum value found in that set will be used. - The core Admin account is used to set a maximum number of tasks IN TOTAL for an Execution - server (thus, no limit specific to that admin user can be specified here). + It is possible to define a maximum number of tasks IN TOTAL for an Execution server. <% end %>