Commit d99a6c2b297ca3ceda7837988ac2487a1553314d
1 parent
d4ebc3c3
Exists in
master
and in
5 other branches
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>
Showing
6 changed files
with
99 additions
and
20 deletions
Show diff stats
... | ... | @@ -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 | 49 | \ No newline at end of file | ... | ... |
features/step_definitions/mpog_steps.rb
... | ... | @@ -105,21 +105,33 @@ end |
105 | 105 | |
106 | 106 | Given /^the following softwares$/ do |table| |
107 | 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 | 135 | software_info.save! |
124 | 136 | end |
125 | 137 | end | ... | ... |
lib/softwares_block.rb
1 | 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 | 6 | def self.description |
6 | 7 | _('Softwares') |
7 | 8 | end |
8 | 9 | |
9 | 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 | 18 | end |
12 | 19 | |
13 | 20 | def help |
... | ... | @@ -15,6 +22,7 @@ class SoftwaresBlock < CommunitiesBlock |
15 | 22 | end |
16 | 23 | |
17 | 24 | def footer |
25 | + self.software_type ||= "All" | |
18 | 26 | owner = self.owner |
19 | 27 | case owner |
20 | 28 | when Profile |
... | ... | @@ -51,9 +59,15 @@ class SoftwaresBlock < CommunitiesBlock |
51 | 59 | |
52 | 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 | 71 | end |
58 | 72 | end |
59 | 73 | ... | ... |