Commit 2212e3aa5cc611fb454ca6e66e58ca47b2966978
Exists in
master
and in
5 other branches
Merge branch 'software_search'
Conflicts: lib/mpog_software_plugin.rb views/institution_editor_extras.html.erb views/mpog_software_plugin/create_institution.html.erb
Showing
14 changed files
with
818 additions
and
63 deletions
Show diff stats
... | ... | @@ -0,0 +1,15 @@ |
1 | +module ControlledVocabularyHelper | |
2 | + | |
3 | + def self.get_categories_as_options | |
4 | + categories = ["<option value = #{""} >Any</option>".html_safe] | |
5 | + value = 1 | |
6 | + | |
7 | + ControlledVocabulary.attribute_names.each do |attribute| | |
8 | + if attribute.to_s != "id" && attribute.to_s != "software_info_id" then | |
9 | + categories << "<option value = #{attribute} >#{attribute.titleize}</option>".html_safe | |
10 | + value+=1 | |
11 | + end | |
12 | + end | |
13 | + categories | |
14 | + end | |
15 | +end | ... | ... |
lib/ext/person.rb
... | ... | @@ -12,22 +12,22 @@ class Person |
12 | 12 | like_sql = "" |
13 | 13 | values = [] |
14 | 14 | |
15 | - unless name.nil? and name.blank? | |
16 | - like_sql << "name ILIKE ? AND " | |
17 | - values << "%#{name}%" | |
15 | + unless name.blank? | |
16 | + like_sql << "name ILIKE ? OR identifier ILIKE ? AND " | |
17 | + values << "%#{name}%" << "%#{name}%" | |
18 | 18 | end |
19 | 19 | |
20 | - unless state.nil? and state.blank? | |
20 | + unless state.blank? | |
21 | 21 | like_sql << "data ILIKE ? AND " |
22 | 22 | values << "%:state: %#{state}%" |
23 | 23 | end |
24 | 24 | |
25 | - unless city.nil? and city.blank? | |
25 | + unless city.blank? | |
26 | 26 | like_sql << "data ILIKE ? AND " |
27 | 27 | values << "%:city: %#{city}%" |
28 | 28 | end |
29 | 29 | |
30 | - unless email.nil? and email.blank? | |
30 | + unless email.blank? | |
31 | 31 | like_sql << "email ILIKE ? AND " |
32 | 32 | values << "%#{email}%" |
33 | 33 | end | ... | ... |
lib/mpog_software_plugin.rb
... | ... | @@ -130,6 +130,59 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
130 | 130 | }] |
131 | 131 | end |
132 | 132 | |
133 | + def search_controller_filters | |
134 | + community_block = proc do | |
135 | + results = [] | |
136 | + if params[:type] == "Software" | |
137 | + softwares = SoftwareInfo.search(params[:name], params[:database_description][:id], | |
138 | + params[:programming_language][:id], params[:operating_system][:id], | |
139 | + params[:license_info][:id], params[:e_ping], params[:e_mag], params[:internacionalizable], | |
140 | + params[:icp_brasil], params[:e_arq], params[:controlled_vocabulary]) | |
141 | + communities = [] | |
142 | + | |
143 | + softwares.each do |s| | |
144 | + communities << s.community | |
145 | + end | |
146 | + results = communities | |
147 | + results = results.paginate(:per_page => 24, :page => params[:page]) | |
148 | + @searches[@asset] = {:results => results} | |
149 | + @search = results | |
150 | + | |
151 | + render :action => :communities | |
152 | + end | |
153 | + end | |
154 | + | |
155 | + people_block = proc do | |
156 | + results = [] | |
157 | + | |
158 | + results = environment.people.search(name = params[:name], | |
159 | + state = params[:state], | |
160 | + city = params[:city], | |
161 | + email = params[:email] | |
162 | + ) | |
163 | + | |
164 | + results = results.paginate(:per_page => 24, :page => params[:page]) | |
165 | + @searches[@asset] = {:results => results} | |
166 | + @search = results | |
167 | + | |
168 | + render :action => :people | |
169 | + end | |
170 | + | |
171 | + | |
172 | + [{ | |
173 | + :type => "before_filter", | |
174 | + :method_name => "search_person_filters", | |
175 | + :options => { :only=>:people }, | |
176 | + :block => people_block | |
177 | + }, | |
178 | + { | |
179 | + :type => "before_filter", | |
180 | + :method_name => "search_software_filters", | |
181 | + :options => { :only=>:communities }, | |
182 | + :block => community_block | |
183 | + }] | |
184 | + end | |
185 | + | |
133 | 186 | def profile_tabs |
134 | 187 | if context.profile.person? |
135 | 188 | { :title => _("Mpog"), |
... | ... | @@ -155,7 +208,7 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
155 | 208 | end |
156 | 209 | |
157 | 210 | def js_files |
158 | - ["mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js", "mpog-incomplete-registration.js"] | |
211 | + ["mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js", "mpog-incomplete-registration.js", "mpog-search.js"] | |
159 | 212 | end |
160 | 213 | |
161 | 214 | def add_new_organization_button |
... | ... | @@ -352,16 +405,20 @@ class MpogSoftwarePlugin < Noosfero::Plugin |
352 | 405 | end |
353 | 406 | end |
354 | 407 | |
355 | - def add_new_user_search_filter | |
356 | - expanded_template('user_search/search_filter.html.erb') | |
357 | - end | |
408 | + def add_new_search_filter | |
409 | + if context.params[:action] == "people" | |
410 | + expanded_template('search/search_user_filter.html.erb') | |
411 | + else context.params[:action] == "communities" | |
412 | + @active_type = if context.params[:type] == "Software" | |
413 | + "software" | |
414 | + elsif context.params[:type] == "Institution" | |
415 | + "institution" | |
416 | + else | |
417 | + "community" | |
418 | + end | |
358 | 419 | |
359 | - def custom_people_search params | |
360 | - Person.search(params[:name], | |
361 | - params[:state], | |
362 | - params[:city], | |
363 | - params[:email] | |
364 | - ) | |
420 | + expanded_template('search/search_community_filter.html.erb') | |
421 | + end | |
365 | 422 | end |
366 | 423 | |
367 | 424 | def controlled_vocabulary_transaction | ... | ... |
lib/software_info.rb
... | ... | @@ -21,6 +21,79 @@ class SoftwareInfo < ActiveRecord::Base |
21 | 21 | joins(:community).where("name ilike ?", "%#{name}%") |
22 | 22 | } |
23 | 23 | |
24 | + scope :search, lambda { |name="", database_description_id = "", | |
25 | + programming_language_id = "", operating_system_name_id = "", | |
26 | + license_info_id = "", e_ping = "", e_mag = "", internacionalizable = "", | |
27 | + icp_brasil = "", e_arq = "", controlled_vocabulary = "" | | |
28 | + | |
29 | + like_sql = "" | |
30 | + values = [] | |
31 | + | |
32 | + unless name.blank? | |
33 | + like_sql << "name ILIKE ? OR identifier ILIKE ? AND " | |
34 | + values << "%#{name}%" << "%#{name}%" | |
35 | + end | |
36 | + | |
37 | + unless database_description_id.blank? | |
38 | + like_sql << "software_databases.database_description_id = ? AND " | |
39 | + values << "#{database_description_id}" | |
40 | + end | |
41 | + | |
42 | + unless programming_language_id.blank? | |
43 | + like_sql << "software_languages.programming_language_id = ? AND " | |
44 | + values << "#{programming_language_id}" | |
45 | + end | |
46 | + | |
47 | + unless operating_system_name_id.blank? | |
48 | + like_sql << "operating_systems.operating_system_name_id = ? AND " | |
49 | + values << "#{operating_system_name_id}" | |
50 | + end | |
51 | + | |
52 | + unless license_info_id.blank? | |
53 | + like_sql << "license_info_id = ? AND " | |
54 | + values << "#{license_info_id}" | |
55 | + end | |
56 | + | |
57 | + unless internacionalizable.blank? | |
58 | + like_sql << "intern = ? AND " | |
59 | + values << "#{internacionalizable}" | |
60 | + end | |
61 | + | |
62 | + unless icp_brasil.blank? | |
63 | + like_sql << "icp_brasil = ? AND " | |
64 | + values << "#{icp_brasil}" | |
65 | + end | |
66 | + | |
67 | + unless e_ping.blank? | |
68 | + like_sql << "e_ping = ? AND " | |
69 | + values << "#{e_ping}" | |
70 | + end | |
71 | + | |
72 | + unless e_mag.blank? | |
73 | + like_sql << "e_mag = ? AND " | |
74 | + values << "#{e_mag}" | |
75 | + end | |
76 | + | |
77 | + unless e_arq.blank? | |
78 | + like_sql << "e_arq = ? AND " | |
79 | + values << "#{e_arq}" | |
80 | + end | |
81 | + | |
82 | + unless controlled_vocabulary.blank? | |
83 | + controlled_vocabulary = controlled_vocabulary.gsub(' ', '').underscore | |
84 | + like_sql << "controlled_vocabulary.#{controlled_vocabulary} = ? AND " | |
85 | + values << "true" | |
86 | + end | |
87 | + | |
88 | + like_sql = like_sql[0..like_sql.length-5] | |
89 | + | |
90 | + { | |
91 | + :joins => [:community, :software_databases, :software_languages, | |
92 | + :operating_systems, :controlled_vocabulary], | |
93 | + :conditions=>[like_sql, *values] | |
94 | + } | |
95 | + } | |
96 | + | |
24 | 97 | def validate_operating_platform |
25 | 98 | self.errors.add(:operating_platform, _("can't be blank")) if self.operating_platform.blank? && self.errors.messages[:operating_platform].nil? |
26 | 99 | end | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
1 | +(function(){ | |
2 | + | |
3 | + function show_institutions_fields() { | |
4 | + jQuery(".institution_fields").show(); | |
5 | + jQuery(".software_fields").hide(); | |
6 | + jQuery(".community_fields").hide(); | |
7 | + } | |
8 | + | |
9 | + function show_software_fields() { | |
10 | + jQuery(".institution_fields").hide(); | |
11 | + jQuery(".software_fields").show(); | |
12 | + jQuery(".community_fields").hide(); | |
13 | + } | |
14 | + | |
15 | + function show_community_fields() { | |
16 | + jQuery(".institution_fields").hide(); | |
17 | + jQuery(".software_fields").hide(); | |
18 | + jQuery(".community_fields").show(); | |
19 | + } | |
20 | + | |
21 | + function display_search_fields_on_page_load() { | |
22 | + var active_search = jQuery(".search_type input[checked='checked']").val(); | |
23 | + | |
24 | + switch(active_search) { | |
25 | + case "Community": show_community_fields(); break; | |
26 | + case "Software": show_software_fields(); break; | |
27 | + case "Institution": show_institutions_fields(); break; | |
28 | + | |
29 | + default: show_community_fields(); | |
30 | + } | |
31 | + } | |
32 | + | |
33 | + function set_events() { | |
34 | + display_search_fields_on_page_load(); | |
35 | + | |
36 | + jQuery("#type_Community").click(show_community_fields); | |
37 | + | |
38 | + jQuery("#type_Software").click(show_software_fields); | |
39 | + | |
40 | + jQuery("#type_Institution").click(show_institutions_fields); | |
41 | + } | |
42 | + | |
43 | + jQuery(document).ready(set_events); | |
44 | +})(); | ... | ... |
public/style.css
... | ... | @@ -77,28 +77,25 @@ |
77 | 77 | height: auto; |
78 | 78 | } |
79 | 79 | |
80 | -.user_filter_options { | |
80 | +.mpog_search_form_fields { | |
81 | + margin-top: 10px; | |
81 | 82 | width: 80%; |
82 | 83 | height: auto; |
83 | 84 | position: relative; |
84 | 85 | float: left; |
85 | 86 | } |
86 | 87 | |
87 | -.user_filter_options input[type='text'] { | |
88 | - width: 78%; | |
89 | - | |
88 | +.mpog_search_form_button { | |
89 | + margin-top: 10px; | |
90 | 90 | } |
91 | 91 | |
92 | -.user_filter_actions { | |
93 | - width: 18 %; | |
94 | - height: auto; | |
95 | - position: relative; | |
96 | - float: right; | |
97 | - text-align: right; | |
92 | +.mpog_search_form_fields input[type='text'] { | |
93 | + width: 90%; | |
94 | + | |
98 | 95 | } |
99 | 96 | |
100 | -.search-table tr td:first-child { | |
101 | - width: 40px; | |
97 | +.mpog_search_form_table tr td:first-child { | |
98 | + width: 22%; | |
102 | 99 | } |
103 | 100 | |
104 | 101 | .formfieldline { | ... | ... |
... | ... | @@ -0,0 +1,316 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | +require File.dirname(__FILE__) + '/../../../../app/controllers/public/search_controller' | |
3 | + | |
4 | +class SearchController; def rescue_action(e) raise e end; end | |
5 | + | |
6 | +class SearchControllerTest < ActionController::TestCase | |
7 | + | |
8 | + def setup | |
9 | + environment = Environment.default | |
10 | + environment.enabled_plugins = ['MpogSoftwarePlugin'] | |
11 | + environment.save | |
12 | + | |
13 | + @controller = SearchController.new | |
14 | + @request = ActionController::TestRequest.new | |
15 | + @request.stubs(:ssl?).returns(:false) | |
16 | + @response = ActionController::TestResponse.new | |
17 | + | |
18 | + LicenseInfo.create(:version=>"GPL-2", :link =>"www.gpl2.com") | |
19 | + ProgrammingLanguage.create(:name=>"C++") | |
20 | + DatabaseDescription.create(:name => "Oracle") | |
21 | + OperatingSystemName.create(:name=>"Debian") | |
22 | + | |
23 | + operating_system = OperatingSystem.new(version: '1.0') | |
24 | + operating_system.operating_system_name = OperatingSystemName.last | |
25 | + operating_system.save! | |
26 | + | |
27 | + software_language = SoftwareLanguage.new(version: "1.0", operating_system: "windows") | |
28 | + software_language.programming_language = ProgrammingLanguage.last | |
29 | + software_language.save! | |
30 | + | |
31 | + software_database = SoftwareDatabase.new(version: "1.0", operating_system: "windows") | |
32 | + software_database.database_description = DatabaseDescription.last | |
33 | + software_database.save! | |
34 | + | |
35 | + end | |
36 | + | |
37 | + should "search for people by identifier" do | |
38 | + p1 = create_user("user 1", "DF", "Gama", "user_1@user.com").person | |
39 | + | |
40 | + get :people, :query => "user-1" | |
41 | + | |
42 | + assert_includes assigns(:searches)[:people][:results], p1 | |
43 | + end | |
44 | + | |
45 | + should "search for people by name" do | |
46 | + p1 = create_user("user_1", "DF", "Gama", "user_1@user.com").person | |
47 | + | |
48 | + get :people, :query => "user_1" | |
49 | + | |
50 | + assert_includes assigns(:searches)[:people][:results], p1 | |
51 | + end | |
52 | + | |
53 | + should "search for people by state" do | |
54 | + p1 = create_user("user_1", "DF", "Gama", "user_1@user.com").person | |
55 | + | |
56 | + get :people, :state => "DF" | |
57 | + | |
58 | + assert_includes assigns(:searches)[:people][:results], p1 | |
59 | + end | |
60 | + | |
61 | + should "search for people by city" do | |
62 | + p1 = create_user("user_1", "DF", "Gama", "user_1@user.com").person | |
63 | + | |
64 | + get :people, :city => "Gama" | |
65 | + | |
66 | + assert_includes assigns(:searches)[:people][:results], p1 | |
67 | + end | |
68 | + | |
69 | + should "search for people by email" do | |
70 | + p1 = create_user("user_1", "DF", "Gama", "user_1@user.com").person | |
71 | + | |
72 | + get :people, :email => "user_1@user.com" | |
73 | + | |
74 | + assert_includes assigns(:searches)[:people][:results], p1 | |
75 | + end | |
76 | + | |
77 | + should "search for people by email and state" do | |
78 | + p1 = create_user("user_1", "DF", "Gama", "user_1@user.com").person | |
79 | + | |
80 | + get :people, :email => "user_1@user.com", :state => "DF" | |
81 | + | |
82 | + assert_includes assigns(:searches)[:people][:results], p1 | |
83 | + end | |
84 | + | |
85 | + should "search for software by identifier" do | |
86 | + software = create_software("beautiful os") | |
87 | + | |
88 | + params = {"type"=>"Software", "query"=>"", "name"=>"beautiful-os", "database_description"=>{"id"=>""}, "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", "commit"=>"Search"} | |
89 | + get :communities, params | |
90 | + | |
91 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
92 | + end | |
93 | + | |
94 | + should "search for software by name" do | |
95 | + software = create_software("beautiful") | |
96 | + | |
97 | + params = {"type"=>"Software", "query"=>"", "name"=>"beautiful", "database_description"=>{"id"=>""}, "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", "commit"=>"Search"} | |
98 | + get :communities, params | |
99 | + | |
100 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
101 | + end | |
102 | + | |
103 | + should "search for software by database" do | |
104 | + software = create_software("beautiful") | |
105 | + software.software_databases.clear() | |
106 | + software.software_databases << SoftwareDatabase.last | |
107 | + software.save! | |
108 | + | |
109 | + params = {"type"=>"Software", "query"=>"", "name"=>"", | |
110 | + "database_description"=>{"id"=>SoftwareDatabase.last.database_description.id}, | |
111 | + "programming_language"=>{"id"=>""}, "operating_system"=>{"id"=>""}, "controlled_vocabulary"=>"", | |
112 | + "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
113 | + "commit"=>"Search"} | |
114 | + get :communities, params | |
115 | + | |
116 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
117 | + end | |
118 | + | |
119 | + should "search for software by programming language" do | |
120 | + software = create_software("beautiful") | |
121 | + software.software_languages.clear() | |
122 | + software.software_languages << SoftwareLanguage.last | |
123 | + software.save! | |
124 | + | |
125 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
126 | + "programming_language"=>{"id"=>SoftwareLanguage.last.programming_language.id}, | |
127 | + "operating_system"=>{"id"=>""}, "controlled_vocabulary"=>"", | |
128 | + "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
129 | + "commit"=>"Search"} | |
130 | + get :communities, params | |
131 | + | |
132 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
133 | + end | |
134 | + | |
135 | + should "search for software by operating system" do | |
136 | + software = create_software("beautiful") | |
137 | + software.operating_systems.clear() | |
138 | + software.operating_systems << OperatingSystem.last | |
139 | + software.save! | |
140 | + | |
141 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
142 | + "programming_language"=>{"id"=>""}, | |
143 | + "operating_system"=>{"id"=>OperatingSystem.last.id}, | |
144 | + "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
145 | + "commit"=>"Search"} | |
146 | + get :communities, params | |
147 | + | |
148 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
149 | + end | |
150 | + | |
151 | + should "search for software by controlled vocabulary" do | |
152 | + software = create_software("beautiful") | |
153 | + software.controlled_vocabulary.habitation = true | |
154 | + software.controlled_vocabulary.save! | |
155 | + | |
156 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
157 | + "programming_language"=>{"id"=>""}, | |
158 | + "operating_system"=>{"id"=>""}, | |
159 | + "controlled_vocabulary"=>"habitation", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
160 | + "commit"=>"Search"} | |
161 | + get :communities, params | |
162 | + | |
163 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
164 | + end | |
165 | + | |
166 | + should "search for software by license info" do | |
167 | + software = create_software("beautiful") | |
168 | + software.license_info = LicenseInfo.last | |
169 | + software.save! | |
170 | + | |
171 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
172 | + "programming_language"=>{"id"=>""}, | |
173 | + "operating_system"=>{"id"=>""}, | |
174 | + "controlled_vocabulary"=>"", "license_info"=>{"id"=>LicenseInfo.last.id}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
175 | + "commit"=>"Search"} | |
176 | + get :communities, params | |
177 | + | |
178 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
179 | + end | |
180 | + | |
181 | + | |
182 | + should "search for software by e_mag" do | |
183 | + software = create_software("beautiful") | |
184 | + software.e_mag = true | |
185 | + software.save! | |
186 | + | |
187 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
188 | + "programming_language"=>{"id"=>""}, | |
189 | + "operating_system"=>{"id"=>""}, | |
190 | + "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"true", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
191 | + "commit"=>"Search"} | |
192 | + get :communities, params | |
193 | + | |
194 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
195 | + end | |
196 | + | |
197 | + | |
198 | + should "search for software by e_ping" do | |
199 | + software = create_software("beautiful") | |
200 | + software.e_ping = true | |
201 | + software.save! | |
202 | + | |
203 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
204 | + "programming_language"=>{"id"=>""}, | |
205 | + "operating_system"=>{"id"=>""}, | |
206 | + "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"true", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"", | |
207 | + "commit"=>"Search"} | |
208 | + get :communities, params | |
209 | + | |
210 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
211 | + end | |
212 | + | |
213 | + | |
214 | + should "search for software by icp_brasil" do | |
215 | + software = create_software("beautiful") | |
216 | + software.icp_brasil = true | |
217 | + software.save! | |
218 | + | |
219 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
220 | + "programming_language"=>{"id"=>""}, | |
221 | + "operating_system"=>{"id"=>""}, | |
222 | + "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"true", "e_arq"=>"", "internacionalizable"=>"", | |
223 | + "commit"=>"Search"} | |
224 | + get :communities, params | |
225 | + | |
226 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
227 | + end | |
228 | + | |
229 | + should "search for software by e_arq" do | |
230 | + software = create_software("beautiful") | |
231 | + software.e_arq = true | |
232 | + software.save! | |
233 | + | |
234 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
235 | + "programming_language"=>{"id"=>""}, | |
236 | + "operating_system"=>{"id"=>""}, | |
237 | + "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"true", "internacionalizable"=>"", | |
238 | + "commit"=>"Search"} | |
239 | + get :communities, params | |
240 | + | |
241 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
242 | + end | |
243 | + | |
244 | + should "search for software by internacionalizable" do | |
245 | + software = create_software("beautiful") | |
246 | + software.intern = true | |
247 | + software.save! | |
248 | + | |
249 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
250 | + "programming_language"=>{"id"=>""}, | |
251 | + "operating_system"=>{"id"=>""}, | |
252 | + "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"", "internacionalizable"=>"true", | |
253 | + "commit"=>"Search"} | |
254 | + get :communities, params | |
255 | + | |
256 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
257 | + end | |
258 | + | |
259 | + should "search by e_arq and e_ping" do | |
260 | + software = create_software("beautiful") | |
261 | + software.e_arq = true | |
262 | + software.e_ping = true | |
263 | + software.save! | |
264 | + | |
265 | + params = {"type"=>"Software", "query"=>"", "name"=>"", "database_description"=>{"id"=>""}, | |
266 | + "programming_language"=>{"id"=>""}, | |
267 | + "operating_system"=>{"id"=>""}, | |
268 | + "controlled_vocabulary"=>"", "license_info"=>{"id"=>""}, "e_ping"=>"true", "e_mag"=>"", "icp_brasil"=>"", "e_arq"=>"true", "internacionalizable"=>"", | |
269 | + "commit"=>"Search"} | |
270 | + get :communities, params | |
271 | + | |
272 | + assert_includes assigns(:searches)[:communities][:results], software.community | |
273 | + end | |
274 | + | |
275 | + protected | |
276 | + | |
277 | + def create_user name, state, city, email | |
278 | + user = fast_create(User) | |
279 | + user.person = fast_create(Person) | |
280 | + user.person.state = state | |
281 | + user.person.city = city | |
282 | + user.person.email = email | |
283 | + user.save! | |
284 | + user.person.save! | |
285 | + user | |
286 | + end | |
287 | + | |
288 | + def create_software name | |
289 | + community = Community.create(:name => name) | |
290 | + software_info = SoftwareInfo::new(:acronym=>"SFT", :operating_platform=>"windows") | |
291 | + software_info.community = community | |
292 | + software_info.software_languages << SoftwareLanguage.last | |
293 | + software_info.software_databases << SoftwareDatabase.last | |
294 | + software_info.operating_systems << OperatingSystem.last | |
295 | + software_info.license_info = LicenseInfo.last | |
296 | + | |
297 | + | |
298 | + cv = ControlledVocabulary.new() | |
299 | + cv.attributes.each do |key| | |
300 | + if(key.first == 'id' || key.first == 'software_info_id') | |
301 | + next | |
302 | + end | |
303 | + cv.update_attribute(key.first, false) | |
304 | + end | |
305 | + cv.save! | |
306 | + | |
307 | + software_info.controlled_vocabulary = cv | |
308 | + | |
309 | + software_info.save! | |
310 | + | |
311 | + community.save! | |
312 | + | |
313 | + software_info | |
314 | + end | |
315 | + | |
316 | +end | ... | ... |
views/institution_editor_extras.html.erb
... | ... | @@ -0,0 +1,36 @@ |
1 | +<form action="/search/communities" name="community_filter" method="POST" class="search_form"> | |
2 | + <div id="search_content"> | |
3 | + | |
4 | + <div class="search_options"> | |
5 | + <table class="mpog_search_form_table formfield type-radio search_type"> | |
6 | + <tr> | |
7 | + <td> | |
8 | + <%= label_tag("type_Community", _("Community")) %> | |
9 | + <%= radio_button_tag(:type, "Community", (true if @active_type == "community")) %> | |
10 | + <%= label_tag("type_Software", _("Software")) %> | |
11 | + <%= radio_button_tag(:type, "Software", (true if @active_type == "software")) %> | |
12 | + <%= label_tag("type_Institution", _("Institution")) %> | |
13 | + <%= radio_button_tag(:type, "Institution", (true if @active_type == "institution")) %> | |
14 | + </td> | |
15 | + </tr> | |
16 | + </table> | |
17 | + </div> | |
18 | + | |
19 | + <div class="community_fields mpog_search_form_fields"> | |
20 | + <%= expanded_template "search/search_forms/_community_fields.html.erb" %> | |
21 | + </div> | |
22 | + | |
23 | + <div class="software_fields mpog_search_form_fields"> | |
24 | + <%= expanded_template "search/search_forms/_software_fields.html.erb" %> | |
25 | + </div> | |
26 | + | |
27 | + <div class="institution_fields mpog_search_form_fields"> | |
28 | + <%= expanded_template "search/search_forms/_institution_fields.html.erb" %> | |
29 | + </div> | |
30 | + | |
31 | + <div class="mpog_search_form_button"> | |
32 | + <%= submit_button(:search, _('Search')) %> | |
33 | + </div> | |
34 | + </div> | |
35 | + | |
36 | +</form> | ... | ... |
... | ... | @@ -0,0 +1,74 @@ |
1 | +<table class="mpog_search_form_table"> | |
2 | + <tr> | |
3 | + <td> <%= label_tag("intitution_name", _("Name"))%> </td> | |
4 | + <td> <%= text_field_tag(:intitution_name) %> </td> | |
5 | + </tr> | |
6 | + | |
7 | + <tr> | |
8 | + <td> <%= _("Country") %> </td> | |
9 | + <td> | |
10 | + <%= select_tag(:intitution_country, options_for_select(CountriesHelper.countries)) %> | |
11 | + </td> | |
12 | + </tr> | |
13 | + | |
14 | + <tr> | |
15 | + <td> <%= label_tag("intitution_state", _("Stage"))%> </td> | |
16 | + <td> <%= text_field_tag(:intitution_state) %> </td> | |
17 | + </tr> | |
18 | + | |
19 | + <tr> | |
20 | + <td> <%= label_tag("intitution_city", _("City"))%> </td> | |
21 | + <td> <%= text_field_tag(:intitution_city) %> </td> | |
22 | + </tr> | |
23 | + | |
24 | + <tr> | |
25 | + <td> <%= label_tag("intitution_cnpj", _("cnpj"))%> </td> | |
26 | + <td> <%= text_field_tag(:intitution_cnpj, nil, :placeholder=>"99.999.999/9999-99") %> </td> | |
27 | + </tr> | |
28 | + | |
29 | + <tr> | |
30 | + <td> <%= label_tag("intitution_acronym", _("Acronym"))%> </td> | |
31 | + <td> <%= text_field_tag(:intitution_acronym, nil) %> </td> | |
32 | + </tr> | |
33 | + | |
34 | + <tr> | |
35 | + <td> <%= _("Institution type ?") %> </td> | |
36 | + <td> | |
37 | + <label> | |
38 | + <%= radio_button_tag(:institution_type, "", true) %> | |
39 | + <%= _("Any") %> | |
40 | + </label> | |
41 | + | |
42 | + <label> | |
43 | + <%= radio_button_tag(:institution_type, "public") %> | |
44 | + <%= _("Public") %> | |
45 | + </label> | |
46 | + | |
47 | + <label> | |
48 | + <%= radio_button_tag(:institution_type, "private") %> | |
49 | + <%= _("Private") %> | |
50 | + </label> | |
51 | + </td> | |
52 | + </tr> | |
53 | + | |
54 | + <tr> | |
55 | + <td> <%= _("Governmental Power") %> </td> | |
56 | + <td> | |
57 | + <%= collection_select(:institution_gov_power, :id, GovernmentalPower.all, :id, :name, :prompt=>_("Any")) %> | |
58 | + </td> | |
59 | + </tr> | |
60 | + | |
61 | + <tr> | |
62 | + <td> <%= _("Governmental Sphere") %> </td> | |
63 | + <td> | |
64 | + <%= collection_select(:institution_gov_sphere, :id, GovernmentalSphere.all, :id, :name, :prompt=>_("Any")) %> | |
65 | + </td> | |
66 | + </tr> | |
67 | + | |
68 | + <tr> | |
69 | + <td> <%= _("Juridical Nature") %> </td> | |
70 | + <td> | |
71 | + <%= collection_select(:institution_juridical_nature, :id, JuridicalNature.all, :id, :name, :prompt=>_("Any")) %> | |
72 | + </td> | |
73 | + </tr> | |
74 | +</table> | |
0 | 75 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,141 @@ |
1 | +<table class="mpog_search_form_table"> | |
2 | + <tr> | |
3 | + <td> <%= label_tag("name", _("Name"))%> </td> | |
4 | + <td> <%= text_field_tag(:name) %> </td> | |
5 | + </tr> | |
6 | + | |
7 | + <tr> | |
8 | + <td> <%= _("Database") %> </td> | |
9 | + <td> | |
10 | + <%= collection_select(:database_description, :id, DatabaseDescription.all, :id, :name, :prompt=>_("Any")) %> | |
11 | + </td> | |
12 | + </tr> | |
13 | + | |
14 | + <tr> | |
15 | + <td> <%= _("Programming Language") %> </td> | |
16 | + <td> | |
17 | + <%= collection_select(:programming_language, :id, ProgrammingLanguage.all, :id, :name, :prompt=>_("Any")) %> | |
18 | + </td> | |
19 | + </tr> | |
20 | + | |
21 | + <tr> | |
22 | + <td> <%= _("Operating System") %> </td> | |
23 | + <td> | |
24 | + <%= collection_select(:operating_system, :id, OperatingSystemName.all, :id, :name, :prompt=>_("Any")) %> | |
25 | + </td> | |
26 | + </tr> | |
27 | + | |
28 | + <tr> | |
29 | + <td> <%= _("Controlled Vocabulary") %> </td> | |
30 | + <td> | |
31 | + <%= select_tag("controlled_vocabulary", (ControlledVocabularyHelper.get_categories_as_options)) %> | |
32 | + </td> | |
33 | + </tr> | |
34 | + | |
35 | + <tr> | |
36 | + <td> <%= _("License Used") %> </td> | |
37 | + <td> | |
38 | + <%= collection_select(:license_info, :id, LicenseInfo.all, :id, :version, :prompt=>_("Any")) %> | |
39 | + </td> | |
40 | + </tr> | |
41 | + | |
42 | + <tr> | |
43 | + <td> <%= _("Adherent to e-PING ?") %> </td> | |
44 | + <td> | |
45 | + <label> | |
46 | + <%= radio_button_tag(:e_ping, "", true) %> | |
47 | + <%= _("Any") %> | |
48 | + </label> | |
49 | + | |
50 | + <label> | |
51 | + <%= radio_button_tag(:e_ping, true) %> | |
52 | + <%= _("Yes") %> | |
53 | + </label> | |
54 | + | |
55 | + <label> | |
56 | + <%= radio_button_tag(:e_ping, false) %> | |
57 | + <%= _("No") %> | |
58 | + </label> | |
59 | + </td> | |
60 | + </tr> | |
61 | + | |
62 | + <tr> | |
63 | + <td> <%= _("Adherent to e-MAG ?") %> </td> | |
64 | + <td> | |
65 | + <label> | |
66 | + <%= radio_button_tag(:e_mag, "", true) %> | |
67 | + <%= _("Any") %> | |
68 | + </label> | |
69 | + | |
70 | + <label> | |
71 | + <%= radio_button_tag(:e_mag, true) %> | |
72 | + <%= _("Yes") %> | |
73 | + </label> | |
74 | + | |
75 | + <label> | |
76 | + <%= radio_button_tag(:e_mag, false) %> | |
77 | + <%= _("No") %> | |
78 | + </label> | |
79 | + </td> | |
80 | + </tr> | |
81 | + | |
82 | + <tr> | |
83 | + <td> <%= _("Adherent to ICP-Brasil ?") %> </td> | |
84 | + <td> | |
85 | + <label> | |
86 | + <%= radio_button_tag(:icp_brasil, "", true) %> | |
87 | + <%= _("Any") %> | |
88 | + </label> | |
89 | + | |
90 | + <label> | |
91 | + <%= radio_button_tag(:icp_brasil, true) %> | |
92 | + <%= _("Yes") %> | |
93 | + </label> | |
94 | + | |
95 | + <label> | |
96 | + <%= radio_button_tag(:icp_brasil, false) %> | |
97 | + <%= _("No") %> | |
98 | + </label> | |
99 | + </td> | |
100 | + </tr> | |
101 | + | |
102 | + <tr> | |
103 | + <td> <%= _("Adherent to e-ARQ ?") %> </td> | |
104 | + <td> | |
105 | + <label> | |
106 | + <%= radio_button_tag(:e_arq, "", true) %> | |
107 | + <%= _("Any") %> | |
108 | + </label> | |
109 | + | |
110 | + <label> | |
111 | + <%= radio_button_tag(:e_arq, true) %> | |
112 | + <%= _("Yes") %> | |
113 | + </label> | |
114 | + | |
115 | + <label> | |
116 | + <%= radio_button_tag(:e_arq, false) %> | |
117 | + <%= _("No") %> | |
118 | + </label> | |
119 | + </td> | |
120 | + </tr> | |
121 | + | |
122 | + <tr> | |
123 | + <td> <%= _("Internacionalizable ?") %> </td> | |
124 | + <td> | |
125 | + <label> | |
126 | + <%= radio_button_tag(:internacionalizable, "", true) %> | |
127 | + <%= _("Any") %> | |
128 | + </label> | |
129 | + | |
130 | + <label> | |
131 | + <%= radio_button_tag(:internacionalizable, true) %> | |
132 | + <%= _("Yes") %> | |
133 | + </label> | |
134 | + | |
135 | + <label> | |
136 | + <%= radio_button_tag(:internacionalizable, false) %> | |
137 | + <%= _("No") %> | |
138 | + </label> | |
139 | + </td> | |
140 | + </tr> | |
141 | +</table> | |
0 | 142 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,29 @@ |
1 | +<form action="/search/people" name="user_filter" method="POST" class="search_form"> | |
2 | + <div id="user_filter_content"> | |
3 | + <div class="mpog_search_form_fields"> | |
4 | + | |
5 | + <table class="mpog_search_form_table"> | |
6 | + <tr> | |
7 | + <td> <%= label_tag :name, _("Name") %> </td> | |
8 | + <td> <%= text_field_tag :name %> </td> | |
9 | + </tr> | |
10 | + <tr> | |
11 | + <td> <%= label_tag :state, _("State") %> </td> | |
12 | + <td> <%= text_field_tag :state %> </td> | |
13 | + </tr> | |
14 | + <tr> | |
15 | + <td> <%= label_tag :city, _("City") %> </td> | |
16 | + <td> <%= text_field_tag :city %> </td> | |
17 | + </tr> | |
18 | + <tr> | |
19 | + <td> <%= label_tag :email, _("Email") %> </td> | |
20 | + <td> <%= text_field_tag :email %> </td> | |
21 | + </tr> | |
22 | + <tr> | |
23 | + <td> </td> | |
24 | + <td> <%= submit_button(:search, _('Search')) %> </td> | |
25 | + </tr> | |
26 | + </table> | |
27 | + </div> | |
28 | + </div> | |
29 | +</form> | |
0 | 30 | \ No newline at end of file | ... | ... |
views/user_search/search_filter.html.erb
... | ... | @@ -1,35 +0,0 @@ |
1 | -<form action="/search/people" name="user_filter" method="POST" class="search_form"> | |
2 | - <div id="user_filter_content"> | |
3 | - <div class="user_filter_options"> | |
4 | - | |
5 | - <table class="search-table"> | |
6 | - <tr> | |
7 | - <td> <%= label_tag :name, _("Name") %> </td> | |
8 | - <td> <%= text_field_tag :name %> </td> | |
9 | - </tr> | |
10 | - <tr> | |
11 | - <td> <%= label_tag :state, _("State") %> </td> | |
12 | - <td> <%= text_field_tag :state %> </td> | |
13 | - </tr> | |
14 | - <tr> | |
15 | - <td> <%= label_tag :city, _("City") %> </td> | |
16 | - <td> <%= text_field_tag :city %> </td> | |
17 | - </tr> | |
18 | - <tr> | |
19 | - <td> <%= label_tag :email, _("Email") %> </td> | |
20 | - <td> <%= text_field_tag :email %> </td> | |
21 | - </tr> | |
22 | - <tr> | |
23 | - <td> </td> | |
24 | - <td> <%= submit_button(:search, _('Search')) %> </td> | |
25 | - </tr> | |
26 | - </table> | |
27 | - </div> | |
28 | - | |
29 | - </br> | |
30 | - | |
31 | - <div class="user_filter_actions"> | |
32 | - | |
33 | - </div> | |
34 | - </div> | |
35 | -</form> | |
36 | 0 | \ No newline at end of file |