diff --git a/features/software_block.feature b/features/software_block.feature new file mode 100644 index 0000000..03aa45e --- /dev/null +++ b/features/software_block.feature @@ -0,0 +1,48 @@ +Feature: edit adherent fields + As a user + I want to edit adherent fields + to mantain my public software up to date. + + Background: + Given "MpogSoftwarePlugin" plugin is enabled + And I am logged in as mpog_admin + And I go to /admin/plugins + And I check "MpogSoftwarePlugin" + And I press "Save changes" + And the following softwares + | name | public_software | + | Public Software | true | + | Generic Software | false | + + Scenario: Add software block + Given I am logged in as mpog_admin + And I follow "Control panel" + And I follow "Edit sideboxes" + When I follow "Add a block" + And I choose "Softwares" + And I press "Add" + Then I should see "softwares" + + Scenario: Change software block to generic software block + Given I am logged in as mpog_admin + And I follow "Control panel" + And I follow "Edit sideboxes" + When I follow "Add a block" + And I choose "Softwares" + And I press "Add" + And I follow "Edit" within ".softwares-block" + And I select "Generic" from "block_software_type" + And I press "Save" + Then I should see "generic software" + + Scenario: Change software block to generic software block + Given I am logged in as mpog_admin + And I follow "Control panel" + And I follow "Edit sideboxes" + When I follow "Add a block" + And I choose "Softwares" + And I press "Add" + And I follow "Edit" within ".softwares-block" + And I select "Public" from "block_software_type" + And I press "Save" + Then I should see "public software" \ No newline at end of file diff --git a/features/step_definitions/mpog_steps.rb b/features/step_definitions/mpog_steps.rb index 635ff8e..38623fc 100644 --- a/features/step_definitions/mpog_steps.rb +++ b/features/step_definitions/mpog_steps.rb @@ -105,21 +105,33 @@ end Given /^the following softwares$/ do |table| table.hashes.each do |item| - community = Community.create :name=>item[:name] - programming_language = ProgrammingLanguage.where(:name=>item[:software_language]).first - database_description = DatabaseDescription.where(:name=>item[:software_database]).first - - software_language = SoftwareLanguage.where(:programming_language_id=>programming_language).first - software_database = SoftwareDatabase.where(:database_description_id=>database_description).first - - operating_system_name = OperatingSystemName.where(:name => item[:operating_system]).first - operating_system = OperatingSystem.where(:operating_system_name_id => operating_system_name).first - - software_info = SoftwareInfo::new(:acronym=>item[:acronym], :operating_platform=>item[:operating_platform], :objectives => item[:objectives], :features => item[:features]) - software_info.community = community - software_info.software_languages << software_language - software_info.software_databases << software_database - software_info.operating_systems << operating_system + software_info = SoftwareInfo.new + software_info.community = Community.create(:name=>item[:name]) + + software_info.acronym = item[:acronym] if item[:acronym] + software_info.acronym = item[:operating_platform] if item[:operating_platform] + software_info.acronym = item[:objectives] if item[:objectives] + software_info.acronym = item[:features] if item[:features] + software_info.public_software = item[:public_software] == "true" if item[:public_software] + + if item[:software_language] + programming_language = ProgrammingLanguage.where(:name=>item[:software_language]).first + software_language = SoftwareLanguage.where(:programming_language_id=>programming_language).first + software_info.software_languages << software_language + end + + if item[:software_database] + database_description = DatabaseDescription.where(:name=>item[:software_database]).first + software_database = SoftwareDatabase.where(:database_description_id=>database_description).first + software_info.software_databases << software_database + end + + if item[:operating_system] + operating_system_name = OperatingSystemName.where(:name => item[:operating_system]).first + operating_system = OperatingSystem.where(:operating_system_name_id => operating_system_name).first + software_info.operating_systems << operating_system + end + software_info.save! end end diff --git a/lib/softwares_block.rb b/lib/softwares_block.rb index d080516..5643d01 100644 --- a/lib/softwares_block.rb +++ b/lib/softwares_block.rb @@ -1,13 +1,20 @@ class SoftwaresBlock < CommunitiesBlock - attr_accessible :accessor_id, :accessor_type, :role_id, :resource_id, :resource_type + settings_items :software_type + attr_accessible :accessor_id, :accessor_type, :role_id, :resource_id, :resource_type, :software_type def self.description _('Softwares') end def default_title - n_('{#} software', '{#} softwares', profile_count) + if self.software_type == "Generic" + return n_('{#} generic software', '{#} generic softwares', profile_count) + elsif self.software_type == "Public" + return n_('{#} public software', '{#} public softwares', profile_count) + else + return n_('{#} software', '{#} softwares', profile_count) + end end def help @@ -15,6 +22,7 @@ class SoftwaresBlock < CommunitiesBlock end def footer + self.software_type ||= "All" owner = self.owner case owner when Profile @@ -51,9 +59,15 @@ class SoftwaresBlock < CommunitiesBlock list_with_software = [] - visible_profiles.each do |p| - if p.class == Community and p.software? and !p.institution? - list_with_software << p + result.each do |profile| + if profile.class == Community and profile.software? + if self.software_type == "Public" + list_with_software << profile if profile.software_info.public_software? + elsif self.software_type == "Generic" + list_with_software << profile if !profile.software_info.public_software? + else + list_with_software << profile + end end end diff --git a/views/box_organizer/_softwares_block.html.erb b/views/box_organizer/_softwares_block.html.erb new file mode 100644 index 0000000..7a79f0b --- /dev/null +++ b/views/box_organizer/_softwares_block.html.erb @@ -0,0 +1,3 @@ +
+ <%= labelled_form_field _('Software Type:'), select_tag('block[software_type]', options_for_select(["Public", "Generic", "All"], @block.software_type) )%> +
diff --git a/views/environment_design b/views/environment_design new file mode 120000 index 0000000..cb3df33 --- /dev/null +++ b/views/environment_design @@ -0,0 +1 @@ +/home/parley/Repositories/noosfero/plugins/mpog_software/views/box_organizer \ No newline at end of file diff --git a/views/profile_design b/views/profile_design new file mode 120000 index 0000000..cb3df33 --- /dev/null +++ b/views/profile_design @@ -0,0 +1 @@ +/home/parley/Repositories/noosfero/plugins/mpog_software/views/box_organizer \ No newline at end of file -- libgit2 0.21.2