diff --git a/lib/create_software.rb b/lib/create_software.rb index a7e8894..7527475 100644 --- a/lib/create_software.rb +++ b/lib/create_software.rb @@ -4,7 +4,8 @@ class CreateSoftware < Task validates_presence_of :requestor_id, :target_id validates_presence_of :name - attr_accessible :name, :finality, :repository_link, :requestor, :environment, :reject_explanation, :license_info + attr_accessible :name, :finality, :repository_link, :requestor, :environment, + :reject_explanation, :license_info alias :environment :target alias :environment= :target= @@ -20,7 +21,8 @@ class CreateSoftware < Task template_id = software_template.id end - community = Community.create!(:name => self.name, :template_id => template_id) + community = Community.create!(:name => self.name, + :template_id => template_id) community.environment = self.environment community.add_admin(self.requestor) @@ -34,20 +36,16 @@ class CreateSoftware < Task _("New software") end - # def icon - # src = image ? image.public_filename(:minor) : '/images/icons-app/community-minor.png' - # {:type => :defined_image, :src => src, :name => name} - # end - def subject name end def information + message = _('%{requestor} wants to create software %{subject} with') if finality.blank? - { :message => _('%{requestor} wants to create software %{subject} with no finality.') } + { :message => message + _(' no finality.') } else - { :message => _('%{requestor} wants to create software %{subject} with this finality:
%{finality}
'), + { :message => message + _(' this finality:%{finality}
'), :variables => {:finality => finality} } end end @@ -67,32 +65,48 @@ class CreateSoftware < Task end def target_notification_description - _('%{requestor} wants to create software %{subject}') % {:requestor => requestor.name, :subject => subject} + _('%{requestor} wants to create software %{subject}') % + {:requestor => requestor.name, :subject => subject} end def target_notification_message - _("User \"%{user}\" just requested to create software %{software}. You have to approve or reject it through the \"Pending Validations\" section in your control panel.\n") % { :user => self.requestor.name, :software => self.name } + _("User \"%{user}\" just requested to create software %{software}. + You have to approve or reject it through the \"Pending Validations\" + section in your control panel.\n") % + { :user => self.requestor.name, :software => self.name } end def task_created_message - _("Your request for registering software %{software} at %{environment} was just sent. Environment administrator will receive it and will approve or reject your request according to his methods and creteria. + _("Your request for registering software %{software} at %{environment} was + just sent. Environment administrator will receive it and will approve or + reject your request according to his methods and creteria. - You will be notified as soon as environment administrator has a position about your request.") % { :software => self.name, :environment => self.target } + You will be notified as soon as environment administrator has a position + about your request.") % + { :software => self.name, :environment => self.target } end def task_cancelled_message - _("Your request for registering software %{software} at %{environment} was not approved by the environment administrator. The following explanation was given: \n\n%{explanation}") % { :software => self.name, :environment => self.environment, :explanation => self.reject_explanation } + _("Your request for registering software %{software} at %{environment} was + not approved by the environment administrator. The following explanation + was given: \n\n%{explanation}") % + { :software => self.name, + :environment => self.environment, + :explanation => self.reject_explanation } end def task_finished_message - _('Your request for registering the software "%{software}" was approved. You can access %{url} and finish the registration of your software.') % { :software => self.name, :url => mount_url } + _('Your request for registering the software "%{software}" was approved. + You can access %{url} and finish the registration of your software.') % + { :software => self.name, :url => mount_url } end private def mount_url identifier = Community.where(:name => self.name).first.identifier - # The use of url_for doesn't allow the /social within the Public Software portal. That's why the url is mounted so 'hard coded' + # The use of url_for doesn't allow the /social within the Public Software + # portal. That's why the url is mounted so 'hard coded' url = "#{environment.top_url}/myprofile/#{identifier}/profile_editor/edit" end diff --git a/lib/institution.rb b/lib/institution.rb index f4f45ae..e87a773 100644 --- a/lib/institution.rb +++ b/lib/institution.rb @@ -15,8 +15,9 @@ class Institution < ActiveRecord::Base attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, :sub_juridical_nature, :normalization_level, - :version, :cnpj, :type, :governmental_power, :governmental_sphere, - :sisp, :juridical_nature, :corporate_name + :version, :cnpj, :type, :governmental_power, + :governmental_sphere, :sisp, :juridical_nature, + :corporate_name validates :name, :presence=>true, :uniqueness=>true @@ -30,7 +31,8 @@ class Institution < ActiveRecord::Base where("name ilike ? OR acronym ilike ?", "%#{value}%", "%#{value}%" ) } - validate :validate_country, :validate_state, :validate_city, :verify_institution_type, :validate_cnpj, :validate_format_cnpj + validate :validate_country, :validate_state, :validate_city, + :verify_institution_type, :validate_cnpj, :validate_format_cnpj protected @@ -39,7 +41,10 @@ class Institution < ActiveRecord::Base valid_institutions_type = ["PublicInstitution", "PrivateInstitution"] unless valid_institutions_type.include? self.type - self.errors.add(:type, _("invalid, only public and private institutions are allowed.")) + self.errors.add( + :type, + _("invalid, only public and private institutions are allowed.") + ) return false end @@ -47,7 +52,10 @@ class Institution < ActiveRecord::Base end def validate_country - if (self.community.blank?) || self.community.country.blank? && self.errors[:country].blank? + if(self.community.blank? || + self.community.country.blank? && + self.errors[:country].blank?) + self.errors.add(:country, _("can't be blank")) return false end @@ -55,7 +63,10 @@ class Institution < ActiveRecord::Base end def validate_state - if (self.community.blank?) || self.errors[:state].blank? && self.community.state.blank? + if(self.community.blank? || + self.errors[:state].blank? && + self.community.state.blank?) + if self.community.country == "BR" self.errors.add(:state, _("can't be blank")) return false @@ -67,7 +78,10 @@ class Institution < ActiveRecord::Base end def validate_city - if (self.community.blank?) || self.errors[:city].blank? && self.community.city.blank? + if(self.community.blank? || + self.errors[:city].blank? && + self.community.city.blank?) + if self.community.country == "BR" self.errors.add(:city, _("can't be blank")) return false diff --git a/lib/software_helper.rb b/lib/software_helper.rb index 29290fa..a406c64 100644 --- a/lib/software_helper.rb +++ b/lib/software_helper.rb @@ -1,9 +1,12 @@ module SoftwareHelper - def self.select_options programming_languages, selected=0 + def self.select_options programming_languages, selected = 0 value = "" programming_languages.each do |language| - value += "" + selected = selected == language.id ? 'selected' : '' + value += "" end value -- libgit2 0.21.2