From 1c11f03321e6d5a3e792e0f9902fde856e7be97b Mon Sep 17 00:00:00 2001 From: Parley Martins Date: Wed, 5 Nov 2014 16:44:03 -0200 Subject: [PATCH] Add software creation steps message and its test --- controllers/mpog_software_plugin_myprofile_controller.rb | 16 ---------------- db/migrate/20141105173616_add_first_edit_to_software.rb | 9 +++++++++ features/software_registration.feature | 22 ++++++++++++++++------ lib/mpog_software_plugin.rb | 6 ++++++ lib/software_info.rb | 40 ++++++++++++++++++++-------------------- public/mpog-software-validations.js | 14 ++++++++++++-- views/first_edit_software_community_extras.html.erb | 3 +++ views/mpog_software_plugin_myprofile/new_software.html.erb | 5 ++++- 8 files changed, 70 insertions(+), 45 deletions(-) create mode 100644 db/migrate/20141105173616_add_first_edit_to_software.rb create mode 100644 views/first_edit_software_community_extras.html.erb diff --git a/controllers/mpog_software_plugin_myprofile_controller.rb b/controllers/mpog_software_plugin_myprofile_controller.rb index 5257102..ad5bb33 100644 --- a/controllers/mpog_software_plugin_myprofile_controller.rb +++ b/controllers/mpog_software_plugin_myprofile_controller.rb @@ -47,26 +47,10 @@ class MpogSoftwarePluginMyprofileController < MyProfileController redirect_to :controller => 'profile_editor', :action => 'edit', :profile => @community.identifier 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 @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 diff --git a/db/migrate/20141105173616_add_first_edit_to_software.rb b/db/migrate/20141105173616_add_first_edit_to_software.rb new file mode 100644 index 0000000..a8b058e --- /dev/null +++ b/db/migrate/20141105173616_add_first_edit_to_software.rb @@ -0,0 +1,9 @@ +class AddFirstEditToSoftware < ActiveRecord::Migration + def up + add_column :software_infos, :first_edit, :boolean, :default => true + end + + def down + remove_column :software_infos, :first_edit + end +end diff --git a/features/software_registration.feature b/features/software_registration.feature index 7e74dca..852dd79 100644 --- a/features/software_registration.feature +++ b/features/software_registration.feature @@ -19,7 +19,7 @@ Feature: edit public software information @selenium Scenario: Show SoftwareLangue fields when click in New Language Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software - When I follow "Public Software" + When I follow "Specifications" And I follow "New language" And I should see "3" of this selector ".software-language-table" And I follow "Delete" @@ -29,7 +29,7 @@ Feature: edit public software information @selenium Scenario: Show databasefields when click in New database Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software - When I follow "Public Software" + When I follow "Specifications" And I follow "New Database" And I should see "3" of this selector ".database-table" And I follow "Delete" @@ -39,7 +39,7 @@ Feature: edit public software information @selenium Scenario: Software database name should be an autocomplete Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software - When I follow "Public Software" + When I follow "Specifications" And I follow "New Database" And I type in "my" into autocomplete list "database_autocomplete" and I choose "MySQL" Then selector ".database_autocomplete" should have any "MySQL" @@ -47,7 +47,7 @@ Feature: edit public software information @selenium Scenario: Software database name should be an autocomplete Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software - When I follow "Public Software" + When I follow "Specifications" And I follow "New language" And I type in "py" into autocomplete list "language_autocomplete" and I choose "Python" Then selector ".database_autocomplete" should have any "Python" @@ -55,7 +55,7 @@ Feature: edit public software information @selenium Scenario: Create software with all dynamic table fields filled Given I go to /myprofile/basic-software/plugin/mpog_software/edit_software - When I follow "Public Software" + When I follow "Specifications" And I follow "New language" And I type in "py" into autocomplete list "language_autocomplete" and I choose "Python" And I fill in "language__version" with "1.2.3" @@ -66,10 +66,20 @@ Feature: edit public software information And I fill in "database__operating_system" with "Unix" Then I press "Save" And I follow "Software Info" - And I follow "Public Software" + And I follow "Specifications" And selector ".language_autocomplete" should have any "Python" And selector "#language__version" should have any "1.2.3" And selector "#language__operating_system" should have any "Unix" And selector ".database_autocomplete" should have any "MySQL" And selector "#database__version" should have any "4.5.6" And selector "#database__operating_system" should have any "Unix" + + @selenium + Scenario: Message second step of creation in edit software community + Given the following softwares + | name | + | New Software | + And I go to /myprofile/new-software/profile_editor/edit + Then I should see "Step 2/2 - Software Community Configuration" + And I go to /myprofile/new-software/profile_editor/edit + Then I should not see "Step 2/2 - Software Community Configuration" diff --git a/lib/mpog_software_plugin.rb b/lib/mpog_software_plugin.rb index 2ea5d57..a99c693 100644 --- a/lib/mpog_software_plugin.rb +++ b/lib/mpog_software_plugin.rb @@ -59,6 +59,12 @@ class MpogSoftwarePlugin < Noosfero::Plugin elsif context.profile.respond_to? :institution and !context.profile.institution.nil? @show_sisp_field = show_sisp_field expanded_template('institution_editor_extras.html.erb') + elsif context.profile.respond_to? :software_info and !context.profile.software_info.nil? + if context.profile.software_info.first_edit? + context.profile.software_info.first_edit = false + context.profile.software_info.save! + expanded_template('first_edit_software_community_extras.html.erb') + end end end diff --git a/lib/software_info.rb b/lib/software_info.rb index 5729690..e5f511f 100644 --- a/lib/software_info.rb +++ b/lib/software_info.rb @@ -1,24 +1,24 @@ 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, :finality, :repository_link, :public_software - - 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_length_of :finality, :maximum => 140 - validates_length_of :objectives, :maximum => 4000 - validates_length_of :features, :maximum => 4000 - - validate :validate_acronym + attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, :operating_platform, :demonstration_url, :acronym, :objectives, :features, :license_infos_id, :community_id, :finality, :repository_link, :public_software, :first_edit + + 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_length_of :finality, :maximum => 140 + validates_length_of :objectives, :maximum => 4000 + validates_length_of :features, :maximum => 4000 + + validate :validate_acronym # used on find_by_contents scope :like_search, lambda{ |name| diff --git a/public/mpog-software-validations.js b/public/mpog-software-validations.js index f3e1367..325794e 100644 --- a/public/mpog-software-validations.js +++ b/public/mpog-software-validations.js @@ -105,9 +105,17 @@ function hide_show_public_software_fields() { if (jQuery("#software_public_software").prop("checked")) - jQuery(".public-software-fields").show(); + jQuery(".public-software-fields").show(); else - jQuery(".public-software-fields").hide(); + jQuery(".public-software-fields").hide(); + } + + function replace_software_creations_step() { + var software_creation_step = jQuery("#software_creation_step").remove(); + + if( software_creation_step.size() > 0 ) { + jQuery("#profile-data").parent().prepend(software_creation_step); + } } jQuery(document).ready(function(){ @@ -192,5 +200,7 @@ }); hide_show_public_software_fields(); jQuery("#software_public_software").click(hide_show_public_software_fields); + + replace_software_creations_step(); }); })(); diff --git a/views/first_edit_software_community_extras.html.erb b/views/first_edit_software_community_extras.html.erb new file mode 100644 index 0000000..44fabe0 --- /dev/null +++ b/views/first_edit_software_community_extras.html.erb @@ -0,0 +1,3 @@ +
+

<%= _("Step 2/2 - Software Community Configuration")%>

+
\ No newline at end of file diff --git a/views/mpog_software_plugin_myprofile/new_software.html.erb b/views/mpog_software_plugin_myprofile/new_software.html.erb index baee5af..9801b94 100644 --- a/views/mpog_software_plugin_myprofile/new_software.html.erb +++ b/views/mpog_software_plugin_myprofile/new_software.html.erb @@ -1,7 +1,10 @@ - <%= javascript_include_tag "mpog-validations" %> <%= stylesheet_link_tag('plugins/mpog_software/mpog-software') %> +
+

<%= _("Step 1/2 - Software Creation")%>

+
+

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

<% if environment.enabled?('admin_must_approve_new_communities') %> -- libgit2 0.21.2