diff --git a/controllers/mpog_software_plugin_myprofile_controller.rb b/controllers/mpog_software_plugin_myprofile_controller.rb index f4aafd3..657a180 100644 --- a/controllers/mpog_software_plugin_myprofile_controller.rb +++ b/controllers/mpog_software_plugin_myprofile_controller.rb @@ -14,85 +14,85 @@ class MpogSoftwarePluginMyprofileController < MyProfileController @community = Community.new(params[:community]) @community.environment = environment @software_info = SoftwareInfo.new(params[:software_info]) - @list_libraries = LibraryHelper.list_libraries(params[:library]) - @list_languages = SoftwareLanguageHelper.list_language(params[:language]) - @list_databases = DatabaseHelper.list_database(params[:database]) - @software_categories = SoftwareCategories::new params[:software_categories] - @list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system]) - @license_info = if params[:license_info].nil? - LicenseInfo::new - else - LicenseInfo.find(:first, :conditions =>["version = ?","#{params[:license_info][:version]}"]) - end + #@list_libraries = LibraryHelper.list_libraries(params[:library]) + #@list_languages = SoftwareLanguageHelper.list_language(params[:language]) + #@list_databases = DatabaseHelper.list_database(params[:database]) + #@software_categories = SoftwareCategories::new params[:software_categories] + #@list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system]) + #@license_info = if params[:license_info].nil? + # LicenseInfo::new + #else + # LicenseInfo.find(:first, :conditions =>["version = ?","#{params[:license_info][:version]}"]) + #end - if not @list_libraries.nil? - @list_libraries.each do |library| - @software_info.libraries << library - end - end + #if not @list_libraries.nil? + # @list_libraries.each do |library| + # @software_info.libraries << library + # end + #end - if not @list_languages.nil? - @list_languages.each do |language| - @software_info.software_languages << language - end - end + #if not @list_languages.nil? + # @list_languages.each do |language| + # @software_info.software_languages << language + # end + #end - if not @list_databases.nil? - @list_databases.each do |database| - @software_info.software_databases << database - end - end + #if not @list_databases.nil? + # @list_databases.each do |database| + # @software_info.software_databases << database + # end + #end - if not @list_operating_systems.nil? - @list_operating_systems.each do |operating_system| - @software_info.operating_systems << operating_system - end - end + #if not @list_operating_systems.nil? + # @list_operating_systems.each do |operating_system| + # @software_info.operating_systems << operating_system + # end + #end - valid_community = request.post? && @community.valid? - valid_software_info = request.post? && @software_info.valid? - valid_license = (request.post? && @license_info.valid?) - valid_libraries = @list_libraries.empty? || LibraryHelper.valid_list_libraries?(@list_libraries) - valid_database = DatabaseHelper.valid_list_database?(@list_databases) - valid_language = SoftwareLanguageHelper.valid_list_language?(@list_languages) - valid_operating_system = OperatingSystemHelper.valid_list_operating_system?(@list_operating_systems) - valid_software_categories = request.post? && @software_categories.valid? + valid_community = request.post? && @community.valid? + valid_software_info = request.post? && @software_info.valid? + #valid_license = (request.post? && @license_info.valid?) + #valid_libraries = @list_libraries.empty? || LibraryHelper.valid_list_libraries?(@list_libraries) + #valid_database = DatabaseHelper.valid_list_database?(@list_databases) + #valid_language = SoftwareLanguageHelper.valid_list_language?(@list_languages) + #valid_operating_system = OperatingSystemHelper.valid_list_operating_system?(@list_operating_systems) + #valid_software_categories = request.post? && @software_categories.valid? - if valid_software_info && valid_community && valid_libraries && valid_license && valid_language && valid_database && valid_operating_system && valid_software_categories - @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info, @software_categories) + if valid_software_info && valid_community + @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info ) + redirect_to :controller => 'memberships', :action => 'index' - unless params[:q].nil? - admins = params[:q].split(/,/).map{|n| environment.people.find n.to_i} + unless params[:q].nil? + admins = params[:q].split(/,/).map{|n| environment.people.find n.to_i} - admins.each do |admin| - @community.add_member(admin) - @community.add_admin(admin) - end - end + admins.each do |admin| + @community.add_member(admin) + @community.add_admin(admin) + end + end - redirect_to :controller => 'memberships', :action => 'index' - else - @list_libraries.each do |lib| - @errors |= lib.errors.full_messages - end - - @list_languages.each do |lng| - @errors |= lng.errors.full_messages - end - - @list_databases.each do |db| - @errors |= db.errors.full_messages - end + else + # @list_libraries.each do |lib| + # @errors |= lib.errors.full_messages + # end + # + # @list_languages.each do |lng| + # @errors |= lng.errors.full_messages + # end + # + # @list_databases.each do |db| + # @errors |= db.errors.full_messages + # end - @list_operating_systems.each do |os| - @errors |= os.errors.full_messages - end + # @list_operating_systems.each do |os| + # @errors |= os.errors.full_messages + # end - @errors |= @community.errors.full_messages - @errors |= @software_info.errors.full_messages - @errors |= @license_info.errors.full_messages - @errors |= @software_categories.errors.full_messages - end + @errors |= @community.errors.full_messages + @errors |= @software_info.errors.full_messages + # @errors |= @license_info.errors.full_messages + # @errors |= @software_categories.errors.full_messages + #end end def search_offerers @@ -101,3 +101,4 @@ class MpogSoftwarePluginMyprofileController < MyProfileController render :text => prepare_to_token_input(result).to_json end end +end diff --git a/db/migrate/20141007140419_add_finality_field_to_software_table.rb b/db/migrate/20141007140419_add_finality_field_to_software_table.rb new file mode 100644 index 0000000..181c4fb --- /dev/null +++ b/db/migrate/20141007140419_add_finality_field_to_software_table.rb @@ -0,0 +1,10 @@ +class AddFinalityFieldToSoftwareTable < ActiveRecord::Migration + def up + add_column :software_infos, :finality, :string, :limit => 140 + + end + + def down + remove_column :software_info, :finality + end +end diff --git a/lib/software_info.rb b/lib/software_info.rb index 2082338..da14d21 100644 --- a/lib/software_info.rb +++ b/lib/software_info.rb @@ -1,27 +1,32 @@ class SoftwareInfo < ActiveRecord::Base - attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, :operating_platform, :demonstration_url, :acronym, :objectives, :features, :license_infos_id, :community_id - - has_many :libraries, :dependent => :destroy - has_many :software_databases - has_many :database_descriptions, :through => :software_databases - has_many :software_languages - has_many :operating_systems - has_many :programming_languages, :through => :software_languages - has_many :operating_system_names, :through => :operating_systems - - belongs_to :community - belongs_to :license_info - - has_one :software_categories - - validates :features, :objectives, - :presence=>true, - :length => { - :maximum => 4000, - :too_long => _("Software features is too long (maximum is 4000 characters)") - } - - validate :validate_operating_platform, :validate_acronym, :valid_software_info, :valid_databases, :valid_operating_systems + # attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, :operating_platform, :demonstration_url, :acronym, :objectives, :features, :license_infos_id, :community_id, :finality + attr_accessible :finality + + #has_many :libraries, :dependent => :destroy + #has_many :software_databases + #has_many :database_descriptions, :through => :software_databases + #has_many :software_languages + #has_many :operating_systems + #has_many :programming_languages, :through => :software_languages + #has_many :operating_system_names, :through => :operating_systems + + belongs_to :community + #belongs_to :license_info + + #has_one :software_categories + + #validates :features, :objectives, + # :presence=>true, + # :length => { + # :maximum => 4000, + # :too_long => _("Software features is too long (maximum is 4000 characters)") + # } + + #validate :validate_operating_platform, :validate_acronym, :valid_software_info, :valid_databases, :valid_operating_systems + + #validate :finality, :presence => {:message => "Finality cannot be blank"} + validate :validate_finality + # used on find_by_contents scope :like_search, lambda{ |name| @@ -115,6 +120,11 @@ class SoftwareInfo < ActiveRecord::Base end end + def validate_finality + self.errors.add(:finality, _("can't be blank")) if self.finality.blank? && self.errors.messages[:finality].nil? + end + + def valid_operating_systems self.errors.add(:operating_system, _(": at least one must be filled")) if self.operating_systems.empty? end diff --git a/views/mpog_software_plugin_myprofile/new_software.html.erb b/views/mpog_software_plugin_myprofile/new_software.html.erb index 6beed7c..62f3a23 100644 --- a/views/mpog_software_plugin_myprofile/new_software.html.erb +++ b/views/mpog_software_plugin_myprofile/new_software.html.erb @@ -28,222 +28,11 @@ <%= fields_for @software_info do |swf| %>
- <%= swf.label("acronym" ,_("Acronym"), :class=>"formlabel") %> - <%= swf.text_field(:acronym) %> -
- -
- <%= swf.label _("Adherent to e-PING ?") %> - - <%= swf.label "e_ping_true", "Yes" %> - <%= swf.radio_button(:e_ping,true)%> - <%= swf.label "e_ping_false", "No"%> - <%= swf.radio_button(:e_ping,false)%> -
- -
- <%= swf.label _("Adherent to e-MAG ?") %> - - <%= swf.label "e_mag_true", "Yes"%> - <%= swf.radio_button(:e_mag,true)%> - <%= swf.label "e_mag_false", "No"%> - <%= swf.radio_button(:e_mag,false)%> -
- -
- <%= swf.label _("Adherent to ICP-Brasil ?") %> - - <%= swf.label "icp_brasil_true", "Yes"%> - <%= swf.radio_button(:icp_brasil,true)%> - <%= swf.label "icp_brasil_false", "No"%> - <%= swf.radio_button(:icp_brasil,false)%> -
- -
- <%= swf.label _("Adherent to e-ARQ ?") %> - - <%= swf.label "e_arq_true", "Yes"%> - <%= swf.radio_button(:e_arq,true)%> - <%= swf.label "e_arq_false", "No"%> - <%= swf.radio_button(:e_arq,false)%> -
- -
- <%= swf.label _("Internacionalizable ?") %> - - <%= swf.label "intern_true", "Yes" %> - <%= swf.radio_button(:intern,true)%> - <%= swf.label "intern_false", "No"%> - <%= swf.radio_button(:intern,false)%> -
- <%= swf.label "operating_platform", _("Operating Platform: ") %>
- <%= swf.text_area(:operating_platform) %> -
- -
- <%= swf.label "objectives", _("Objectives: ")%>
- <%= required swf.text_area(:objectives) %> -
- -
- <%= swf.label "features", _("Features: ")%>
- <%= required swf.text_area(:features) %> -
- -
- <%= swf.label "demonstration_url", _("Demonstration URL: ") %> - <%= swf.text_field(:demonstration_url) %> + <%= swf.label("finality" ,_("Finality"), :class=>"formlabel") %> + <%= required swf.text_field(:finality) %>
<% end %> -
- <%= content_tag('label', _('Fill in the search field to add offerers for this Software'), :id => "text-input-search-offerers") %> - <%= token_input_field_tag(:q, 'search-offerers', {:action => 'search_offerers'}, { :focus => true, :hint_text => _('Type in a search term for a person to be added as -offerers'), :pre_populate => @tokenized_children}) %> -
- -
-

<%= _("Libraries") %>

- <%= render :partial => 'library_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :libraries => @list_libraries } %> -
-
- -
-

<%= _("Operating Systems") %>

- <% if @list_operating_systems.blank? %> - <%= OperatingSystemHelper.operating_system_as_tables(nil, false).call %> - <% end %> - <%= render :partial => 'operating_system_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :operating_systems_fields => @list_operating_systems} %> -
-
- - <%= fields_for @license_info do |lcv| %> -
-

<%= lcv.label _("License Version: ") %>

- <%= lcv.select(:version, LicenseInfo.all.map {|l| [l.version, l.version]}, {:selected=>1}, :onchange => "get_license_link('license_info_version')") %> - -

<%= _("License link") %>

- <% LicenseHelper.getListLicenses.each do | license | %> - - <% end %> - <%=LicenseInfo.first.link %> - -
- <% end %> - -
-
-

<%= _("Programming languages") %>

- <% if @list_languages.blank? %> - <%= SoftwareLanguageHelper.language_as_tables(nil, false).call %> - <% end %> - - <%= render :partial => 'language_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :languages => @list_languages } %> -
- -
-
-

<%= _("Databases") %>

- <% if @list_databases.blank? %> - <%= DatabaseHelper.database_as_tables(nil, true).call %> - <% end %> - - <%= render :partial => 'database_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :database => @list_databases } %> -
- - <%= fields_for @software_categories do |cv| %> -
-

<%= _("Software Categories:") %>

- - <%= cv.check_box :administration %> - <%= cv.label :administration, _("Administration") %>
- - <%= cv.check_box :agriculture %> - <%= cv.label :agriculture, _("Agriculture") %>
- - <%= cv.check_box :business_and_services %> - <%= cv.label :business_and_services, _("Business_and Services") %>
- - <%= cv.check_box :communication %> - <%= cv.label :communication, _("Communication") %>
- - <%= cv.check_box :culture %> - <%= cv.label :culture, _("Culture") %>
- - <%= cv.check_box :national_defense %> - <%= cv.label :national_defense, _("National Defense") %>
- - <%= cv.check_box :economy_and_finances %> - <%= cv.label :economy_and_finances, _("Economy and Finances") %>
- - <%= cv.check_box :education %> - <%= cv.label :education, _("Education") %>
- - <%= cv.check_box :energy %> - <%= cv.label :energy, _("Energy") %>
- - <%= cv.check_box :sports %> - <%= cv.label :sports, _("Sports") %>
- - <%= cv.check_box :habitation %> - <%= cv.label :habitation, _("Habitation") %>
- - <%= cv.check_box :industry %> - <%= cv.label :industry, _("Industry") %>
- - <%= cv.check_box :environment %> - <%= cv.label :environment, _("Environment") %>
- - <%= cv.check_box :research_and_development %> - <%= cv.label :research_and_development, _("Research and Development") %>
- - <%= cv.check_box :social_security %> - <%= cv.label :social_security, _("Social Security") %>
- - <%= cv.check_box :social_protection %> - <%= cv.label :social_protection, _("Social Protection") %>
- - <%= cv.check_box :sanitation %> - <%= cv.label :sanitation, _("Sanitation") %>
- - <%= cv.check_box :health %> - <%= cv.label :health, _("Health") %>
- - <%= cv.check_box :security_public_order %> - <%= cv.label :security_public_order, _("Security and Public Order") %>
- - <%= cv.check_box :work %> - <%= cv.label :work, _("Work") %>
- - <%= cv.check_box :transportation %> - <%= cv.label :transportation, _("Transportation") %>
- - <%= cv.check_box :urbanism %> - <%= cv.label :urbanism, _("Urbanism") %>
-
- <% end %> - <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => 'community', :profile => @community } %> - - <%= f.fields_for :image_builder, @community.image do |i| %> - <%= file_field_or_thumbnail(_('Image:'), @community.image, i) %> - <% end %> - -
- <%= _('New members must be approved:')%> -
-
- <%= radio_button 'community', 'closed', 'true', :style => 'float: left' %> -
- <%= _('Before joining this group (a moderator has to accept the member in pending request before member can access the intranet and/or the website).') %> -
-
-
- <%= radio_button 'community', 'closed', 'false', :style => 'float: left' %> -
- <%= _('After joining this group (a moderator can always desactivate access for users later).') %> -
-
- <%= template_options(:communities, 'community')%> <%= hidden_field_tag('back_to', @back_to) %> diff --git a/views/mpog_software_plugin_myprofile/public_software_info.html.erb b/views/mpog_software_plugin_myprofile/public_software_info.html.erb new file mode 100644 index 0000000..921fb77 --- /dev/null +++ b/views/mpog_software_plugin_myprofile/public_software_info.html.erb @@ -0,0 +1,258 @@ +<%= javascript_include_tag "mpog-validations" %> + +

<%= _('Creating new software') %>

+ +<% if environment.enabled?('admin_must_approve_new_communities') %> +
+ <%= _("Note that the creation of communities in this environment is restricted. Your request to create this new community will be sent to %{environment} administrators and will be approved or rejected according to their methods and criteria.") % { :environment => environment.name }%> +
+<%end %> + +<% unless @errors.blank? %> +
+

<%= _("Can`t create new software: #{@errors.length} errors") %>

+ +
+<% end %> + +
+ <%= labelled_form_for :community, :html => { :multipart => true } do |f| %> + + <%= required_fields_message %> + + <%= required f.text_field(:name) %> + + <%= fields_for @software_info do |swf| %> +
+ <%= swf.label("acronym" ,_("Acronym"), :class=>"formlabel") %> + <%= swf.text_field(:acronym) %> +
+ +
+ <%= swf.label _("Adherent to e-PING ?") %> + + <%= swf.label "e_ping_true", "Yes" %> + <%= swf.radio_button(:e_ping,true)%> + <%= swf.label "e_ping_false", "No"%> + <%= swf.radio_button(:e_ping,false)%> +
+ +
+ <%= swf.label _("Adherent to e-MAG ?") %> + + <%= swf.label "e_mag_true", "Yes"%> + <%= swf.radio_button(:e_mag,true)%> + <%= swf.label "e_mag_false", "No"%> + <%= swf.radio_button(:e_mag,false)%> +
+ +
+ <%= swf.label _("Adherent to ICP-Brasil ?") %> + + <%= swf.label "icp_brasil_true", "Yes"%> + <%= swf.radio_button(:icp_brasil,true)%> + <%= swf.label "icp_brasil_false", "No"%> + <%= swf.radio_button(:icp_brasil,false)%> +
+ +
+ <%= swf.label _("Adherent to e-ARQ ?") %> + + <%= swf.label "e_arq_true", "Yes"%> + <%= swf.radio_button(:e_arq,true)%> + <%= swf.label "e_arq_false", "No"%> + <%= swf.radio_button(:e_arq,false)%> +
+ +
+ <%= swf.label _("Internacionalizable ?") %> + + <%= swf.label "intern_true", "Yes" %> + <%= swf.radio_button(:intern,true)%> + <%= swf.label "intern_false", "No"%> + <%= swf.radio_button(:intern,false)%> +
+ <%= swf.label "operating_platform", _("Operating Platform: ") %>
+ <%= swf.text_area(:operating_platform, :class=>"expand-field") %> +
+ +
+ <%= swf.label "objectives", _("Objectives: ")%>
+ <%= required swf.text_area(:objectives, :class=>"expand-field") %> +
+ +
+ <%= swf.label "features", _("Features: ")%>
+ <%= required swf.text_area(:features, :class=>"expand-field") %> +
+ +
+ <%= swf.label "demonstration_url", _("Demonstration URL: ") %> + <%= swf.text_field(:demonstration_url) %> +
+ <% end %> + +
+ <%= content_tag('label', _('Fill in the search field to add offerers for this Software'), :id => "text-input-search-offerers") %> + <%= token_input_field_tag(:q, 'search-offerers', {:action => 'search_offerers'}, { :focus => true, :hint_text => _('Type in a search term for a person to be added as +offerers'), :pre_populate => @tokenized_children}) %> +
+ +
+

<%= _("Libraries") %>

+ <%= render :partial => 'library_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :libraries => @list_libraries } %> +
+
+ +
+

<%= _("Operating Systems") %>

+ <% if @list_operating_systems.blank? %> + <%= OperatingSystemHelper.operating_system_as_tables(nil, false).call %> + <% end %> + <%= render :partial => 'operating_system_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :operating_systems_fields => @list_operating_systems} %> +
+
+ + <%= fields_for @license_info do |lcv| %> +
+

<%= lcv.label _("License Version: ") %>

+ <%= lcv.select(:version, LicenseInfo.all.map {|l| [l.version, l.version]}, {:selected=>1}, :onchange => "get_license_link('license_info_version')") %> + +

<%= _("License link") %>

+ <% LicenseHelper.getListLicenses.each do | license | %> + + <% end %> + <%=LicenseInfo.first.link %> + +
+ <% end %> + +
+
+

<%= _("Programming languages") %>

+ <% if @list_languages.blank? %> + <%= SoftwareLanguageHelper.language_as_tables(nil, false).call %> + <% end %> + + <%= render :partial => 'language_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :languages => @list_languages } %> +
+ +
+
+

<%= _("Databases") %>

+ <% if @list_databases.blank? %> + <%= DatabaseHelper.database_as_tables(nil, true).call %> + <% end %> + + <%= render :partial => 'database_fields', :locals => { :f => f, :object_name => 'community', :profile => @community, :database => @list_databases } %> +
+ + <%= fields_for @software_categories do |cv| %> +
+

<%= _("Software Categories:") %>

+ + <%= cv.check_box :administration %> + <%= cv.label :administration, _("Administration") %>
+ + <%= cv.check_box :agriculture %> + <%= cv.label :agriculture, _("Agriculture") %>
+ + <%= cv.check_box :business_and_services %> + <%= cv.label :business_and_services, _("Business_and Services") %>
+ + <%= cv.check_box :communication %> + <%= cv.label :communication, _("Communication") %>
+ + <%= cv.check_box :culture %> + <%= cv.label :culture, _("Culture") %>
+ + <%= cv.check_box :national_defense %> + <%= cv.label :national_defense, _("National Defense") %>
+ + <%= cv.check_box :economy_and_finances %> + <%= cv.label :economy_and_finances, _("Economy and Finances") %>
+ + <%= cv.check_box :education %> + <%= cv.label :education, _("Education") %>
+ + <%= cv.check_box :energy %> + <%= cv.label :energy, _("Energy") %>
+ + <%= cv.check_box :sports %> + <%= cv.label :sports, _("Sports") %>
+ + <%= cv.check_box :habitation %> + <%= cv.label :habitation, _("Habitation") %>
+ + <%= cv.check_box :industry %> + <%= cv.label :industry, _("Industry") %>
+ + <%= cv.check_box :environment %> + <%= cv.label :environment, _("Environment") %>
+ + <%= cv.check_box :research_and_development %> + <%= cv.label :research_and_development, _("Research and Development") %>
+ + <%= cv.check_box :social_security %> + <%= cv.label :social_security, _("Social Security") %>
+ + <%= cv.check_box :social_protection %> + <%= cv.label :social_protection, _("Social Protection") %>
+ + <%= cv.check_box :sanitation %> + <%= cv.label :sanitation, _("Sanitation") %>
+ + <%= cv.check_box :health %> + <%= cv.label :health, _("Health") %>
+ + <%= cv.check_box :security_public_order %> + <%= cv.label :security_public_order, _("Security and Public Order") %>
+ + <%= cv.check_box :work %> + <%= cv.label :work, _("Work") %>
+ + <%= cv.check_box :transportation %> + <%= cv.label :transportation, _("Transportation") %>
+ + <%= cv.check_box :urbanism %> + <%= cv.label :urbanism, _("Urbanism") %>
+
+ <% end %> + <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => 'community', :profile => @community } %> + + <%= f.fields_for :image_builder, @community.image do |i| %> + <%= file_field_or_thumbnail(_('Image:'), @community.image, i) %> + <% end %> + +
+ <%= _('New members must be approved:')%> +
+
+ <%= radio_button 'community', 'closed', 'true', :style => 'float: left' %> +
+ <%= _('Before joining this group (a moderator has to accept the member in pending request before member can access the intranet and/or the website).') %> +
+
+
+ <%= radio_button 'community', 'closed', 'false', :style => 'float: left' %> +
+ <%= _('After joining this group (a moderator can always desactivate access for users later).') %> +
+
+ + <%= template_options(:communities, 'community')%> + + <%= hidden_field_tag('back_to', @back_to) %> + + <% button_bar do %> + <%= submit_button(:save, _('Create')) %> + <%= button(:cancel, _('Cancel'), @back_to ) %> + <% end %> + + <% end %> + +
-- libgit2 0.21.2