Commit d99a6c2b297ca3ceda7837988ac2487a1553314d

Authored by Parley
1 parent d4ebc3c3
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Software Block provides option of public, generic and all softwares.

-Tests also added

Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com>
Signed-off-by: Parley Martins <parley@outlook.com>
features/software_block.feature 0 → 100644
@@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
  1 +Feature: edit adherent fields
  2 + As a user
  3 + I want to edit adherent fields
  4 + to mantain my public software up to date.
  5 +
  6 + Background:
  7 + Given "MpogSoftwarePlugin" plugin is enabled
  8 + And I am logged in as mpog_admin
  9 + And I go to /admin/plugins
  10 + And I check "MpogSoftwarePlugin"
  11 + And I press "Save changes"
  12 + And the following softwares
  13 + | name | public_software |
  14 + | Public Software | true |
  15 + | Generic Software | false |
  16 +
  17 + Scenario: Add software block
  18 + Given I am logged in as mpog_admin
  19 + And I follow "Control panel"
  20 + And I follow "Edit sideboxes"
  21 + When I follow "Add a block"
  22 + And I choose "Softwares"
  23 + And I press "Add"
  24 + Then I should see "softwares"
  25 +
  26 + Scenario: Change software block to generic software block
  27 + Given I am logged in as mpog_admin
  28 + And I follow "Control panel"
  29 + And I follow "Edit sideboxes"
  30 + When I follow "Add a block"
  31 + And I choose "Softwares"
  32 + And I press "Add"
  33 + And I follow "Edit" within ".softwares-block"
  34 + And I select "Generic" from "block_software_type"
  35 + And I press "Save"
  36 + Then I should see "generic software"
  37 +
  38 + Scenario: Change software block to generic software block
  39 + Given I am logged in as mpog_admin
  40 + And I follow "Control panel"
  41 + And I follow "Edit sideboxes"
  42 + When I follow "Add a block"
  43 + And I choose "Softwares"
  44 + And I press "Add"
  45 + And I follow "Edit" within ".softwares-block"
  46 + And I select "Public" from "block_software_type"
  47 + And I press "Save"
  48 + Then I should see "public software"
0 \ No newline at end of file 49 \ No newline at end of file
features/step_definitions/mpog_steps.rb
@@ -105,21 +105,33 @@ end @@ -105,21 +105,33 @@ end
105 105
106 Given /^the following softwares$/ do |table| 106 Given /^the following softwares$/ do |table|
107 table.hashes.each do |item| 107 table.hashes.each do |item|
108 - community = Community.create :name=>item[:name]  
109 - programming_language = ProgrammingLanguage.where(:name=>item[:software_language]).first  
110 - database_description = DatabaseDescription.where(:name=>item[:software_database]).first  
111 -  
112 - software_language = SoftwareLanguage.where(:programming_language_id=>programming_language).first  
113 - software_database = SoftwareDatabase.where(:database_description_id=>database_description).first  
114 -  
115 - operating_system_name = OperatingSystemName.where(:name => item[:operating_system]).first  
116 - operating_system = OperatingSystem.where(:operating_system_name_id => operating_system_name).first  
117 -  
118 - software_info = SoftwareInfo::new(:acronym=>item[:acronym], :operating_platform=>item[:operating_platform], :objectives => item[:objectives], :features => item[:features])  
119 - software_info.community = community  
120 - software_info.software_languages << software_language  
121 - software_info.software_databases << software_database  
122 - software_info.operating_systems << operating_system 108 + software_info = SoftwareInfo.new
  109 + software_info.community = Community.create(:name=>item[:name])
  110 +
  111 + software_info.acronym = item[:acronym] if item[:acronym]
  112 + software_info.acronym = item[:operating_platform] if item[:operating_platform]
  113 + software_info.acronym = item[:objectives] if item[:objectives]
  114 + software_info.acronym = item[:features] if item[:features]
  115 + software_info.public_software = item[:public_software] == "true" if item[:public_software]
  116 +
  117 + if item[:software_language]
  118 + programming_language = ProgrammingLanguage.where(:name=>item[:software_language]).first
  119 + software_language = SoftwareLanguage.where(:programming_language_id=>programming_language).first
  120 + software_info.software_languages << software_language
  121 + end
  122 +
  123 + if item[:software_database]
  124 + database_description = DatabaseDescription.where(:name=>item[:software_database]).first
  125 + software_database = SoftwareDatabase.where(:database_description_id=>database_description).first
  126 + software_info.software_databases << software_database
  127 + end
  128 +
  129 + if item[:operating_system]
  130 + operating_system_name = OperatingSystemName.where(:name => item[:operating_system]).first
  131 + operating_system = OperatingSystem.where(:operating_system_name_id => operating_system_name).first
  132 + software_info.operating_systems << operating_system
  133 + end
  134 +
123 software_info.save! 135 software_info.save!
124 end 136 end
125 end 137 end
lib/softwares_block.rb
1 class SoftwaresBlock < CommunitiesBlock 1 class SoftwaresBlock < CommunitiesBlock
2 2
3 - attr_accessible :accessor_id, :accessor_type, :role_id, :resource_id, :resource_type 3 + settings_items :software_type
  4 + attr_accessible :accessor_id, :accessor_type, :role_id, :resource_id, :resource_type, :software_type
4 5
5 def self.description 6 def self.description
6 _('Softwares') 7 _('Softwares')
7 end 8 end
8 9
9 def default_title 10 def default_title
10 - n_('{#} software', '{#} softwares', profile_count) 11 + if self.software_type == "Generic"
  12 + return n_('{#} generic software', '{#} generic softwares', profile_count)
  13 + elsif self.software_type == "Public"
  14 + return n_('{#} public software', '{#} public softwares', profile_count)
  15 + else
  16 + return n_('{#} software', '{#} softwares', profile_count)
  17 + end
11 end 18 end
12 19
13 def help 20 def help
@@ -15,6 +22,7 @@ class SoftwaresBlock &lt; CommunitiesBlock @@ -15,6 +22,7 @@ class SoftwaresBlock &lt; CommunitiesBlock
15 end 22 end
16 23
17 def footer 24 def footer
  25 + self.software_type ||= "All"
18 owner = self.owner 26 owner = self.owner
19 case owner 27 case owner
20 when Profile 28 when Profile
@@ -51,9 +59,15 @@ class SoftwaresBlock &lt; CommunitiesBlock @@ -51,9 +59,15 @@ class SoftwaresBlock &lt; CommunitiesBlock
51 59
52 list_with_software = [] 60 list_with_software = []
53 61
54 - visible_profiles.each do |p|  
55 - if p.class == Community and p.software? and !p.institution?  
56 - list_with_software << p 62 + result.each do |profile|
  63 + if profile.class == Community and profile.software?
  64 + if self.software_type == "Public"
  65 + list_with_software << profile if profile.software_info.public_software?
  66 + elsif self.software_type == "Generic"
  67 + list_with_software << profile if !profile.software_info.public_software?
  68 + else
  69 + list_with_software << profile
  70 + end
57 end 71 end
58 end 72 end
59 73
views/box_organizer/_softwares_block.html.erb 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +<div id='edit-softwares-block'>
  2 + <%= labelled_form_field _('Software Type:'), select_tag('block[software_type]', options_for_select(["Public", "Generic", "All"], @block.software_type) )%>
  3 +</div>
views/environment_design 0 → 120000
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +/home/parley/Repositories/noosfero/plugins/mpog_software/views/box_organizer
0 \ No newline at end of file 2 \ No newline at end of file
views/profile_design 0 → 120000
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +/home/parley/Repositories/noosfero/plugins/mpog_software/views/box_organizer
0 \ No newline at end of file 2 \ No newline at end of file