From: Toshi MARUYAMA Date: Sat, 12 Dec 2020 15:49:36 +0000 (+0000) Subject: shorten long line of app/models/project.rb X-Git-Tag: 4.2.0~180 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fd112cb766001b2d71bc3379c117c439d76b6f7f;p=redmine.git shorten long line of app/models/project.rb git-svn-id: http://svn.redmine.org/redmine/trunk@20639 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/project.rb b/app/models/project.rb index 1ea3aaf5f..aef28744b 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -64,25 +64,31 @@ class Project < ActiveRecord::Base :delete_permission => :manage_files acts_as_customizable - acts_as_searchable :columns => ['name', 'identifier', 'description'], :project_key => "#{Project.table_name}.id", :permission => nil - acts_as_event :title => Proc.new {|o| "#{l(:label_project)}: #{o.name}"}, - :url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}}, + acts_as_searchable :columns => ['name', 'identifier', 'description'], + :project_key => "#{Project.table_name}.id", + :permission => nil + acts_as_event :title => proc {|o| "#{l(:label_project)}: #{o.name}"}, + :url => proc {|o| {:controller => 'projects', :action => 'show', :id => o}}, :author => nil validates_presence_of :name, :identifier - validates_uniqueness_of :identifier, :if => Proc.new {|p| p.identifier_changed?} + validates_uniqueness_of :identifier, :if => proc {|p| p.identifier_changed?} validates_length_of :name, :maximum => 255 validates_length_of :homepage, :maximum => 255 validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH # downcase letters, digits, dashes but not digits only - validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :if => Proc.new {|p| p.identifier_changed?} + validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, + :if => proc {|p| p.identifier_changed?} # reserved words validates_exclusion_of :identifier, :in => %w(new) validate :validate_parent - after_save :update_inherited_members, :if => Proc.new {|project| project.saved_change_to_inherit_members?} - after_save :remove_inherited_member_roles, :add_inherited_member_roles, :if => Proc.new {|project| project.saved_change_to_parent_id?} - after_update :update_versions_from_hierarchy_change, :if => Proc.new {|project| project.saved_change_to_parent_id?} + after_save :update_inherited_members, + :if => proc {|project| project.saved_change_to_inherit_members?} + after_save :remove_inherited_member_roles, :add_inherited_member_roles, + :if => proc {|project| project.saved_change_to_parent_id?} + after_update :update_versions_from_hierarchy_change, + :if => proc {|project| project.saved_change_to_parent_id?} before_destroy :delete_all_members scope :has_module, (lambda do |mod| @@ -240,11 +246,13 @@ class Project < ActiveRecord::Base end def principals - @principals ||= Principal.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).distinct + @principals ||= + Principal.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).distinct end def users - @users ||= User.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).distinct + @users ||= + User.active.joins(:members).where("#{Member.table_name}.project_id = ?", id).distinct end # Returns the Systemwide and project specific activities @@ -1253,7 +1261,12 @@ class Project < ActiveRecord::Base def allowed_permissions @allowed_permissions ||= begin - module_names = enabled_modules.loaded? ? enabled_modules.map(&:name) : enabled_modules.pluck(:name) + module_names = + if enabled_modules.loaded? + enabled_modules.map(&:name) + else + enabled_modules.pluck(:name) + end Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name} end end