Commit 5c62082bf4c4dbc2a955c8af6a9942b4c46303ad
1 parent
f0dab8ba
Exists in
master
and in
79 other branches
Change mpog_plugin to its own repository
Signed-off-by: Alex de Souza <campelo.al1@gmail.com> Signed-off-by: Arthur Del Esposte <arthurmde@yahoo.com.br> Signed-off-by: Daniel Bucher <daniel.bucher88@gmail.com> Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Gustavo Jaruga <darksshades@hotmail.com> Signed-off-by: Luciano Prestes <lucianopcbr@gmail.com> Signed-off-by: Matheus Faria <matheus.sousa.faria@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
108 changed files
with
6300 additions
and
0 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 108 files displayed.
... | ... | @@ -0,0 +1,67 @@ |
1 | +README - MPOG Software Público Plugin | |
2 | +================================ | |
3 | + | |
4 | +MPOG Software Público Plugin is a plugin that includes features to Novo Portal do Software Público Brasileiro (SPB). | |
5 | + | |
6 | +More information about SPB: https://www.participa.br/softwarepublico | |
7 | + | |
8 | +INSTALL | |
9 | +======= | |
10 | + | |
11 | +Enable Plugin | |
12 | +------------- | |
13 | + | |
14 | +Also, you need to enable MPOG Software Plugin on your Noosfero: | |
15 | + | |
16 | +cd <your_noosfero_dir> | |
17 | +./script/noosfero-plugins enable mpog_software | |
18 | + | |
19 | +Activate Plugin | |
20 | +--------------- | |
21 | + | |
22 | +As a Noosfero administrator user, go to administrator panel: | |
23 | + | |
24 | +- Click on "Enable/disable plugins" option | |
25 | +- Click on "MPOG Software Plugin" check-box | |
26 | + | |
27 | +Schedule Institutions Update | |
28 | +---------------------------- | |
29 | + | |
30 | +./plugins/mpog_software/script/schedule_institution_update.sh | |
31 | + | |
32 | + | |
33 | +Running MPOG Software tests | |
34 | +-------------------- | |
35 | +$ ruby plugins/mpog_software/test/unit/name_of_file.rb | |
36 | +$ cucumber plugins/mpog_software/features/ | |
37 | + | |
38 | +Get Involved | |
39 | +============ | |
40 | + | |
41 | +If you find any bug and/or want to collaborate, please send an e-mail to arthurmde@gmail.com | |
42 | + | |
43 | +LICENSE | |
44 | +======= | |
45 | + | |
46 | +Copyright (c) The Author developers. | |
47 | + | |
48 | +See Noosfero license. | |
49 | + | |
50 | + | |
51 | +AUTHORS | |
52 | +======= | |
53 | + | |
54 | +Alex Campelo (campelo.al1 at gmail.com) | |
55 | +Arthur de Moura Del Esposte (arthurmde at gmail.com) | |
56 | +Daniel Bucher (daniel.bucher88 at gmail.com) | |
57 | +David Carlos (ddavidcarlos1392 at gmail.com) | |
58 | +Fabio Teixeira (fabio1079 at gmail.com) | |
59 | +Gustavo Jaruga (darksshades at gmail.com) | |
60 | +Luciano Prestes (lucianopcbr at gmail.com) | |
61 | +Matheus Faria (matheus.sousa.faria at gmail.com) | |
62 | + | |
63 | + | |
64 | +ACKNOWLEDGMENTS | |
65 | +=============== | |
66 | + | |
67 | +The authors have been supported by MPOG and UnB | ... | ... |
... | ... | @@ -0,0 +1,9 @@ |
1 | +web_service: | |
2 | + base_url: http://estruturaorganizacional.dados.gov.br/doc/estrutura-organizacional/resumida.json | |
3 | + sphere_codes: | |
4 | + federal: 1 | |
5 | + power_codes: | |
6 | + executive: 1 | |
7 | + legislative: 2 | |
8 | + judiciary: 3 | |
9 | + additional_params: retornarOrgaoEntidadeVinculados=NAO | ... | ... |
... | ... | @@ -0,0 +1,205 @@ |
1 | +require 'csv' | |
2 | +class MpogSoftwarePluginController < ApplicationController | |
3 | + | |
4 | + def archive_software | |
5 | + per_page = 10 | |
6 | + scope = SoftwareInfo | |
7 | + @q = params[:q] | |
8 | + @collection = find_by_contents(:community, scope, @q, {:per_page => per_page, :page => params[:npage]})[:results] | |
9 | + end | |
10 | + | |
11 | + def deactivate | |
12 | + community = SoftwareInfo.find(params[:id]).community_id | |
13 | + Community.find(community).deactivate | |
14 | + if params[:from_profile] | |
15 | + redirect_to :back | |
16 | + else | |
17 | + redirect_to :action => 'archive_software' | |
18 | + end | |
19 | + end | |
20 | + | |
21 | + def activate | |
22 | + community = SoftwareInfo.find(params[:id]).community_id | |
23 | + Community.find(community).activate | |
24 | + redirect_to :action => 'archive_software' | |
25 | + end | |
26 | + | |
27 | + def check_reactivate_account | |
28 | + if request.xhr? and params[:email] | |
29 | + result = "" | |
30 | + user = User.where(:email => params[:email]) | |
31 | + | |
32 | + if user.length == 1 | |
33 | + result = "<span id='forgot_link'><a href='/account/forgot_password'> Reactive account</a></span>" unless user[0].person.visible | |
34 | + end | |
35 | + | |
36 | + render :json => result.to_json | |
37 | + end | |
38 | + end | |
39 | + | |
40 | + def get_institutions | |
41 | + list = [] | |
42 | + | |
43 | + if request.xhr? and params[:query] | |
44 | + list = Institution.search_institution(params[:query]).map{ |institution| | |
45 | + {:value=>institution.name, :id=>institution.id} | |
46 | + } | |
47 | + end | |
48 | + | |
49 | + render :json => list.to_json | |
50 | + end | |
51 | + | |
52 | + def hide_registration_incomplete_percentage | |
53 | + response = false | |
54 | + | |
55 | + if request.xhr? and params[:hide] | |
56 | + session[:hide_incomplete_percentage] = true | |
57 | + response = session[:hide_incomplete_percentage] | |
58 | + end | |
59 | + | |
60 | + render :json=>response.to_json | |
61 | + end | |
62 | + | |
63 | + def create_institution | |
64 | + if request.xhr? | |
65 | + render :layout=>false | |
66 | + else | |
67 | + redirect_to "/" | |
68 | + end | |
69 | + end | |
70 | + | |
71 | + def new_institution | |
72 | + if request.xhr? and !params[:community].nil? and !params[:institution].nil? and !params[:recaptcha_response_field].nil? | |
73 | + response_message = {} | |
74 | + | |
75 | + institution = create_institution | |
76 | + | |
77 | + response_message = if verify_recaptcha(:model=> institution, :message => _('Please type the word correctly')) | |
78 | + if institution.errors.full_messages.empty? and institution.valid? and institution.save | |
79 | + {:success => true, :message => _("Institution successful created!"), :institution_data=>{:name=>institution.name, :id=>institution.id}} | |
80 | + else | |
81 | + {:success => false, :message => _("Institution could not be created!"), :errors => institution.errors.full_messages} | |
82 | + end | |
83 | + else | |
84 | + {:success => false, :message=>_('Please type the image text correctly'), :errors=>[]} | |
85 | + end | |
86 | + | |
87 | + render :json => response_message.to_json | |
88 | + else | |
89 | + redirect_to "/" | |
90 | + end | |
91 | + end | |
92 | + | |
93 | + def institution_already_exists | |
94 | + if request.xhr? and !params[:name].nil? | |
95 | + already_exists = !Community.where(:name=>params[:name]).empty? | |
96 | + | |
97 | + render :json=>already_exists.to_json | |
98 | + else | |
99 | + redirect_to "/" | |
100 | + end | |
101 | + end | |
102 | + | |
103 | + def download | |
104 | + respond_to do |format| | |
105 | + format.html | |
106 | + format.xml do | |
107 | + softwares = software_list_to_correct_format(SoftwareInfo.all) | |
108 | + send_data softwares.to_xml( | |
109 | + :skip_types => true, | |
110 | + :only => %w[name acronym demonstration_url e_arq e_mag e_ping features icp_brasil objectives operating_platform languages_list database_list]), | |
111 | + :type => 'text/xml', | |
112 | + :disposition => "attachment; filename=softwares.xml" | |
113 | + end | |
114 | + | |
115 | + format.csv do | |
116 | + softwares = software_list_to_correct_format(SoftwareInfo.all) | |
117 | + csv_content = "" | |
118 | + softwares.each { |s| | |
119 | + csv_content << "name;acronym;demonstration_url;e_arq;e_mag;e_ping;features;icp_brasil;objectives;operating_platform\n" | |
120 | + csv_content << CSV.generate_line([s['name'], s['acronym'], s['demonstration_url'], s['e_arq'], s['e_mag'], s['e_ping'], s['features'], s['icp_brasil'], s['objectives'], s['operating_platform']], {:col_sep => ';'}) | |
121 | + | |
122 | + csv_content << "\nlanguage_name;language_version;language_operating_system\n" | |
123 | + s[:languages_list].each { |sl| | |
124 | + csv_content << CSV.generate_line([sl[:name], sl[:version], sl[:operating_system]], {:col_sep => ';'}) | |
125 | + } | |
126 | + | |
127 | + csv_content << "\ndatabase_name;database_version;database_operating_system\n" | |
128 | + s[:database_list].each { |dl| | |
129 | + csv_content << CSV.generate_line([dl[:name], dl[:version], dl[:operating_system]], {:col_sep => ';'}) | |
130 | + } | |
131 | + | |
132 | + csv_content << "\n\n" | |
133 | + } | |
134 | + if csv_content.blank? | |
135 | + csv_content = "name;acronym;demonstration_url;e_arq;e_mag;e_ping;features;icp_brasil;objectives;operating_platform\n" | |
136 | + end | |
137 | + | |
138 | + render :text => csv_content, :content_type => 'text/csv', :layout => false | |
139 | + end | |
140 | + end | |
141 | + end | |
142 | + | |
143 | + | |
144 | + protected | |
145 | + | |
146 | + def create_institution | |
147 | + community = Community.new(params[:community]) | |
148 | + community.environment = environment | |
149 | + | |
150 | + institution = if params[:institution][:type] == "PublicInstitution" | |
151 | + PublicInstitution::new params[:institution] | |
152 | + else | |
153 | + PrivateInstitution::new params[:institution] | |
154 | + end | |
155 | + | |
156 | + institution.name = community[:name] | |
157 | + institution.community = community | |
158 | + | |
159 | + if institution.type == "PublicInstitution" | |
160 | + begin | |
161 | + govPower = GovernmentalPower.find params[:governmental][:power] | |
162 | + govSphere = GovernmentalSphere.find params[:governmental][:sphere] | |
163 | + | |
164 | + institution.governmental_power = govPower | |
165 | + institution.governmental_sphere = govSphere | |
166 | + rescue | |
167 | + institution.errors.add(:governmental_fields, _("Could not find Governmental Power or Governmental Sphere")) | |
168 | + end | |
169 | + end | |
170 | + | |
171 | + if institution.cnpj.nil? or institution.cnpj.blank? | |
172 | + institution.errors.add(:cnpj, _("can't be blank")) | |
173 | + end | |
174 | + | |
175 | + institution | |
176 | + end | |
177 | + | |
178 | + def software_list_to_correct_format software_list=[] | |
179 | + if !software_list.empty? | |
180 | + software_list.each do |software| | |
181 | + software[:name] = Community.find(software.community_id).name | |
182 | + software[:languages_list] = [] | |
183 | + | |
184 | + software.software_languages.each do |sl| | |
185 | + software[:languages_list] << {} | |
186 | + index = software[:languages_list].count - 1 | |
187 | + software[:languages_list][index][:name] = ProgrammingLanguage.find(sl.programming_language_id).name | |
188 | + software[:languages_list][index][:version] = sl.version | |
189 | + software[:languages_list][index][:operating_system] = sl.operating_system | |
190 | + end | |
191 | + | |
192 | + software[:database_list] = [] | |
193 | + software.software_databases.each do |dd| | |
194 | + software[:database_list] << {} | |
195 | + index = software[:database_list].count - 1 | |
196 | + software[:database_list][index][:name] = DatabaseDescription.find(dd.database_description_id).name | |
197 | + software[:database_list][index][:version] = dd.version | |
198 | + software[:database_list][index][:operating_system] = dd.operating_system | |
199 | + end | |
200 | + end | |
201 | + end | |
202 | + software_list | |
203 | + end | |
204 | + | |
205 | +end | ... | ... |
controllers/mpog_software_plugin_myprofile_controller.rb
0 → 100644
... | ... | @@ -0,0 +1,85 @@ |
1 | +class MpogSoftwarePluginMyprofileController < MyProfileController | |
2 | + append_view_path File.join(File.dirname(__FILE__) + '/../views') | |
3 | + | |
4 | + def index | |
5 | + end | |
6 | + | |
7 | + def archive_software | |
8 | + puts "="*80 | |
9 | + nil | |
10 | + end | |
11 | + | |
12 | + def new_software | |
13 | + @errors = [] | |
14 | + @community = Community.new(params[:community]) | |
15 | + @community.environment = environment | |
16 | + @software_info = SoftwareInfo.new(params[:software_info]) | |
17 | + @list_libraries = LibraryHelper.list_libraries(params[:library]) | |
18 | + @list_languages = SoftwareLanguageHelper.list_language(params[:language]) | |
19 | + @list_databases = DatabaseHelper.list_database(params[:database]) | |
20 | + @controlled_vocabulary = ControlledVocabulary::new params[:controlled_vocabulary] | |
21 | + @list_operating_systems = OperatingSystemHelper.list_operating_system(params[:operating_system]) | |
22 | + @license_info = if params[:license_info].nil? | |
23 | + LicenseInfo::new | |
24 | + else | |
25 | + LicenseInfo.find(:first, :conditions=>"id = #{params[:license_info][:version]}") | |
26 | + end | |
27 | + | |
28 | + if not @list_libraries.nil? | |
29 | + @list_libraries.each do |library| | |
30 | + @software_info.libraries << library | |
31 | + end | |
32 | + end | |
33 | + | |
34 | + if not @list_languages.nil? | |
35 | + @list_languages.each do |language| | |
36 | + @software_info.software_languages << language | |
37 | + end | |
38 | + end | |
39 | + | |
40 | + if not @list_databases.nil? | |
41 | + @list_databases.each do |database| | |
42 | + @software_info.software_databases << database | |
43 | + end | |
44 | + end | |
45 | + | |
46 | + if not @list_operating_systems.nil? | |
47 | + @list_operating_systems.each do |operating_system| | |
48 | + @software_info.operating_systems << operating_system | |
49 | + end | |
50 | + end | |
51 | + | |
52 | + valid_community = request.post? && @community.valid? | |
53 | + valid_software_info = request.post? && @software_info.valid? | |
54 | + valid_license = (request.post? && @license_info.valid?) | |
55 | + valid_libraries = @list_libraries.empty? || LibraryHelper.valid_list_libraries?(@list_libraries) | |
56 | + valid_database = DatabaseHelper.valid_list_database?(@list_databases) | |
57 | + valid_language = SoftwareLanguageHelper.valid_list_language?(@list_languages) | |
58 | + valid_operating_system = OperatingSystemHelper.valid_list_operating_system?(@list_operating_systems) | |
59 | + | |
60 | + if valid_software_info && valid_community && valid_libraries && valid_license && valid_language && valid_database && valid_operating_system | |
61 | + @community = Community.create_after_moderation(user, {:environment => environment}.merge(params[:community]), @software_info, @license_info, @controlled_vocabulary) | |
62 | + redirect_to :controller => 'memberships', :action => 'index' | |
63 | + else | |
64 | + @list_libraries.each do |lib| | |
65 | + @errors |= lib.errors.full_messages | |
66 | + end | |
67 | + | |
68 | + @list_languages.each do |lng| | |
69 | + @errors |= lng.errors.full_messages | |
70 | + end | |
71 | + | |
72 | + @list_databases.each do |db| | |
73 | + @errors |= db.errors.full_messages | |
74 | + end | |
75 | + | |
76 | + @list_operating_systems.each do |os| | |
77 | + @errors |= os.errors.full_messages | |
78 | + end | |
79 | + @errors |= @community.errors.full_messages | |
80 | + @errors |= @software_info.errors.full_messages | |
81 | + @errors |= @license_info.errors.full_messages | |
82 | + end | |
83 | + end | |
84 | + | |
85 | +end | ... | ... |
db/migrate/20140523132016_create_controlled_vocabulary_table.rb
0 → 100644
... | ... | @@ -0,0 +1,35 @@ |
1 | +class CreateControlledVocabularyTable < ActiveRecord::Migration | |
2 | + def up | |
3 | + create_table :controlled_vocabulary do |t| | |
4 | + t.references :software_info | |
5 | + t.boolean :administration | |
6 | + t.boolean :agriculture | |
7 | + t.boolean :business_and_services | |
8 | + t.boolean :communication | |
9 | + t.boolean :culture | |
10 | + t.boolean :national_defense | |
11 | + t.boolean :economy_and_finances | |
12 | + t.boolean :education | |
13 | + t.boolean :energy | |
14 | + t.boolean :sports | |
15 | + t.boolean :habitation | |
16 | + t.boolean :industry | |
17 | + t.boolean :environment | |
18 | + t.boolean :research_and_development | |
19 | + t.boolean :social_security | |
20 | + t.boolean :social_protection | |
21 | + t.boolean :international_relations | |
22 | + t.boolean :sanitation | |
23 | + t.boolean :health | |
24 | + t.boolean :security_public_order | |
25 | + t.boolean :work | |
26 | + t.boolean :transportation | |
27 | + t.boolean :urbanism | |
28 | + | |
29 | + end | |
30 | + end | |
31 | + | |
32 | + def down | |
33 | + drop_table :controlled_vocabulary | |
34 | + end | |
35 | +end | ... | ... |
... | ... | @@ -0,0 +1,17 @@ |
1 | +class AddExtraFieldsToUser < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + change_table :users do |t| | |
4 | + t.string :secondary_email | |
5 | + t.references :institution | |
6 | + t.string :role | |
7 | + end | |
8 | + end | |
9 | + | |
10 | + def self.down | |
11 | + change_table :users do |t| | |
12 | + t.remove :secondary_email | |
13 | + t.remove_references :institution | |
14 | + t.remove :role | |
15 | + end | |
16 | + end | |
17 | +end | ... | ... |
... | ... | @@ -0,0 +1,13 @@ |
1 | +class CreateLicenseInfosTable < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + create_table :license_infos do |t| | |
4 | + t.string :version | |
5 | + t.string :link | |
6 | + end | |
7 | + LicenseInfo.create(:version=>"CC-GPL-V2", :link=>"http://creativecommons.org/licenses/GPL/2.0/legalcode.pt") | |
8 | + end | |
9 | + | |
10 | + def self.down | |
11 | + drop_table :license_infos | |
12 | + end | |
13 | +end | ... | ... |
db/migrate/20140528193905_create_software_infos_table.rb
0 → 100644
... | ... | @@ -0,0 +1,23 @@ |
1 | +class CreateSoftwareInfosTable < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + create_table :software_infos do |t| | |
4 | + t.references :license_info | |
5 | + t.references :community | |
6 | + t.boolean :e_mag, :default => false | |
7 | + t.boolean :icp_brasil,:default => false | |
8 | + t.boolean :intern, :default => false | |
9 | + t.boolean :e_ping, :default => false | |
10 | + t.boolean :e_arq, :default => false | |
11 | + t.string :name, :default => ' ' | |
12 | + t.string :operating_platform | |
13 | + t.string :demonstration_url | |
14 | + t.string :acronym | |
15 | + t.text :objectives | |
16 | + t.text :features | |
17 | + end | |
18 | + end | |
19 | + | |
20 | + def self.down | |
21 | + drop_table :software_infos | |
22 | + end | |
23 | +end | ... | ... |
... | ... | @@ -0,0 +1,14 @@ |
1 | +class CreateLibrariesTable < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + create_table :libraries do |t| | |
4 | + t.string :name | |
5 | + t.string :version | |
6 | + t.string :license | |
7 | + t.references :software_info | |
8 | + end | |
9 | + end | |
10 | + | |
11 | + def self.down | |
12 | + drop_table :libraries | |
13 | + end | |
14 | +end | ... | ... |
db/migrate/20140528193956_create_programming_languages_table.rb
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +class CreateProgrammingLanguagesTable < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + create_table :programming_languages do |t| | |
4 | + t.string :name | |
5 | + end | |
6 | + | |
7 | + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/languages.txt", ProgrammingLanguage) | |
8 | + end | |
9 | + | |
10 | + def self.down | |
11 | + drop_table :programming_languages | |
12 | + end | |
13 | +end | ... | ... |
db/migrate/20140528194044_create_database_descriptions_table.rb
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +class CreateDatabaseDescriptionsTable < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + create_table :database_descriptions do |t| | |
4 | + t.string :name | |
5 | + end | |
6 | + | |
7 | + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/databases.txt", DatabaseDescription) | |
8 | + end | |
9 | + | |
10 | + def self.down | |
11 | + drop_table :database_descriptions | |
12 | + end | |
13 | +end | ... | ... |
db/migrate/20140528194129_create_software_databases_table.rb
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +class CreateSoftwareDatabasesTable < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + create_table :software_databases do |t| | |
4 | + t.string :version | |
5 | + t.string :operating_system | |
6 | + t.references :database_description | |
7 | + t.references :software_info | |
8 | + end | |
9 | + end | |
10 | + | |
11 | + def self.down | |
12 | + drop_table :software_databases | |
13 | + end | |
14 | +end | ... | ... |
db/migrate/20140528211914_create_software_languages_table.rb
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +class CreateSoftwareLanguagesTable < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + create_table :software_languages do |t| | |
4 | + t.references :software_info | |
5 | + t.references :programming_language | |
6 | + t.string :version | |
7 | + t.string :operating_system | |
8 | + end | |
9 | + end | |
10 | + | |
11 | + def self.down | |
12 | + drop_table :software_languages | |
13 | + end | |
14 | +end | ... | ... |
... | ... | @@ -0,0 +1,27 @@ |
1 | +class AddNewFieldsInstitution < ActiveRecord::Migration | |
2 | + def up | |
3 | + add_column :institutions, :acronym, :string | |
4 | + add_column :institutions, :unit_code, :integer | |
5 | + add_column :institutions, :parent_code, :integer | |
6 | + add_column :institutions, :unit_type, :string | |
7 | + add_column :institutions, :juridical_nature, :string | |
8 | + add_column :institutions, :sub_juridical_nature, :string | |
9 | + add_column :institutions, :normalization_level, :string | |
10 | + add_column :institutions, :version, :string | |
11 | + add_column :institutions, :cnpj, :string | |
12 | + add_column :institutions, :type, :string | |
13 | + end | |
14 | + | |
15 | + def down | |
16 | + remove_column :institutions, :acronym | |
17 | + remove_column :institutions, :unit_code | |
18 | + remove_column :institutions, :parent_code | |
19 | + remove_column :institutions, :unit_type | |
20 | + remove_column :institutions, :juridical_nature | |
21 | + remove_column :institutions, :sub_juridical_nature | |
22 | + remove_column :institutions, :normalization_level | |
23 | + remove_column :institutions, :version | |
24 | + remove_column :institutions, :cnpj | |
25 | + remove_column :institutions, :type | |
26 | + end | |
27 | +end | ... | ... |
db/migrate/20140617132133_create_governmental_spheres.rb
0 → 100644
... | ... | @@ -0,0 +1,11 @@ |
1 | +class CreateGovernmentalSpheres < ActiveRecord::Migration | |
2 | + def change | |
3 | + create_table :governmental_spheres do |t| | |
4 | + t.string :name | |
5 | + | |
6 | + t.timestamps | |
7 | + end | |
8 | + | |
9 | + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/governmental_sphere.txt", GovernmentalSphere) | |
10 | + end | |
11 | +end | ... | ... |
... | ... | @@ -0,0 +1,11 @@ |
1 | +class CreateGovernmentalPowers < ActiveRecord::Migration | |
2 | + def change | |
3 | + create_table :governmental_powers do |t| | |
4 | + t.string :name | |
5 | + | |
6 | + t.timestamps | |
7 | + end | |
8 | + | |
9 | + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/governmental_powers.txt", GovernmentalPower) | |
10 | + end | |
11 | +end | ... | ... |
db/migrate/20140617134556_add_references_to_institution.rb
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +class AddReferencesToInstitution < ActiveRecord::Migration | |
2 | + def up | |
3 | + change_table :institutions do |t| | |
4 | + t.references :governmental_power | |
5 | + t.references :governmental_sphere | |
6 | + end | |
7 | + end | |
8 | + | |
9 | + def down | |
10 | + change_table :institutions do |t| | |
11 | + t.remove_references :governmental_power | |
12 | + t.remove_references :governmental_sphere | |
13 | + end | |
14 | + end | |
15 | +end | ... | ... |
db/migrate/20140630183326_add_relation_between_community_and_institution.rb
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +class AddRelationBetweenCommunityAndInstitution < ActiveRecord::Migration | |
2 | + def up | |
3 | + change_table :institutions do |t| | |
4 | + t.references :community | |
5 | + end | |
6 | + end | |
7 | + | |
8 | + def down | |
9 | + change_table :institutions do |t| | |
10 | + t.remove_references :community | |
11 | + end | |
12 | + end | |
13 | +end | ... | ... |
db/migrate/20140710185444_create_operating_system_table.rb
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +class CreateOperatingSystemTable < ActiveRecord::Migration | |
2 | + def up | |
3 | + create_table :operating_systems do |t| | |
4 | + t.string :name | |
5 | + t.string :version | |
6 | + t.references :software_info | |
7 | + end | |
8 | + end | |
9 | + | |
10 | + def down | |
11 | + drop_table :operating_systems | |
12 | + end | |
13 | +end | ... | ... |
db/migrate/20140711144012_remove_name_from_software_info.rb
0 → 100644
db/migrate/20140714133901_create_operating_name_table.rb
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +class CreateOperatingNameTable < ActiveRecord::Migration | |
2 | + def up | |
3 | + create_table :operating_system_names do |t| | |
4 | + t.string :name | |
5 | + end | |
6 | + | |
7 | + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/operating_systems.txt", OperatingSystemName) | |
8 | + end | |
9 | + | |
10 | + def down | |
11 | + drop_table :operating_system_names | |
12 | + end | |
13 | +end | ... | ... |
db/migrate/20140714135007_change_operating_systems_table.rb
0 → 100644
... | ... | @@ -0,0 +1,16 @@ |
1 | +class ChangeOperatingSystemsTable < ActiveRecord::Migration | |
2 | + def up | |
3 | + change_table :operating_systems do |t| | |
4 | + t.remove :name | |
5 | + t.references :operating_system_name | |
6 | + end | |
7 | + | |
8 | + end | |
9 | + | |
10 | + def down | |
11 | + change_table :operating_systems do |t| | |
12 | + t.string :name | |
13 | + t.remove :operating_system_name_id | |
14 | + end | |
15 | + end | |
16 | +end | ... | ... |
... | ... | @@ -0,0 +1,21 @@ |
1 | +Feature: Institution Field | |
2 | + As a user | |
3 | + I want to sign up resgistring my institution | |
4 | + So others users can use it | |
5 | + | |
6 | + Background: | |
7 | + Given "MpogSoftwarePlugin" plugin is enabled | |
8 | + And I am logged in as admin | |
9 | + And I go to /admin/plugins | |
10 | + And I check "MpogSoftwarePlugin" | |
11 | + And I press "Save changes" | |
12 | + And I go to /account/logout | |
13 | + | |
14 | + @selenium | |
15 | + Scenario: Show new institution field when another institution is selected | |
16 | + Given I go to /account/signup | |
17 | + When I select "Other" from "Institution" | |
18 | + And I should see "New Institution" | |
19 | + And I fill in "institution_name" with "Test Institution" | |
20 | + And I fill in "profile_data_name" with " " | |
21 | + Then I should see "Test Institution" within "#user_institution_id" | ... | ... |
... | ... | @@ -0,0 +1,44 @@ |
1 | +Feature: deactivate user | |
2 | + As a user | |
3 | + I want to deactivate my account | |
4 | + So I can reactivate my account later | |
5 | + | |
6 | + Background: | |
7 | + Given "MpogSoftwarePlugin" plugin is enabled | |
8 | + And I am logged in as admin | |
9 | + And I go to /admin/plugins | |
10 | + And I check "MpogSoftwarePlugin" | |
11 | + And I press "Save changes" | |
12 | + And I go to /account/logout | |
13 | + And the following users | |
14 | + | login | name | email | | |
15 | + | joaosilva | Joao Silva | joaosilva@example.com | | |
16 | + And I am logged in as "joaosilva" | |
17 | + | |
18 | +@selenium | |
19 | + Scenario: successfull deactivation | |
20 | + Given I go to joaosilva's control panel | |
21 | + And I follow "Edit Profile" | |
22 | + And I follow "Delete profile" | |
23 | + And I follow "Yes, I am sure" | |
24 | + Then I am not logged in | |
25 | + When I go to /profile/joaosilva | |
26 | + Then I should see "This profile is inaccessible." | |
27 | + | |
28 | +@selenium | |
29 | + Scenario: successfull reactivation of account | |
30 | + Given I go to joaosilva's control panel | |
31 | + And I follow "Edit Profile" | |
32 | + And I follow "Delete profile" | |
33 | + And I follow "Yes, I am sure" | |
34 | + And I go to the homepage | |
35 | + When I follow "Login" | |
36 | + And I follow "New user" | |
37 | + And I fill in the following within ".no-boxes": | |
38 | + | e-Mail | joaosilva@example.com | | |
39 | + | Full name | 123 | | |
40 | + And I follow "Reactive account" | |
41 | + And I fill in the following within ".no-boxes": | |
42 | + | Username or Email | joaosilva@example.com | | |
43 | + And I press "Send instructions" | |
44 | + Then I should see "An e-mail was just sent to your e-mail address" | ... | ... |
... | ... | @@ -0,0 +1,59 @@ |
1 | +Feature: | |
2 | + As a administrator of a software | |
3 | + I want to manage it | |
4 | + | |
5 | + Background: | |
6 | + Given "MpogSoftwarePlugin" plugin is enabled | |
7 | + And I am logged in as admin | |
8 | + And I go to /admin/plugins | |
9 | + And I check "MpogSoftwarePlugin" | |
10 | + And I press "Save changes" | |
11 | + And SoftwareInfo has initial default values on database | |
12 | + | |
13 | + @selenium | |
14 | + Scenario: Deactivate a software | |
15 | + Given the following software language | |
16 | + | programing_language | version | operating_system | | |
17 | + | Python | 1.0 | Linux | | |
18 | + And the following software databases | |
19 | + | database_name | version | operating_system | | |
20 | + | PostgreSQL | 1.0 | Linux | | |
21 | + And the following softwares | |
22 | + | name | acronym | operating_platform | software_language | software_database | | |
23 | + | teste | ts | I dont know | Python | PostgreSQL | | |
24 | + And I go to /plugin/mpog_software/archive_software | |
25 | + And I should see "teste" | |
26 | + And I follow "Deactivate software" | |
27 | + And I confirm the "Do you want to deactivate this software?" dialog | |
28 | + And I go to /search/communities | |
29 | + And I fill in "search-input" with "teste" | |
30 | + And I press "Search" | |
31 | + Then I should not see "teste" within "search-profile-item" | |
32 | + | |
33 | + @selenium | |
34 | + Scenario: Activate a deactivated software | |
35 | + Given the following software language | |
36 | + | programing_language | version | operating_system | | |
37 | + | Python | 1.0 | Linux | | |
38 | + And the following software databases | |
39 | + | database_name | version | operating_system | | |
40 | + | PostgreSQL | 1.0 | Linux | | |
41 | + And the following softwares | |
42 | + | name | acronym | operating_platform | software_language | software_database | | |
43 | + | teste | ts | I dont know | Python | PostgreSQL | | |
44 | + And I go to /plugin/mpog_software/archive_software | |
45 | + And I should see "teste" | |
46 | + And I follow "Deactivate software" | |
47 | + And I confirm the "Do you want to deactivate this software?" dialog | |
48 | + And I go to /search/communities | |
49 | + And I fill in "search-input" with "teste" | |
50 | + And I press "Search" | |
51 | + And I should not see "Teste" within "search-profile-item" | |
52 | + And I go to /plugin/mpog_software/archive_software | |
53 | + And I should see "teste" | |
54 | + And I follow "Activate Software" | |
55 | + And I confirm the "Do you want to activate this software?" dialog | |
56 | + And I follow "Communities" | |
57 | + And I fill in "search-input" with "teste" | |
58 | + And I press "Search" | |
59 | + Then I should see "teste" within "search-profile-item" | ... | ... |
... | ... | @@ -0,0 +1,62 @@ |
1 | +Feature: Mpog Search People | |
2 | + As a user | |
3 | + I want to search for people with one or more filter options | |
4 | + So I can find another user | |
5 | + | |
6 | + Background: | |
7 | + Given "MpogSoftwarePlugin" plugin is enabled | |
8 | + And I am logged in as admin | |
9 | + And I go to /admin/plugins | |
10 | + And I check "MpogSoftwarePlugin" | |
11 | + And I press "Save changes" | |
12 | + And I go to /account/logout | |
13 | + And the following users | |
14 | + | login | name | state | city | email | | |
15 | + | josecunha | Jose Cunha | DF | Gama | jose.cunha@gmail.com | | |
16 | + | cunhajose | Cunha Jose | SP | Guarulhos | cunha.jose@gmail.com | | |
17 | + | joaoperera | Joao Perera | NY | New York | joao.perera@gmail.com | | |
18 | + | mariaperera | Maria Perera | NY | New York | maria.perera@gmail.com | | |
19 | + | |
20 | + Scenario: Search a person with name field | |
21 | + Given I go to /search/people | |
22 | + And I fill in "name" with "jo" | |
23 | + And I press "Search" | |
24 | + And I should see "Jose Cunha" | |
25 | + Then I should see "Joao Perera" | |
26 | + | |
27 | + Scenario: Search a person with a state field | |
28 | + Given I go to /search/people | |
29 | + And I fill in "state" with "DF" | |
30 | + And I press "Search" | |
31 | + Then I should see "Jose Cunha" | |
32 | + | |
33 | + Scenario: Search a person with a city field | |
34 | + Given I go to /search/people | |
35 | + And I fill in "city" with "Guarulhos" | |
36 | + And I press "Search" | |
37 | + Then I should see "Cunha Jose" | |
38 | + | |
39 | + Scenario: Search a person with a email field | |
40 | + Given I go to /search/people | |
41 | + And I fill in "email" with "jo" | |
42 | + And I press "Search" | |
43 | + And I should see "Jose Cunha" | |
44 | + And I should see "Cunha Jose" | |
45 | + Then I should see "Joao Perera" | |
46 | + | |
47 | + Scenario: Search a person with name and state fields | |
48 | + Given I go to /search/people | |
49 | + And I fill in "name" with "perera" | |
50 | + And I fill in "state" with "NY" | |
51 | + And I press "Search" | |
52 | + And I should see "Maria Perera" | |
53 | + Then I should see "Joao Perera" | |
54 | + | |
55 | + Scenario: Search a person with all fields | |
56 | + Given I go to /search/people | |
57 | + And I fill in "name" with "perera" | |
58 | + And I fill in "state" with "NY" | |
59 | + And I fill in "city" with "New" | |
60 | + And I fill in "email" with "joao" | |
61 | + And I press "Search" | |
62 | + Then I should see "Joao Perera" | |
0 | 63 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,435 @@ |
1 | +Feature: | |
2 | + As a user | |
3 | + I want to create a new software | |
4 | + | |
5 | + Background: | |
6 | + Given "MpogSoftwarePlugin" plugin is enabled | |
7 | + And SoftwareInfo has initial default values on database | |
8 | + And I am logged in as admin | |
9 | + And I go to /admin/plugins | |
10 | + And I check "MpogSoftwarePlugin" | |
11 | + And I press "Save changes" | |
12 | + | |
13 | + @selenium | |
14 | + Scenario: Do not show error message if all required fields are correctly filled | |
15 | + Given I go to admin_user's control panel | |
16 | + And I follow "Manage my groups" | |
17 | + And I follow "Create a new software" | |
18 | + And I fill in "community_name" with "test name" | |
19 | + And I fill in "language__version" with "2.0.0" | |
20 | + And I fill in "language__operating_system" with "Linux" | |
21 | + And I fill in "database__version" with "3.0" | |
22 | + And I fill in "database__operating_system" with "GNU" | |
23 | + And I fill in "operating_system__version" with "3.0" | |
24 | + And I fill in "software_info_operating_platform" with "test operating platform" | |
25 | + And fill in "software_info_acronym" with "SFTW" | |
26 | + And I press "Create" | |
27 | + Then I should see "Manage my groups" | |
28 | + | |
29 | + Scenario: Show operating_platform errors if this field is blank | |
30 | + Given I go to admin_user's control panel | |
31 | + And I follow "Manage my groups" | |
32 | + And I follow "Create a new software" | |
33 | + And fill in "community_name" with "test" | |
34 | + And fill in "language__version" with "2.0.0" | |
35 | + And fill in "language__operating_system" with "Linux" | |
36 | + And I fill in "database__version" with "3.0" | |
37 | + And I fill in "database__operating_system" with "GNU" | |
38 | + And fill in "software_info_acronym" with "SFTW" | |
39 | + And I press "Create" | |
40 | + Then I should see "Operating platform can't be blank" | |
41 | + | |
42 | + Scenario: Do not show operating_platform errors if this field is not blank | |
43 | + Given I go to admin_user's control panel | |
44 | + And I follow "Manage my groups" | |
45 | + And I follow "Create a new software" | |
46 | + And fill in "software_info_operating_platform" with "test operating platform" | |
47 | + And fill in "language__version" with "2.0.0" | |
48 | + And fill in "language__operating_system" with "Linux" | |
49 | + And I fill in "database__version" with "3.0" | |
50 | + And I fill in "database__operating_system" with "GNU" | |
51 | + And I press "Create" | |
52 | + Then I should not see "Operating platform can't be blank" | |
53 | + | |
54 | + @selenium | |
55 | + Scenario: Show software_langue errors if this Version is blank | |
56 | + Given I go to admin_user's control panel | |
57 | + And I follow "Manage my groups" | |
58 | + And I follow "Create a new software" | |
59 | + And fill in "community_name" with "test" | |
60 | + And fill in "language__operating_system" with "Linux" | |
61 | + And I fill in "database__version" with "3.0" | |
62 | + And I fill in "database__operating_system" with "GNU" | |
63 | + And I press "Create" | |
64 | + Then I should see "Software languages is invalid" | |
65 | + | |
66 | + Scenario: Show acronym errors if this field is blank | |
67 | + Given I go to admin_user's control panel | |
68 | + And I follow "Manage my groups" | |
69 | + And I follow "Create a new software" | |
70 | + And fill in "community_name" with "test" | |
71 | + And fill in "language__version" with "2.0.0" | |
72 | + And fill in "language__operating_system" with "Linux" | |
73 | + And I fill in "database__version" with "3.0" | |
74 | + And I fill in "database__operating_system" with "GNU" | |
75 | + And I press "Create" | |
76 | + Then I should see "Acronym can't be blank" | |
77 | + | |
78 | + @selenium | |
79 | + Scenario: Show database_fields errors version is blank | |
80 | + Given I go to admin_user's control panel | |
81 | + And I follow "Manage my groups" | |
82 | + And I follow "Create a new software" | |
83 | + And fill in "community_name" with "test" | |
84 | + And fill in "language__version" with "2.0.0" | |
85 | + And fill in "language__operating_system" with "Linux" | |
86 | + And I fill in "database__operating_system" with "GNU" | |
87 | + And I press "Create" | |
88 | + Then I should see "Software databases is invalid" | |
89 | + | |
90 | + Scenario: Show acronym errors if this field has more than 8 characters | |
91 | + Given I go to admin_user's control panel | |
92 | + And I follow "Manage my groups" | |
93 | + And I follow "Create a new software" | |
94 | + And fill in "community_name" with "test" | |
95 | + And fill in "language__version" with "2.0.0" | |
96 | + And fill in "language__operating_system" with "Linux" | |
97 | + And I fill in "database__operating_system" with "GNU" | |
98 | + And I fill in "database__version" with "3.0" | |
99 | + And I press "Create" | |
100 | + And fill in "software_info_acronym" with "123456789" | |
101 | + And I press "Create" | |
102 | + Then I should see "Acronym can't have more than 8 characteres" | |
103 | + | |
104 | + Scenario: Show operating system errors if this field is not filled | |
105 | + Given I go to admin_user's control panel | |
106 | + And I follow "Manage my groups" | |
107 | + And I follow "Create a new software" | |
108 | + And I press "Create" | |
109 | + Then I should see "Operating system : at least one must be filled" | |
110 | + | |
111 | + @selenium | |
112 | + Scenario: Show operating system errors if this field is not filled | |
113 | + Given I go to admin_user's control panel | |
114 | + And I follow "Manage my groups" | |
115 | + And I follow "Create a new software" | |
116 | + And I fill in "operating_system__version" with "3.0" | |
117 | + And I press "Create" | |
118 | + Then I should not see "Operating system : at least one must be filled" | |
119 | + | |
120 | + Scenario: Show library fields when click in New Library | |
121 | + Given I go to admin_user's control panel | |
122 | + And I follow "Manage my groups" | |
123 | + And I follow "Create a new software" | |
124 | + And I follow "New Library" | |
125 | + Then I should see "Name" | |
126 | + Then I should see "Version" | |
127 | + Then I should see "License" | |
128 | + | |
129 | + @selenium | |
130 | + Scenario: Show SoftwareLangue fields when click in New Language | |
131 | + Given I go to admin_user's control panel | |
132 | + And I follow "Manage my groups" | |
133 | + And I follow "Create a new software" | |
134 | + And I follow "New language" | |
135 | + Then I should see "3" of this selector ".software-language-table" | |
136 | + #3 because one is always hidden | |
137 | + | |
138 | + @selenium | |
139 | + Scenario: Show databasefields when click in New database | |
140 | + Given I go to admin_user's control panel | |
141 | + And I follow "Manage my groups" | |
142 | + And I follow "Create a new software" | |
143 | + And I follow "New Database" | |
144 | + Then I should see "3" of this selector ".database-table" | |
145 | + #3 because one is always hidden | |
146 | + | |
147 | + @selenium | |
148 | + Scenario: Create software with libraries | |
149 | + Given I go to admin_user's control panel | |
150 | + And I follow "Manage my groups" | |
151 | + And I follow "Create a new software" | |
152 | + And I follow "New Library" | |
153 | + And I fill in "community_name" with "test123" | |
154 | + And fill in "software_info_acronym" with "SFTW" | |
155 | + And I fill in "software_info_operating_platform" with "test platform" | |
156 | + And I fill in "library__name" with "test library name" | |
157 | + And I fill in "library__version" with "test library version" | |
158 | + And I fill in "library__license" with "test library license" | |
159 | + And fill in "language__version" with "2.0.0" | |
160 | + And fill in "language__operating_system" with "Linux" | |
161 | + And I fill in "database__version" with "3.0" | |
162 | + And I fill in "database__operating_system" with "GNU" | |
163 | + And I fill in "operating_system__version" with "3.0" | |
164 | + And I press "Create" | |
165 | + And I go to /myprofile/test123/profile_editor/edit | |
166 | + And I should see "Libraries" | |
167 | + And selector ".library-table" should have any "test library name" | |
168 | + And selector ".library-table" should have any "test library version" | |
169 | + Then selector ".library-table" should have any "test library license" | |
170 | + | |
171 | + @selenium | |
172 | + Scenario: Delete software libraries | |
173 | + Given I go to admin_user's control panel | |
174 | + And I follow "Manage my groups" | |
175 | + And I follow "Create a new software" | |
176 | + And I follow "New Library" | |
177 | + And I fill in "community_name" with "test123" | |
178 | + And fill in "software_info_acronym" with "SFTW" | |
179 | + And I fill in "software_info_operating_platform" with "test platform" | |
180 | + And I fill in "library__name" with "test name" | |
181 | + And I fill in "library__version" with "test version" | |
182 | + And I fill in "library__license" with "test license" | |
183 | + And fill in "language__version" with "2.0.0" | |
184 | + And fill in "language__operating_system" with "Linux" | |
185 | + And I fill in "database__version" with "3.0" | |
186 | + And I fill in "database__operating_system" with "GNU" | |
187 | + And I fill in "operating_system__version" with "3.0" | |
188 | + And I press "Create" | |
189 | + And I go to /myprofile/test123/profile_editor/edit | |
190 | + And I should see "Libraries" | |
191 | + And selector ".library-table" should have any "test name" | |
192 | + And selector ".library-table" should have any "test version" | |
193 | + And selector ".library-table" should have any "test license" | |
194 | + And I follow "Delete" | |
195 | + And I press "Save" | |
196 | + And I go to /myprofile/test123/profile_editor/edit | |
197 | + And I should not see "test name" within "#library__name" | |
198 | + And I should not see "test version" within "#library__version" | |
199 | + Then I should not see "test license" within "#library__license" | |
200 | + | |
201 | + @selenium | |
202 | + Scenario: Crete software libraries on software edit | |
203 | + Given I go to admin_user's control panel | |
204 | + And I follow "Manage my groups" | |
205 | + And I follow "Create a new software" | |
206 | + And I fill in "community_name" with "test123" | |
207 | + And fill in "software_info_acronym" with "SFTW" | |
208 | + And I fill in "software_info_operating_platform" with "test platform" | |
209 | + And fill in "language__version" with "2.0.0" | |
210 | + And fill in "language__operating_system" with "Linux" | |
211 | + And I fill in "database__version" with "3.0" | |
212 | + And I fill in "database__operating_system" with "GNU" | |
213 | + And I fill in "operating_system__version" with "3.0" | |
214 | + And I press "Create" | |
215 | + And I go to /myprofile/test123/profile_editor/edit | |
216 | + And I follow "New Library" | |
217 | + And I fill in "library__name" with "test name" | |
218 | + And I fill in "library__version" with "test version" | |
219 | + And I fill in "library__license" with "test license" | |
220 | + And I press "Save" | |
221 | + And I go to /myprofile/test123/profile_editor/edit | |
222 | + And I should see "Libraries" | |
223 | + And selector ".library-table" should have any "test name" | |
224 | + And selector ".library-table" should have any "test version" | |
225 | + Then selector ".library-table" should have any "test license" | |
226 | + | |
227 | + @selenium | |
228 | + Scenario: Edit software libraries on software edit | |
229 | + Given I go to admin_user's control panel | |
230 | + And I follow "Manage my groups" | |
231 | + And I follow "Create a new software" | |
232 | + And I follow "New Library" | |
233 | + And I fill in "community_name" with "test123" | |
234 | + And fill in "software_info_acronym" with "SFTW" | |
235 | + And I fill in "software_info_operating_platform" with "test platform" | |
236 | + And I fill in "library__name" with "test name" | |
237 | + And I fill in "library__version" with "test version" | |
238 | + And I fill in "library__license" with "test license" | |
239 | + And fill in "language__version" with "2.0.0" | |
240 | + And fill in "language__operating_system" with "Linux" | |
241 | + And I fill in "database__version" with "3.0" | |
242 | + And I fill in "database__operating_system" with "GNU" | |
243 | + And I fill in "operating_system__version" with "3.0" | |
244 | + And I press "Create" | |
245 | + And I go to /myprofile/test123/profile_editor/edit | |
246 | + And I should see "Libraries" | |
247 | + And selector ".library-table" should have any "test name" | |
248 | + And selector ".library-table" should have any "test version" | |
249 | + And selector ".library-table" should have any "test license" | |
250 | + And I follow "New Library" | |
251 | + And I fill in "library__name" with "new name" | |
252 | + And I fill in "library__version" with "new version" | |
253 | + And I fill in "library__license" with "new license" | |
254 | + And I press "Save" | |
255 | + And I go to /myprofile/test123/profile_editor/edit | |
256 | + And selector ".library-table" should have any "new name" | |
257 | + And selector ".library-table" should have any "new version" | |
258 | + Then selector ".library-table" should have any "new license" | |
259 | + | |
260 | + @selenium | |
261 | + Scenario: change license field | |
262 | + Given I go to admin_user's control panel | |
263 | + And I follow "Manage my groups" | |
264 | + And I follow "Create a new software" | |
265 | + And I fill in "community_name" with "test123" | |
266 | + And fill in "software_info_acronym" with "SFTW" | |
267 | + And I fill in "software_info_operating_platform" with "test platform" | |
268 | + And I select "GPL-2" from "license_info_version" | |
269 | + And fill in "language__version" with "2.0.0" | |
270 | + And fill in "language__operating_system" with "Linux" | |
271 | + And I fill in "database__version" with "3.0" | |
272 | + And I fill in "database__operating_system" with "GNU" | |
273 | + And I fill in "operating_system__version" with "3.0" | |
274 | + And I press "Create" | |
275 | + And I go to /myprofile/test123/profile_editor/edit | |
276 | + And I select "GPL-3" from "version" | |
277 | + And I press "Save" | |
278 | + And I go to /myprofile/test123/profile_editor/edit | |
279 | + Then I should see "GPL-3" | |
280 | + | |
281 | + @selenium | |
282 | + Scenario: license link appears on the create software page | |
283 | + Given I go to admin_user's control panel | |
284 | + And I follow "Manage my groups" | |
285 | + And I follow "Create a new software" | |
286 | + And I fill in "community_name" with "test123" | |
287 | + And I fill in "software_info_operating_platform" with "test platform" | |
288 | + And I select "GPL-2" from "license_info_version" | |
289 | + Then I should see "www.gpl2.com" within "#version_link" | |
290 | + | |
291 | + @selenium | |
292 | + Scenario: license link changes if the user choose a different license | |
293 | + Given I go to admin_user's control panel | |
294 | + And I follow "Manage my groups" | |
295 | + And I follow "Create a new software" | |
296 | + And I fill in "community_name" with "test123" | |
297 | + And I fill in "software_info_operating_platform" with "test platform" | |
298 | + And I select "GPL-2" from "license_info_version" | |
299 | + And I should see "www.gpl2.com" within "#version_link" | |
300 | + And I select "GPL-3" from "license_info_version" | |
301 | + Then I should see "www.gpl3.com" within "#version_link" | |
302 | + | |
303 | + @selenium | |
304 | + Scenario: Crete software with Language | |
305 | + Given I go to admin_user's control panel | |
306 | + And I follow "Manage my groups" | |
307 | + And I follow "Create a new software" | |
308 | + And I fill in "community_name" with "test123" | |
309 | + And fill in "software_info_acronym" with "SFTW" | |
310 | + And I fill in "software_info_operating_platform" with "test platform" | |
311 | + And fill in "language__version" with "2.0.0" | |
312 | + And fill in "language__operating_system" with "Linux" | |
313 | + And I fill in "database__version" with "3.0" | |
314 | + And I fill in "database__operating_system" with "GNU" | |
315 | + And I fill in "operating_system__version" with "3.0" | |
316 | + And I press "Create" | |
317 | + And I go to /myprofile/test123/profile_editor/edit | |
318 | + And I should see "Programming Languages" | |
319 | + And selector ".software-language-table" should have any "2.0.0" | |
320 | + Then selector ".software-language-table" should have any "Linux" | |
321 | + | |
322 | + @selenium | |
323 | + Scenario: Edit softwareLanguage on profile editor | |
324 | + Given I go to admin_user's control panel | |
325 | + And I follow "Manage my groups" | |
326 | + And I follow "Create a new software" | |
327 | + And I fill in "community_name" with "test123" | |
328 | + And fill in "software_info_acronym" with "SFTW" | |
329 | + And I fill in "software_info_operating_platform" with "test platform" | |
330 | + And fill in "language__version" with "2.0.0" | |
331 | + And fill in "language__operating_system" with "Linux" | |
332 | + And I fill in "database__version" with "3.0" | |
333 | + And I fill in "database__operating_system" with "GNU" | |
334 | + And I fill in "operating_system__version" with "3.0" | |
335 | + And I press "Create" | |
336 | + And I go to /myprofile/test123/profile_editor/edit | |
337 | + And I should see "Programming Languages" | |
338 | + And selector ".software-language-table" should have any "2.0.0" | |
339 | + And selector ".software-language-table" should have any "Linux" | |
340 | + And I select "Python" from "language__programming_language_id" | |
341 | + And fill in "language__version" with "3.2" | |
342 | + And fill in "language__operating_system" with "GNU" | |
343 | + And I press "Save" | |
344 | + And I go to /myprofile/test123/profile_editor/edit | |
345 | + And selector ".software-language-table" should have any "Python" | |
346 | + And selector ".software-language-table" should have any "3.2" | |
347 | + Then selector ".software-language-table" should have any "GNU" | |
348 | + | |
349 | + @selenium | |
350 | + Scenario: Adding new softwareLanguage on profile editor | |
351 | + Given I go to admin_user's control panel | |
352 | + And I follow "Manage my groups" | |
353 | + And I follow "Create a new software" | |
354 | + And I fill in "community_name" with "test123" | |
355 | + And fill in "software_info_acronym" with "SFTW" | |
356 | + And I fill in "software_info_operating_platform" with "test platform" | |
357 | + And fill in "language__version" with "2.0.0" | |
358 | + And fill in "language__operating_system" with "Linux" | |
359 | + And I fill in "database__version" with "3.0" | |
360 | + And I fill in "database__operating_system" with "GNU" | |
361 | + And I fill in "operating_system__version" with "3.0" | |
362 | + And I press "Create" | |
363 | + And I go to /myprofile/test123/profile_editor/edit | |
364 | + And I should see "Programming Languages" | |
365 | + And selector ".software-language-table" should have any "2.0.0" | |
366 | + And selector ".software-language-table" should have any "Linux" | |
367 | + And I follow "New language" | |
368 | + And I click on the first button with class ".delete-dynamic-table" | |
369 | + And I click on table number "2" selector ".software-language-table" and select the value "Python" | |
370 | + And I fill with "4.3" in field with name "language[][version]" of table number "2" with class ".software-language-table" | |
371 | + And I fill with "Windows" in field with name "language[][operating_system]" of table number "2" with class ".software-language-table" | |
372 | + And I press "Save" | |
373 | + And I go to /myprofile/test123/profile_editor/edit | |
374 | + And selector ".software-language-table" should have any "Python" | |
375 | + And selector ".software-language-table" should have any "4.3" | |
376 | + Then selector ".software-language-table" should have any "Windows" | |
377 | + | |
378 | + @selenium | |
379 | + Scenario: Edit softwareDatabase on profile editor | |
380 | + Given I go to admin_user's control panel | |
381 | + And I follow "Manage my groups" | |
382 | + And I follow "Create a new software" | |
383 | + And I fill in "community_name" with "test123" | |
384 | + And fill in "software_info_acronym" with "SFTW" | |
385 | + And I fill in "software_info_operating_platform" with "test platform" | |
386 | + And fill in "language__version" with "2.0.0" | |
387 | + And fill in "language__operating_system" with "Linux" | |
388 | + And I fill in "database__version" with "3.0" | |
389 | + And I fill in "database__operating_system" with "GNU" | |
390 | + And I fill in "operating_system__version" with "3.0" | |
391 | + And I press "Create" | |
392 | + And I go to /myprofile/test123/profile_editor/edit | |
393 | + And I should see "Databases" | |
394 | + And selector ".database-table" should have any "3.0" | |
395 | + And selector ".database-table" should have any "GNU" | |
396 | + And I select "PostgreSQL" from "database__database_description_id" | |
397 | + And fill in "database__version" with "3.2" | |
398 | + And fill in "database__operating_system" with "Linux" | |
399 | + And I press "Save" | |
400 | + And I go to /myprofile/test123/profile_editor/edit | |
401 | + And selector ".database-table" should have any "PostgreSQL" | |
402 | + And selector ".database-table" should have any "3.2" | |
403 | + Then selector ".database-table" should have any "Linux" | |
404 | + | |
405 | + @selenium | |
406 | + Scenario: Delete softwareDatabase on profile editor | |
407 | + Given I go to admin_user's control panel | |
408 | + And I follow "Manage my groups" | |
409 | + And I follow "Create a new software" | |
410 | + And I fill in "community_name" with "test123" | |
411 | + And fill in "software_info_acronym" with "SFTW" | |
412 | + And I fill in "software_info_operating_platform" with "test platform" | |
413 | + And fill in "language__version" with "2.0.0" | |
414 | + And fill in "language__operating_system" with "Linux" | |
415 | + And I fill in "database__version" with "3.5" | |
416 | + And I fill in "database__operating_system" with "Solaris" | |
417 | + And I fill in "operating_system__version" with "3.0" | |
418 | + And I press "Create" | |
419 | + And I go to /myprofile/test123/profile_editor/edit | |
420 | + And I should see "Databases" | |
421 | + And selector ".database-table" should have any "3.5" | |
422 | + And selector ".database-table" should have any "Solaris" | |
423 | + And I follow "New Database" | |
424 | + And I click on table number "2" selector ".database-table" and select the value "MariaDB" | |
425 | + And I fill with "4.3" in field with name "database[][version]" of table number "2" with class ".database-table" | |
426 | + And I fill with "Windows" in field with name "database[][operating_system]" of table number "2" with class ".database-table" | |
427 | + And I click on the first button with class ".database-table .delete-dynamic-table" | |
428 | + And I press "Save" | |
429 | + And I go to /myprofile/test123/profile_editor/edit | |
430 | + And selector ".database-table" should have any "MariaDB" | |
431 | + And selector ".database-table" should have any "4.3" | |
432 | + And selector ".database-table" should have any "Windows" | |
433 | + And I should not see "4th Dimension" | |
434 | + And I should not see "3.5" | |
435 | + And I should not see "Solaris" | |
0 | 436 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,133 @@ |
1 | +Given /^SoftwareInfo has initial default values on database$/ do | |
2 | + LicenseInfo.create(:version=>"None", :link=>"") | |
3 | + LicenseInfo.create(:version=>"GPL-2", :link =>"www.gpl2.com") | |
4 | + LicenseInfo.create(:version=>"GPL-3", :link =>"www.gpl3.com") | |
5 | + | |
6 | + ProgrammingLanguage.create(:name=>"C") | |
7 | + ProgrammingLanguage.create(:name=>"C++") | |
8 | + ProgrammingLanguage.create(:name=>"Ruby") | |
9 | + ProgrammingLanguage.create(:name=>"Python") | |
10 | + | |
11 | + DatabaseDescription.create(:name => "Oracle") | |
12 | + DatabaseDescription.create(:name => "MySQL") | |
13 | + DatabaseDescription.create(:name => "Apache") | |
14 | + DatabaseDescription.create(:name => "PostgreSQL") | |
15 | + | |
16 | + OperatingSystemName.create(:name=>"Debina") | |
17 | + OperatingSystemName.create(:name=>"Fedora") | |
18 | + OperatingSystemName.create(:name=>"CentOS") | |
19 | +end | |
20 | + | |
21 | +Given /^Institutions has initial default values on database$/ do | |
22 | + GovernmentalPower.create(:name => "Executivo") | |
23 | + GovernmentalPower.create(:name => "Legislativo") | |
24 | + GovernmentalPower.create(:name => "Judiciario") | |
25 | + | |
26 | + GovernmentalSphere.create(:name => "Federal") | |
27 | +end | |
28 | + | |
29 | +Given /^I type in "([^"]*)" into autocomplete list "([^"]*)" and I choose "([^"]*)"$/ do |typed, input_institution, should_select| | |
30 | + page.driver.browser.execute_script %Q{ jQuery('input[data-autocomplete]').trigger("focus") } | |
31 | + fill_in("#{input_institution}",:with => typed) | |
32 | + page.driver.browser.execute_script %Q{ jQuery('input[data-autocomplete]').trigger("keydown") } | |
33 | + sleep 1 | |
34 | + page.driver.browser.execute_script %Q{ jQuery('.ui-menu-item a:contains("#{should_select}")').trigger("mouseenter").trigger("click"); } | |
35 | +end | |
36 | + | |
37 | +Given /^the following public institutions?$/ do |table| | |
38 | + # table is a Cucumber::Ast::Table | |
39 | + table.hashes.each do |item| | |
40 | + governmental_power = GovernmentalPower.where(:name => item[:governmental_power]).first | |
41 | + governmental_sphere = GovernmentalSphere.where(:name => item[:governmental_sphere]).first | |
42 | + institution = PublicInstitution.create!(:name => item[:name], :type => "PublicInstitution", :acronym => item[:acronym], :cnpj => item[:cnpj], :governmental_power => governmental_power, :governmental_sphere => governmental_sphere) | |
43 | + institution.save! | |
44 | + end | |
45 | +end | |
46 | + | |
47 | +Given /^the following software language$/ do |table| | |
48 | + table.hashes.each do |item| | |
49 | + programming_language = ProgrammingLanguage.where(:name=>item[:programing_language]).first | |
50 | + software_language = SoftwareLanguage::new | |
51 | + | |
52 | + software_language.programming_language = programming_language | |
53 | + software_language.version = item[:version] | |
54 | + software_language.operating_system = item[:operating_system] | |
55 | + | |
56 | + software_language.save! | |
57 | + end | |
58 | +end | |
59 | + | |
60 | +Given /^the following software databases$/ do |table| | |
61 | + table.hashes.each do |item| | |
62 | + database_description = DatabaseDescription.where(:name=>item[:database_name]).first | |
63 | + software_database = SoftwareDatabase::new | |
64 | + | |
65 | + software_database.database_description = database_description | |
66 | + software_database.version = item[:version] | |
67 | + software_database.operating_system = item[:operating_system] | |
68 | + | |
69 | + software_database.save! | |
70 | + end | |
71 | +end | |
72 | + | |
73 | +Given /^the following softwares$/ do |table| | |
74 | + table.hashes.each do |item| | |
75 | + community = Community.create :name=>item[:name] | |
76 | + programming_language = ProgrammingLanguage.where(:name=>item[:software_language]).first | |
77 | + database_description = DatabaseDescription.where(:name=>item[:software_database]).first | |
78 | + | |
79 | + software_language = SoftwareLanguage.where(:programming_language_id=>programming_language).first | |
80 | + software_database = SoftwareDatabase.where(:database_description_id=>database_description).first | |
81 | + | |
82 | + software_info = SoftwareInfo::new(:acronym=>item[:acronym], :operating_platform=>item[:operating_platform]) | |
83 | + software_info.community = community | |
84 | + software_info.software_languages << software_language | |
85 | + software_info.software_databases << software_database | |
86 | + software_info.save! | |
87 | + end | |
88 | +end | |
89 | + | |
90 | +# Dynamic table steps | |
91 | +Given /^I fill in first "([^"]*)" class with "([^"]*)"$/ do |selector, value| | |
92 | + evaluate_script "jQuery('#{selector}').first().attr('value', '#{value}') && true" | |
93 | +end | |
94 | + | |
95 | +Given /^I fill in last "([^"]*)" class with "([^"]*)"$/ do |selector, value| | |
96 | + evaluate_script "jQuery('#{selector}').last().attr('value', '#{value}') && true" | |
97 | +end | |
98 | + | |
99 | +Given /^I click on the first button with class "([^"]*)"$/ do |selector| | |
100 | + evaluate_script "jQuery('#{selector}').first().trigger('click') && true" | |
101 | +end | |
102 | + | |
103 | +Given /^I click on the last button with class "([^"]*)"$/ do |selector| | |
104 | + evaluate_script "jQuery('#{selector}').last().trigger('click') && true" | |
105 | +end | |
106 | + | |
107 | +Given /^the user "([^"]*)" has "([^"]*)" as secondary e\-mail$/ do |login, email| | |
108 | + User[login].update_attributes(:secondary_email => email) | |
109 | +end | |
110 | + | |
111 | +Given /^I click on anything with selector "([^"]*)"$/ do |selector| | |
112 | + evaluate_script "jQuery('#{selector}').trigger('click') && true" | |
113 | +end | |
114 | + | |
115 | +Given /^I should see "([^"]*)" of this selector "([^"]*)"$/ do |quantity, selector| | |
116 | + evaluate_script "jQuery('#{selector}').length == '#{quantity}'" | |
117 | +end | |
118 | + | |
119 | +Given /^selector "([^"]*)" should have any "([^"]*)"$/ do |selector, text| | |
120 | + evaluate_script "jQuery('#{selector}').html().indexOf('#{text}') != -1" | |
121 | +end | |
122 | + | |
123 | +Given /^I click on table number "([^"]*)" selector "([^"]*)" and select the value "([^"]*)"$/ do |number, selector, value| | |
124 | + evaluate_script "jQuery('#{selector}:nth-child(#{number}) select option:contains(\"#{value}\")').selected() && true" | |
125 | +end | |
126 | + | |
127 | +Given /^I fill with "([^"]*)" in field with name "([^"]*)" of table number "([^"]*)" with class "([^"]*)"$/ do |value, name, number, selector| | |
128 | + evaluate_script "jQuery('#{selector}:nth-child(#{number}) input[name=\"#{name}\"]').val('#{value}') && true" | |
129 | +end | |
130 | + | |
131 | +Given /^I sleep for (\d+) seconds$/ do |time| | |
132 | + sleep time.to_i | |
133 | +end | |
0 | 134 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,310 @@ |
1 | +Feature: User Registration | |
2 | + | |
3 | + Background: | |
4 | + Given "MpogSoftwarePlugin" plugin is enabled | |
5 | + And I am logged in as admin | |
6 | + And I go to /admin/plugins | |
7 | + And I check "MpogSoftwarePlugin" | |
8 | + And I press "Save changes" | |
9 | + And I go to /admin/features/manage_fields | |
10 | + And I check "person_fields_country_active" | |
11 | + And I check "person_fields_country_required" | |
12 | + And I check "person_fields_country_signup" | |
13 | + And I check "person_fields_state_active" | |
14 | + And I check "person_fields_state_required" | |
15 | + And I check "person_fields_state_signup" | |
16 | + And I check "person_fields_city_active" | |
17 | + And I check "person_fields_city_required" | |
18 | + And I check "person_fields_city_signup" | |
19 | + And I press "Save changes" | |
20 | + And the following blocks | |
21 | + | owner | type | | |
22 | + | environment | LoginBlock | | |
23 | + And I go to /account/logout | |
24 | + | |
25 | + @selenium | |
26 | + Scenario: Successfull registration with only required fields | |
27 | + Given I go to /account/signup | |
28 | + And I fill in the following within ".no-boxes": | |
29 | + | e-Mail | josesilva@example.com | | |
30 | + | Username | josesilva | | |
31 | + | Password | secret | | |
32 | + | Password confirmation | secret | | |
33 | + | Full name | José da Silva | | |
34 | + | State | Bahia | | |
35 | + | City | Salvador | | |
36 | + And I select "Brazil" from "profile_data[country]" | |
37 | + And wait for the captcha signup time | |
38 | + And I press "Create my account" | |
39 | + When José da Silva's account is activated | |
40 | + And I go to login page | |
41 | + And I fill in "Username" with "josesilva" | |
42 | + And I fill in "Password" with "secret" | |
43 | + And I press "Log in" | |
44 | + Then I should be logged in as "josesilva" | |
45 | + | |
46 | + @selenium | |
47 | + Scenario: Successfull registration with governmental e-mail typing the name of the organization | |
48 | + Given I go to /account/signup | |
49 | + And Institutions has initial default values on database | |
50 | + And the following public institutions | |
51 | + | name | acronym | cnpj | governmental_power | governmental_sphere | | |
52 | + | Ministerio das Cidades | MC | 58.745.189/0001-21 | Executivo | Federal | | |
53 | + | Governo do DF | GDF | 12.645.166/0001-44 | Legislativo | Federal | | |
54 | + | Ministerio do Planejamento | MP | 41.769.591/0001-43 | Judiciario | Federal | | |
55 | + And I fill in the following within ".no-boxes": | |
56 | + | e-Mail | josesilva@serpro.gov.br| | |
57 | + | Username | josesilva | | |
58 | + | Password | secret | | |
59 | + | Password confirmation | secret | | |
60 | + | Full name | José da Silva | | |
61 | + | State | Bahia | | |
62 | + | City | Salvador | | |
63 | + | Secondary e-Mail | josesilva@example.com | | |
64 | + | Role | TI analist | | |
65 | + And I select "Brazil" from "profile_data[country]" | |
66 | + And I type in "Minis" into autocomplete list "input_institution" and I choose "Ministerio do Planejamento" | |
67 | + And wait for the captcha signup time | |
68 | + And I press "Create my account" | |
69 | + When José da Silva's account is activated | |
70 | + And I go to login page | |
71 | + And I fill in "Username" with "josesilva" | |
72 | + And I fill in "Password" with "secret" | |
73 | + And I press "Log in" | |
74 | + Then I should be logged in as "josesilva" | |
75 | + | |
76 | + @selenium | |
77 | + Scenario: Successfull registration with governmental e-mail typing the acronym of the organization | |
78 | + Given I go to /account/signup | |
79 | + And Institutions has initial default values on database | |
80 | + And the following public institutions | |
81 | + | name | acronym | cnpj | governmental_power | governmental_sphere | | |
82 | + | Ministerio das Cidades | MC | 58.745.189/0001-21 | Executivo | Federal | | |
83 | + | Governo do DF | GDF | 12.645.166/0001-44 | Legislativo | Federal | | |
84 | + | Ministerio do Planejamento | MP | 41.769.591/0001-43 | Judiciario | Federal | | |
85 | + And I fill in the following within ".no-boxes": | |
86 | + | e-Mail | josesilva@serpro.gov.br| | |
87 | + | Username | josesilva | | |
88 | + | Password | secret | | |
89 | + | Password confirmation | secret | | |
90 | + | Full name | José da Silva | | |
91 | + | State | Bahia | | |
92 | + | City | Salvador | | |
93 | + | Secondary e-Mail | josesilva@example.com | | |
94 | + | Role | TI analist | | |
95 | + And I select "Brazil" from "profile_data[country]" | |
96 | + And I type in "MP" into autocomplete list "input_institution" and I choose "Ministerio do Planejamento" | |
97 | + And wait for the captcha signup time | |
98 | + And I press "Create my account" | |
99 | + When José da Silva's account is activated | |
100 | + And I go to login page | |
101 | + And I fill in "Username" with "josesilva" | |
102 | + And I fill in "Password" with "secret" | |
103 | + And I press "Log in" | |
104 | + Then I should be logged in as "josesilva" | |
105 | + | |
106 | + @selenium | |
107 | + Scenario: Unsuccessfull registration due to the existance of e-mail as secondary another user's e-mail | |
108 | + Given the following users | |
109 | + | login | name | email | country | state | city | | |
110 | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | | |
111 | + And the user "maria" has "user@example.com" as secondary e-mail | |
112 | + And I go to /account/signup | |
113 | + And I fill in the following within ".no-boxes": | |
114 | + | e-Mail | user@example.com | | |
115 | + | Username | josesilva | | |
116 | + | Password | secret | | |
117 | + | Password confirmation | secret | | |
118 | + | Full name | José da Silva | | |
119 | + | State | Bahia | | |
120 | + | City | Salvador | | |
121 | + And wait for the captcha signup time | |
122 | + And I select "Brazil" from "profile_data[country]" | |
123 | + When I press "Create my account" | |
124 | + Then I should see "E-mail or secondary e-mail already taken." | |
125 | + | |
126 | + @selenium | |
127 | + Scenario: Unsuccessfull registration due to the existance of secondary e-mail as another user's secondary e-mail | |
128 | + Given the following users | |
129 | + | login | name | email | country | state | city | | |
130 | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | | |
131 | + And the user "maria" has "user@example.com" as secondary e-mail | |
132 | + And I go to /account/signup | |
133 | + And I fill in the following within ".no-boxes": | |
134 | + | e-Mail | josesilva@example.com | | |
135 | + | Username | josesilva | | |
136 | + | Password | secret | | |
137 | + | Password confirmation | secret | | |
138 | + | Full name | José da Silva | | |
139 | + | State | Bahia | | |
140 | + | City | Salvador | | |
141 | + | Secondary e-Mail | user@example.com | | |
142 | + And I select "Brazil" from "profile_data[country]" | |
143 | + And wait for the captcha signup time | |
144 | + When I press "Create my account" | |
145 | + Then I should see "E-mail or secondary e-mail already taken." | |
146 | + | |
147 | + @selenium | |
148 | + Scenario: Unsuccessfull registration due to the existance of secondary e-mail as another user's e-mail | |
149 | + Given the following users | |
150 | + | login | name | email | country | state | city | | |
151 | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | | |
152 | + And I go to /account/signup | |
153 | + And I fill in the following within ".no-boxes": | |
154 | + | e-Mail | josesilva@example.com | | |
155 | + | Username | josesilva | | |
156 | + | Password | secret | | |
157 | + | Password confirmation | secret | | |
158 | + | Full name | José da Silva | | |
159 | + | State | Bahia | | |
160 | + | City | Salvador | | |
161 | + | Secondary e-Mail | user@example.com | | |
162 | + And I select "Brazil" from "profile_data[country]" | |
163 | + And wait for the captcha signup time | |
164 | + When I press "Create my account" | |
165 | + Then I should see "E-mail or secondary e-mail already taken." | |
166 | + | |
167 | + @selenium | |
168 | + Scenario: Unsuccessfull registration due to both primary e-mail and secondary e-mail being equal | |
169 | + Given I go to /account/signup | |
170 | + And I fill in the following within ".no-boxes": | |
171 | + | Username | josesilva | | |
172 | + | e-Mail | josesilva@example.com | | |
173 | + | Password | secret | | |
174 | + | Password confirmation | secret | | |
175 | + | Full name | José da Silva | | |
176 | + | State | Bahia | | |
177 | + | City | Salvador | | |
178 | + | Secondary e-Mail | josesilva@example.com | | |
179 | + And I select "Brazil" from "profile_data[country]" | |
180 | + And wait for the captcha signup time | |
181 | + When I press "Create my account" | |
182 | + Then I should see "Email must be different from secondary email." | |
183 | + | |
184 | + @selenium | |
185 | + Scenario: Unsuccessfull registration due to government fields being blank | |
186 | + Given I go to /account/signup | |
187 | + And I fill in the following within ".no-boxes": | |
188 | + | Username | josesilva | | |
189 | + | e-Mail | josesilva@serpro.gov.br| | |
190 | + | Password | secret | | |
191 | + | Password confirmation | secret | | |
192 | + | Full name | José da Silva | | |
193 | + | Secondary e-Mail | josesilva@example.com | | |
194 | + And I select "Brazil" from "profile_data[country]" | |
195 | + And wait for the captcha signup time | |
196 | + When I press "Create my account" | |
197 | + Then I should see "Role can't be blank if e-mail has governamental sulfixes." | |
198 | + And I should see "Institution is obligatory if user has a government email." | |
199 | + And I should see "State can't be blank" | |
200 | + And I should see "City can't be blank" | |
201 | + | |
202 | + @selenium | |
203 | + Scenario: Unsuccessfull registration due to secondary email is governmental and primary is not | |
204 | + Given I go to /account/signup | |
205 | + And I fill in the following within ".no-boxes": | |
206 | + | Username | josesilva | | |
207 | + | e-Mail | josesilva@example.com | | |
208 | + | Password | secret | | |
209 | + | Password confirmation | secret | | |
210 | + | Full name | José da Silva | | |
211 | + | State | Bahia | | |
212 | + | City | Salvador | | |
213 | + | Secondary e-Mail | josesilva@serpro.gov.br| | |
214 | + And wait for the captcha signup time | |
215 | + When I press "Create my account" | |
216 | + Then I should see "The governamental email must be the primary one." | |
217 | + | |
218 | + @selenium | |
219 | + Scenario: Show incomplete resgistration percentage | |
220 | + Given I go to /account/signup | |
221 | + And I fill in the following within ".no-boxes": | |
222 | + | e-Mail | josesilva@gmail.com | | |
223 | + | Password | secret | | |
224 | + | Password confirmation | secret | | |
225 | + | Full name | José da Silva | | |
226 | + | State | Bahia | | |
227 | + | City | Salvador | | |
228 | + | Secondary e-Mail | josesilva@example.com | | |
229 | + | Role | TI analist | | |
230 | + And I select "Brazil" from "profile_data[country]" | |
231 | + And I fill in "Username" with "josesilva" | |
232 | + And wait for the captcha signup time | |
233 | + And I press "Create my account" | |
234 | + When José da Silva's account is activated | |
235 | + And I go to login page | |
236 | + And I fill in "Username" with "josesilva" | |
237 | + And I fill in "Password" with "secret" | |
238 | + And I press "Log in" | |
239 | + Then I should see "Percentage incomplete: 63 %" | |
240 | + | |
241 | + @selenium | |
242 | + Scenario: Remove the incomplete resgistration percentage message | |
243 | + Given I go to /account/signup | |
244 | + And I fill in the following within ".no-boxes": | |
245 | + | e-Mail | josesilva@gmail.com | | |
246 | + | Password | secret | | |
247 | + | Password confirmation | secret | | |
248 | + | Full name | José da Silva | | |
249 | + | State | Bahia | | |
250 | + | City | Salvador | | |
251 | + | Secondary e-Mail | josesilva@example.com | | |
252 | + | Role | TI analist | | |
253 | + And I select "Brazil" from "profile_data[country]" | |
254 | + And I fill in "Username" with "josesilva" | |
255 | + And wait for the captcha signup time | |
256 | + And I press "Create my account" | |
257 | + When José da Silva's account is activated | |
258 | + And I go to login page | |
259 | + And I fill in "Username" with "josesilva" | |
260 | + And I fill in "Password" with "secret" | |
261 | + And I press "Log in" | |
262 | + And I click on anything with selector ".hide-incomplete-percentage" | |
263 | + Then I should not see "Percentage incomplete: 63 %" | |
264 | + | |
265 | + @selenium | |
266 | + Scenario: When the user log out and log in again, the percentage registration message must appear | |
267 | + Given the following users | |
268 | + | login | name | email | country | state | city | | |
269 | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | | |
270 | + When I am logged in as "maria" | |
271 | + And I follow "Logout" | |
272 | + And I am logged in as "maria" | |
273 | + Then I should see "Percentage incomplete:" | |
274 | + | |
275 | + @selenium | |
276 | + Scenario: When the user logged in and hide link of imcomplete percentage and user log out and log in again, the percentage registration link must appear | |
277 | + Given the following users | |
278 | + | login | name | email | country | state | city | | |
279 | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | | |
280 | + When I am logged in as "maria" | |
281 | + And I go to /profile/maria | |
282 | + And I should see "Percentage incomplete:" | |
283 | + And I click on anything with selector ".hide-incomplete-percentage" | |
284 | + And I follow "Logout" | |
285 | + And I am logged in as "maria" | |
286 | + And I go to /profile/maria | |
287 | + Then I should see "Percentage incomplete:" | |
288 | + | |
289 | + @selenium | |
290 | + Scenario: When the user logged in and hide link of imcomplete percentage and user update page, the percentage registration link must not appear | |
291 | + Given the following users | |
292 | + | login | name | email | country | state | city | | |
293 | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | | |
294 | + When I am logged in as "maria" | |
295 | + And I go to /profile/maria | |
296 | + And I should see "Percentage incomplete:" | |
297 | + And I click on anything with selector ".hide-incomplete-percentage" | |
298 | + And I should not see "Percentage incomplete:" | |
299 | + And I go to /myprofile/maria/profile_editor/edit | |
300 | + And I go to /profile/maria | |
301 | + Then I should not see "Percentage incomplete:" | |
302 | + | |
303 | + @selenium | |
304 | + Scenario: When the user press incomplete percentage link,he must be redirect to his edit profile page | |
305 | + Given the following users | |
306 | + | login | name | email | country | state | city | | |
307 | + | maria | Maria Silva | maria@example.com | Brazil | DF | Brasilia | | |
308 | + When I am logged in as "maria" | |
309 | + And I follow "Percentage incomplete: 72 %" | |
310 | + Then I should see "Profile settings" | ... | ... |
... | ... | @@ -0,0 +1,85 @@ |
1 | +module DatabaseHelper | |
2 | + | |
3 | + def self.list_database new_databases | |
4 | + return [] if new_databases.nil? or new_databases.length == 0 | |
5 | + list_databases = [] | |
6 | + | |
7 | + new_databases.each do |new_database| | |
8 | + unless SoftwareHelper.all_table_is_empty? new_database, ["database_description_id"] | |
9 | + database = SoftwareDatabase.new | |
10 | + database.database_description_id = new_database[:database_description_id] | |
11 | + database.version = new_database[:version] | |
12 | + database.operating_system = new_database[:operating_system] | |
13 | + list_databases << database | |
14 | + end | |
15 | + end | |
16 | + | |
17 | + list_databases | |
18 | + end | |
19 | + | |
20 | + def self.valid_list_database? list_databases | |
21 | + return false if list_databases.nil? or list_databases.length == 0 | |
22 | + | |
23 | + list_databases.each do |database| | |
24 | + return false unless database.valid? | |
25 | + end | |
26 | + | |
27 | + true | |
28 | + end | |
29 | + | |
30 | + def self.database_as_tables(list_databases, have_delete_button = nil) | |
31 | + extend( | |
32 | + ActionView::Helpers::TagHelper, | |
33 | + ActionView::Helpers::FormTagHelper, | |
34 | + ActionView::Helpers::UrlHelper, | |
35 | + ActionView::Helpers::FormOptionsHelper, | |
36 | + ApplicationHelper | |
37 | + ) | |
38 | + | |
39 | + return database_html_structure({:database_description_id => 1, :version => "", :operating_system => ""}, have_delete_button) if list_databases.nil? | |
40 | + | |
41 | + lambdas_list = [] | |
42 | + | |
43 | + list_databases.each do |database| | |
44 | + lambdas_list << database_html_structure(database, have_delete_button) | |
45 | + end | |
46 | + | |
47 | + lambdas_list | |
48 | + end | |
49 | + | |
50 | + def self.database_html_structure(database_data, have_delete_button = nil) | |
51 | + Proc::new do | |
52 | + content_tag('table', | |
53 | + content_tag('tr', | |
54 | + content_tag('td', label_tag(_("database Name: ")))+ | |
55 | + content_tag('td', select_tag("database[][database_description_id]", SoftwareHelper.select_options(DatabaseDescription.all, database_data[:database_description_id]) ))+ | |
56 | + content_tag('td') | |
57 | + )+ | |
58 | + | |
59 | + content_tag('tr', | |
60 | + content_tag('td', label_tag(_("Version")))+ | |
61 | + content_tag('td', text_field_tag("database[][version]", database_data[:version]))+ | |
62 | + content_tag('td') | |
63 | + )+ | |
64 | + | |
65 | + content_tag('tr', | |
66 | + content_tag('td', label_tag(_("Operating System")))+ | |
67 | + content_tag('td', text_field_tag("database[][operating_system]", database_data[:operating_system]))+ | |
68 | + | |
69 | + if have_delete_button.nil? | |
70 | + content_tag('td', | |
71 | + button_without_text(:delete, _('Delete'), "#" , :class=>"delete-dynamic-table"), | |
72 | + :align => 'right' | |
73 | + ) | |
74 | + else | |
75 | + content_tag('td') | |
76 | + end | |
77 | + ), :class => 'dynamic-table database-table' | |
78 | + ) | |
79 | + end | |
80 | + end | |
81 | + | |
82 | + def self.add_dynamic_table | |
83 | + database_as_tables(nil).call | |
84 | + end | |
85 | +end | ... | ... |
... | ... | @@ -0,0 +1,51 @@ |
1 | +require_dependency 'community' | |
2 | + | |
3 | +class Community | |
4 | + | |
5 | + attr_accessible :visible | |
6 | + | |
7 | + has_one :software_info, :dependent=>:delete | |
8 | + has_one :institution, :dependent=>:delete | |
9 | + | |
10 | + def self.create_after_moderation(requestor, attributes = {}, software_info = nil, license_info = nil, controlled_vocabulary = nil) | |
11 | + community = Community.new(attributes) | |
12 | + if community.environment.enabled?('admin_must_approve_new_communities') | |
13 | + CreateCommunity.create(attributes.merge(:requestor => requestor)) | |
14 | + else | |
15 | + community = Community.create(attributes) | |
16 | + | |
17 | + if not software_info.nil? | |
18 | + if not license_info.nil? | |
19 | + software_info.license_info = license_info | |
20 | + end | |
21 | + | |
22 | + if not controlled_vocabulary.nil? | |
23 | + software_info.controlled_vocabulary = controlled_vocabulary | |
24 | + end | |
25 | + | |
26 | + community.software_info = software_info | |
27 | + end | |
28 | + | |
29 | + community.add_admin(requestor) | |
30 | + end | |
31 | + community | |
32 | + end | |
33 | + | |
34 | + def software? | |
35 | + return !software_info.nil? | |
36 | + end | |
37 | + | |
38 | + def institution? | |
39 | + return !institution.nil? | |
40 | + end | |
41 | + | |
42 | + def deactivate | |
43 | + self.visible = false | |
44 | + self.save! | |
45 | + end | |
46 | + | |
47 | + def activate | |
48 | + self.visible = true | |
49 | + self.save! | |
50 | + end | |
51 | +end | ... | ... |
... | ... | @@ -0,0 +1,12 @@ |
1 | +class ControlledVocabulary < ActiveRecord::Base | |
2 | + self.table_name = "controlled_vocabulary" | |
3 | + | |
4 | + attr_accessible :administration , :agriculture , :business_and_services , :communication , | |
5 | + :culture , :national_defense , :economy_and_finances , :education , | |
6 | + :energy , :sports , :habitation , :industry , :environment , | |
7 | + :research_and_development , :social_security , :social_protection , | |
8 | + :international_relations , :sanitation , :health , | |
9 | + :security_public_order , :work , :transportation , :urbanism | |
10 | + | |
11 | + belongs_to :software_info | |
12 | +end | |
0 | 13 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,77 @@ |
1 | +require_dependency 'person' | |
2 | + | |
3 | +class Person | |
4 | + | |
5 | + settings_items :area_interest, :type => :string, :default => "" | |
6 | + settings_items :percentage_incomplete, :type => :string, :default => "" | |
7 | + | |
8 | + attr_accessible :area_interest | |
9 | + attr_accessible :percentage_incomplete | |
10 | + | |
11 | + scope :search, lambda { |name="", state="", city="", email=""| | |
12 | + like_sql = "" | |
13 | + values = [] | |
14 | + | |
15 | + unless name.nil? and name.blank? | |
16 | + like_sql << "name ILIKE ? AND " | |
17 | + values << "%#{name}%" | |
18 | + end | |
19 | + | |
20 | + unless state.nil? and state.blank? | |
21 | + like_sql << "data ILIKE ? AND " | |
22 | + values << "%:state: %#{state}%" | |
23 | + end | |
24 | + | |
25 | + unless city.nil? and city.blank? | |
26 | + like_sql << "data ILIKE ? AND " | |
27 | + values << "%:city: %#{city}%" | |
28 | + end | |
29 | + | |
30 | + unless email.nil? and email.blank? | |
31 | + like_sql << "email ILIKE ? AND " | |
32 | + values << "%#{email}%" | |
33 | + end | |
34 | + like_sql = like_sql[0..like_sql.length-5] | |
35 | + | |
36 | + { | |
37 | + :joins => :user, | |
38 | + :conditions=>[like_sql, *values] | |
39 | + } | |
40 | + } | |
41 | + | |
42 | + def secondary_email | |
43 | + self.user.secondary_email unless self.user.nil? | |
44 | + end | |
45 | + | |
46 | + def secondary_email= value | |
47 | + self.user.secondary_email = value unless self.user.nil? | |
48 | + end | |
49 | + | |
50 | + def institution | |
51 | + self.user.institution.name if self.user and self.user.institution | |
52 | + end | |
53 | + | |
54 | + def institution_id | |
55 | + self.user.institution.id unless self.user.institution.nil? | |
56 | + end | |
57 | + | |
58 | + def institution_id= value | |
59 | + institution = Institution.find(:first, :conditions=>"id = #{value}") | |
60 | + | |
61 | + unless institution.nil? | |
62 | + self.user.institution = institution | |
63 | + end | |
64 | + end | |
65 | + | |
66 | + def role | |
67 | + self.user.role unless self.user.nil? | |
68 | + end | |
69 | + | |
70 | + def role= value | |
71 | + self.user.role = value unless self.user.nil? | |
72 | + end | |
73 | + | |
74 | + def software? | |
75 | + false | |
76 | + end | |
77 | +end | ... | ... |
... | ... | @@ -0,0 +1,67 @@ |
1 | +require_dependency 'user' | |
2 | + | |
3 | +class User | |
4 | + | |
5 | + belongs_to :institution | |
6 | + | |
7 | + validate :email_different_secondary?, :email_has_already_been_used?, | |
8 | + :secondary_email_format, :email_suffix_is_gov?, :validate_role? | |
9 | + | |
10 | + scope :primary_or_secondary_email_already_used?, lambda { |email| | |
11 | + where("email=? OR secondary_email=?", email, email) | |
12 | + } | |
13 | + | |
14 | + def email_different_secondary? | |
15 | + self.errors.add(:base, _("Email must be different from secondary email.")) if self.email == self.secondary_email | |
16 | + end | |
17 | + | |
18 | + def email_has_already_been_used? | |
19 | + user_already_saved = User.find(:first, :conditions=>["email = ?", self.email]) | |
20 | + | |
21 | + if user_already_saved.nil? | |
22 | + primary_email_hasnt_been_used = User.primary_or_secondary_email_already_used?(self.email).empty? | |
23 | + secondary_email_hasnt_been_used = User.primary_or_secondary_email_already_used?(self.secondary_email).empty? | |
24 | + | |
25 | + if !primary_email_hasnt_been_used or !secondary_email_hasnt_been_used | |
26 | + self.errors.add(:base, _("E-mail or secondary e-mail already taken.")) | |
27 | + end | |
28 | + end | |
29 | + end | |
30 | + | |
31 | + def secondary_email_format | |
32 | + if !self.secondary_email.nil? and self.secondary_email.length > 0 | |
33 | + test = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/ | |
34 | + self.errors.add(:base, _("Invalid secondary email format.")) unless test.match(self.secondary_email) | |
35 | + end | |
36 | + end | |
37 | + | |
38 | + def email_suffix_is_gov? | |
39 | + test = /^.*@[gov.br|jus.br|leg.br|mp.br]+$/ | |
40 | + primary_email_has_gov_suffix = false | |
41 | + secondary_email_has_gov_suffix = false | |
42 | + | |
43 | + if !self.email.nil? and self.email.length > 0 | |
44 | + primary_email_has_gov_suffix = true if test.match(self.email) | |
45 | + end | |
46 | + | |
47 | + unless primary_email_has_gov_suffix | |
48 | + if !self.secondary_email.nil? and self.secondary_email.length > 0 | |
49 | + secondary_email_has_gov_suffix = true if test.match(self.secondary_email) | |
50 | + end | |
51 | + self.errors.add(:base, _("The governamental email must be the primary one.")) if secondary_email_has_gov_suffix | |
52 | + end | |
53 | + | |
54 | + self.errors.add(:base, _("Institution is obligatory if user has a government email.")) if primary_email_has_gov_suffix and self.institution.nil? | |
55 | + end | |
56 | + | |
57 | + def validate_role? | |
58 | + valid_sufix = ['gov.br','jus.br','leg.br','mp.br'] | |
59 | + valid_sufix.each do |sufix| | |
60 | + if (self.secondary_email =~ /#{sufix}(.*)/ || self.email =~ /#{sufix}(.*)/) and self.role.blank? | |
61 | + errors.add(:role, _("can't be blank if e-mail has governamental sulfixes.")) | |
62 | + break | |
63 | + end | |
64 | + end | |
65 | + end | |
66 | + | |
67 | +end | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +class GovernmentalPower < ActiveRecord::Base | |
2 | + attr_accessible :name | |
3 | + | |
4 | + validates :name, :presence=>true, :uniqueness=>true | |
5 | + has_many :institutions | |
6 | + | |
7 | + def public_institutions | |
8 | + Institution.where(:type=>"PublicInstitution", :governmental_power_id=>self.id) | |
9 | + end | |
10 | +end | ... | ... |
... | ... | @@ -0,0 +1,30 @@ |
1 | +class Institution < ActiveRecord::Base | |
2 | + belongs_to :governmental_power | |
3 | + belongs_to :governmental_sphere | |
4 | + | |
5 | + attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, | |
6 | + :juridical_nature, :sub_juridical_nature, :normalization_level, | |
7 | + :version, :cnpj, :type, :governmental_power, :governmental_sphere | |
8 | + has_many :users | |
9 | + | |
10 | + validates :name, :presence=>true, :uniqueness=>true | |
11 | + | |
12 | + before_save :verify_institution_type | |
13 | + | |
14 | + belongs_to :community | |
15 | + | |
16 | + scope :search_institution, lambda{ |value| | |
17 | + where("name ilike ? OR acronym ilike ?", "%#{value}%", "%#{value}%" ) | |
18 | + } | |
19 | + | |
20 | + protected | |
21 | + | |
22 | + def verify_institution_type | |
23 | + valid_institutions_type = ["PublicInstitution", "PrivateInstitution"] | |
24 | + | |
25 | + unless valid_institutions_type.include? self.type | |
26 | + self.errors.add(:type, _("invalid, only public and private institutions are allowed.")) | |
27 | + false | |
28 | + end | |
29 | + end | |
30 | +end | ... | ... |
... | ... | @@ -0,0 +1,76 @@ |
1 | +require "net/http" | |
2 | +require "yaml" | |
3 | + | |
4 | +module InstitutionHelper | |
5 | + | |
6 | + SPHERES = ['federal'] | |
7 | + POWERS = ['executive', 'legislative', 'judiciary'] | |
8 | + | |
9 | + def self.mass_update | |
10 | + @web_service_info = self.web_service_info | |
11 | + | |
12 | + POWERS.each do |power| | |
13 | + SPHERES.each do |sphere| | |
14 | + json = self.get_json power, sphere | |
15 | + | |
16 | + units = json["unidades"] | |
17 | + | |
18 | + units.each do |unit| | |
19 | + institution = Institution.where(:name=>unit["nome"]) | |
20 | + | |
21 | + institution = if institution.count == 0 | |
22 | + Institution::new | |
23 | + else | |
24 | + institution.first | |
25 | + end | |
26 | + | |
27 | + institution = self.set_institution_data institution, unit | |
28 | + institution.save | |
29 | + end | |
30 | + end | |
31 | + end | |
32 | + end | |
33 | + | |
34 | + protected | |
35 | + | |
36 | + def self.web_service_info | |
37 | + YAML.load_file(File.dirname(__FILE__) + '/../config/siorg.yml')['web_service'] | |
38 | + end | |
39 | + | |
40 | + def self.service_url power, sphere | |
41 | + base_url = @web_service_info['base_url'] | |
42 | + power_code = @web_service_info['power_codes'][power].to_s | |
43 | + sphere_code = @web_service_info['sphere_codes'][sphere].to_s | |
44 | + additional_params = @web_service_info['additional_params'] | |
45 | + | |
46 | + return URI("#{base_url}?codigoPoder=#{power_code}&codigoEsfera=#{sphere_code}&#{additional_params}") | |
47 | + end | |
48 | + | |
49 | + def self.get_json power, sphere | |
50 | + uri = self.service_url power, sphere #URI(BASE_URL+"codigoPoder=#{power_code}&codigoEsfera=#{sphere_code}&retornarOrgaoEntidadeVinculados=NAO") | |
51 | + data = Net::HTTP.get(uri) | |
52 | + ActiveSupport::JSON.decode(data) | |
53 | + end | |
54 | + | |
55 | + def self.retrieve_code unit, field | |
56 | + data = unit[field] | |
57 | + return data.split("/").last unless (data.blank? || data.nil?) | |
58 | + return nil | |
59 | + end | |
60 | + | |
61 | + def self.set_institution_data institution, unit | |
62 | + institution.name = unit["nome"] | |
63 | + institution.acronym = unit["sigla"] | |
64 | + institution.unit_code = self.retrieve_code(unit,"codigoUnidade") | |
65 | + institution.parent_code = self.retrieve_code(unit,"codigoUnidadePai") | |
66 | + institution.unit_type = self.retrieve_code(unit,"codigoTipoUnidade") | |
67 | + institution.juridical_nature = self.retrieve_code(unit,"codigoNaturezaJuridica") | |
68 | + institution.sub_juridical_nature = self.retrieve_code(unit,"codigoSubNaturezaJuridica") | |
69 | + institution.normalization_level = unit["nivelNormatizacao"] | |
70 | + institution.version = unit["versaoConsulta"] | |
71 | + institution.type = "PublicInstitution" | |
72 | + institution.governmental_power = GovernmentalPower.where(:name=>self.retrieve_code(unit,"codigoPoder")).first | |
73 | + institution.governmental_sphere = GovernmentalSphere.where(:name=>self.retrieve_code(unit,"codigoEsfera")).first | |
74 | + institution | |
75 | + end | |
76 | +end | ... | ... |
... | ... | @@ -0,0 +1,22 @@ |
1 | +class Library < ActiveRecord::Base | |
2 | + | |
3 | + #TODO missing relations? | |
4 | + | |
5 | + attr_accessible :name, :version, :license, :software_info_id | |
6 | + | |
7 | + #TODO: review validations | |
8 | + validate :validate_name, :validate_version, :validate_license | |
9 | + | |
10 | + def validate_name | |
11 | + self.errors.add(:name, _("can't be blank")) if self.name.blank? && self.errors[:name].blank? | |
12 | + end | |
13 | + | |
14 | + def validate_version | |
15 | + self.errors.add(:version, _("can't be blank")) if self.version.blank? && self.errors[:version].blank? | |
16 | + end | |
17 | + | |
18 | + def validate_license | |
19 | + self.errors.add(:license, _("can't be blank")) if self.license.blank? && self.errors[:license].blank? | |
20 | + end | |
21 | + | |
22 | +end | ... | ... |
... | ... | @@ -0,0 +1,78 @@ |
1 | +module LibraryHelper | |
2 | + def self.list_libraries new_libraries | |
3 | + return [] if new_libraries.nil? or new_libraries.length == 0 | |
4 | + list_libraries = [] | |
5 | + | |
6 | + new_libraries.each do |new_library| | |
7 | + unless SoftwareHelper.all_table_is_empty? new_library | |
8 | + library = Library.new | |
9 | + library.name = new_library[:name] | |
10 | + library.version = new_library[:version] | |
11 | + library.license = new_library[:license] | |
12 | + list_libraries << library | |
13 | + end | |
14 | + end | |
15 | + | |
16 | + list_libraries | |
17 | + end | |
18 | + | |
19 | + def self.valid_list_libraries? list_libraries | |
20 | + return true if list_libraries.nil? or list_libraries.length == 0 | |
21 | + | |
22 | + list_libraries.each do |library| | |
23 | + return false unless library.valid? | |
24 | + end | |
25 | + | |
26 | + true | |
27 | + end | |
28 | + | |
29 | + def self.library_as_tables list_libraries | |
30 | + extend( | |
31 | + ActionView::Helpers::TagHelper, | |
32 | + ActionView::Helpers::FormTagHelper, | |
33 | + ActionView::Helpers::UrlHelper, | |
34 | + ApplicationHelper | |
35 | + ) | |
36 | + | |
37 | + return library_html_structure({:name=>"", :version=>"", :license=>""}) if list_libraries.nil? | |
38 | + | |
39 | + lambdas_list = [] | |
40 | + | |
41 | + list_libraries.each do |library| | |
42 | + lambdas_list << library_html_structure(library) | |
43 | + end | |
44 | + | |
45 | + lambdas_list | |
46 | + end | |
47 | + | |
48 | + def self.library_html_structure library_data | |
49 | + Proc::new do | |
50 | + content_tag('table', | |
51 | + content_tag('tr', | |
52 | + content_tag('td', label_tag(_("Name")))+ | |
53 | + content_tag('td', text_field_tag("library[][name]", library_data[:name]))+ | |
54 | + content_tag('td') | |
55 | + )+ | |
56 | + | |
57 | + content_tag('tr', | |
58 | + content_tag('td', label_tag(_("Version")))+ | |
59 | + content_tag('td', text_field_tag("library[][version]", library_data[:version]))+ | |
60 | + content_tag('td') | |
61 | + )+ | |
62 | + | |
63 | + content_tag('tr', | |
64 | + content_tag('td', label_tag(_("License")))+ | |
65 | + content_tag('td', text_field_tag("library[][license]", library_data[:license])) + | |
66 | + content_tag('td', | |
67 | + button_without_text(:delete, _('Delete'), "#" , :class=>"delete-dynamic-table"), | |
68 | + :align => 'right' | |
69 | + ) | |
70 | + ), :class => 'dynamic-table library-table' | |
71 | + ) | |
72 | + end | |
73 | + end | |
74 | + | |
75 | + def self.add_dynamic_table | |
76 | + library_as_tables(nil).call | |
77 | + end | |
78 | +end | ... | ... |
... | ... | @@ -0,0 +1,346 @@ |
1 | +class MpogSoftwarePlugin < Noosfero::Plugin | |
2 | + include ActionView::Helpers::TagHelper | |
3 | + include ActionView::Helpers::FormTagHelper | |
4 | + include ActionView::Helpers::FormOptionsHelper | |
5 | + include ActionView::Helpers::JavaScriptHelper | |
6 | + include ActionView::Helpers::AssetTagHelper | |
7 | + include FormsHelper | |
8 | + include LibraryHelper | |
9 | + | |
10 | + def self.plugin_name | |
11 | + "MpogSoftwarePlugin" | |
12 | + end | |
13 | + | |
14 | + def self.plugin_description | |
15 | + _("Add Public Software and MPOG features.") | |
16 | + end | |
17 | + | |
18 | + def signup_extra_contents | |
19 | + institutions = Institution.all | |
20 | + | |
21 | + Proc::new do | |
22 | + content_tag(:div, | |
23 | + required(labelled_form_field( | |
24 | + _('Secondary e-Mail'), | |
25 | + text_field(:user, :secondary_email, :id => 'secondary_email_field') + | |
26 | + content_tag( | |
27 | + :small, _("If you have a gov email, don't forget to use this email on the primary email") ,:class => 'signup-form',:id =>'secondary-email-balloon') | |
28 | + )), | |
29 | + :id => 'signup-secondary-email') + | |
30 | + | |
31 | + content_tag(:div, | |
32 | + labelled_form_field( | |
33 | + _('Role'), text_field(:user, :role, :id => 'role_field') + | |
34 | + content_tag( | |
35 | + :small,_('If your primary email has one of those sufix: gov.br, jus.br, leg.br or mp.br, dont forget to fill your role in the organization'),:class => 'signup-form',:id =>'role-balloon')), | |
36 | + :id => 'signup-role' | |
37 | + ) + | |
38 | + | |
39 | + content_tag(:div, | |
40 | + labelled_form_field( | |
41 | + _('Areas of Interest'), | |
42 | + text_field(:profile_data, :area_interest, :id => 'area_interest_field')+ | |
43 | + content_tag( | |
44 | + :small,_('Fill with your interest areas'),:class => 'signup-form',:id =>'area-interest-balloon')), | |
45 | + :id => 'signup-area-interest' | |
46 | + ) + | |
47 | + | |
48 | + content_tag(:div, | |
49 | + labelled_form_field( | |
50 | + _('Institution'), | |
51 | + text_field(:institution, :name, :id => 'input_institution')+ | |
52 | + content_tag( | |
53 | + :small, _('Fill with your institution') ,:class => 'signup-form', :id =>'institution-balloon' | |
54 | + ) + | |
55 | + content_tag(:div, _("The searched institution does not exist"), :id=>"institution_empty_ajax_message", :class=>"errorExplanation hide-field") + | |
56 | + link_to(_("Add new institution"), "#", :id=>"create_institution_link", :class=>'button with-text icon-add')+ | |
57 | + hidden_field_tag("user[institution_id]", "", :id => 'user_institution_id')+ | |
58 | + content_tag(:div, "", :id=>"institution_dialog") | |
59 | + ), | |
60 | + :id => 'signup-institution' | |
61 | + ) | |
62 | + end | |
63 | + end | |
64 | + | |
65 | + def profile_editor_extras | |
66 | + if context.profile.person? | |
67 | + expanded_template('person_editor_extras.html.erb') | |
68 | + elsif context.profile.respond_to? :software_info and !context.profile.software_info.nil? | |
69 | + expanded_template('software_editor_extras.html.erb') | |
70 | + elsif context.profile.respond_to? :institution and !context.profile.institution.nil? | |
71 | + expanded_template('institution_editor_extras.html.erb') | |
72 | + end | |
73 | + end | |
74 | + | |
75 | + def profile_editor_transaction_extras | |
76 | + if context.profile.respond_to?(:software_info) | |
77 | + if context.params.has_key?(:software_info) | |
78 | + software_info_transaction | |
79 | + end | |
80 | + | |
81 | + if context.params.has_key?(:library) | |
82 | + libraries_transaction | |
83 | + end | |
84 | + | |
85 | + if context.params.has_key?(:version) | |
86 | + license_transaction | |
87 | + end | |
88 | + | |
89 | + if context.params.has_key?(:language) | |
90 | + language_transaction | |
91 | + end | |
92 | + | |
93 | + if context.params.has_key?(:database) | |
94 | + databases_transaction | |
95 | + end | |
96 | + | |
97 | + if context.params.has_key?(:operating_system) | |
98 | + operating_system_transaction | |
99 | + end | |
100 | + if context.params.has_key?(:institution) || context.params.has_key?(:governmental_power) || context.params.has_key?(:governmental_sphere) | |
101 | + institution_transaction | |
102 | + end | |
103 | + | |
104 | + if context.params.has_key?(:controlled_vocabulary) | |
105 | + controlled_vocabulary_transaction | |
106 | + end | |
107 | + elsif context.profile.respond_to?(:user) | |
108 | + if context.params.has_key?(:user) | |
109 | + user_transaction | |
110 | + end | |
111 | + end | |
112 | + end | |
113 | + | |
114 | + def profile_tabs | |
115 | + if context.profile.person? | |
116 | + { :title => _("Mpog"), | |
117 | + :id => 'mpog-fields', | |
118 | + :content => Proc::new do render :partial => 'profile_tab' end, | |
119 | + :start => true } | |
120 | + elsif context.profile.software? | |
121 | + { :title => _("Software"), | |
122 | + :id => 'mpog-fields', | |
123 | + :content => Proc::new do render :partial => 'software_tab' end, | |
124 | + :start => true } | |
125 | + elsif context.profile.institution? | |
126 | + { :title => _("Institution"), | |
127 | + :id => 'mpog-fields', | |
128 | + :content => Proc::new do render :partial => 'institution_tab' end, | |
129 | + :start => true | |
130 | + } | |
131 | + end | |
132 | + end | |
133 | + | |
134 | + def stylesheet? | |
135 | + true | |
136 | + end | |
137 | + | |
138 | + def js_files | |
139 | + ["mpog-software-validations.js", "mpog-user-validations.js", "mpog-institution-validations.js"] | |
140 | + end | |
141 | + | |
142 | + def alternative_exclusion | |
143 | + if context.profile.person? | |
144 | + if context.profile.disable | |
145 | + context.session[:notice] = _('The profile was deactivated.') | |
146 | + context.profile.user.forget_me | |
147 | + context.session.delete(:user) | |
148 | + | |
149 | + true | |
150 | + end | |
151 | + elsif context.profile.community? | |
152 | + context.profile.software_info.software_languages.delete_all | |
153 | + context.profile.destroy | |
154 | + | |
155 | + mensage = context.profile.software_info.nil? ? "community" : "software" | |
156 | + context.session[:notice] = _("The #{mensage} was deleted.") | |
157 | + else | |
158 | + false | |
159 | + end | |
160 | + end | |
161 | + | |
162 | + def add_new_organization_button | |
163 | + Proc::new do | |
164 | + button(:add, _('Create a new software'), :controller => 'mpog_software_plugin_myprofile', :action => 'new_software') | |
165 | + end | |
166 | + end | |
167 | + | |
168 | + def alternative_reactive_account(person) | |
169 | + person.visible = true | |
170 | + person.save | |
171 | + true | |
172 | + end | |
173 | + | |
174 | + # FIXME - if in error log apears has_permission?, try to use this method | |
175 | + def has_permission?(person, permission, target) | |
176 | + person.has_permission_without_plugins?(permission, target) | |
177 | + end | |
178 | + | |
179 | + def incomplete_registration params | |
180 | + person = User.find(params[:user]).person | |
181 | + percentege = calc_percentage_registration(person) | |
182 | + if percentege >= 0 and percentege <= 100 | |
183 | + return _("Registration "+percentege.to_s+"% incomplete ") | |
184 | + end | |
185 | + end | |
186 | + | |
187 | + def calc_percentage_registration person | |
188 | + empty_fields = 0 | |
189 | + required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"] | |
190 | + required_list.each do |field| | |
191 | + if person.send(field).blank? | |
192 | + empty_fields = empty_fields + 1 | |
193 | + end | |
194 | + end | |
195 | + percentege = (empty_fields*100)/required_list.count | |
196 | + person.percentage_incomplete = percentege | |
197 | + person.save(validate: false) | |
198 | + percentege | |
199 | + end | |
200 | + | |
201 | + def add_link_to_complete_registration person | |
202 | + #find a better way to do it | |
203 | + if context.session[:hide_incomplete_percentage] != true | |
204 | + new_url = person.public_profile_url | |
205 | + new_url[:controller] = 'profile_editor' | |
206 | + new_url[:action] = 'edit' | |
207 | + | |
208 | + Proc::new do | |
209 | + content_tag(:div, | |
210 | + link_to( _("Percentage incomplete: #{person.percentage_incomplete.to_s} %" ), new_url) + | |
211 | + link_to(image_tag("/images/icon_filter_exclude.png"), "#", :class => "hide-incomplete-percentage", :alt => "Hide Incomplete Percentage"), :class=>"mpog-incomplete-percentage" | |
212 | + ) | |
213 | + end | |
214 | + end | |
215 | + end | |
216 | + | |
217 | + def manage_software | |
218 | + [{:title => _('Manage Software'), :url => {:controller => 'mpog_software_plugin', :action => 'archive_software'}}] | |
219 | + end | |
220 | + | |
221 | + protected | |
222 | + | |
223 | + def operating_system_transaction | |
224 | + OperatingSystem.transaction do | |
225 | + list_operating = OperatingSystemHelper.list_operating_system(context.params[:operating_system]) | |
226 | + | |
227 | + if OperatingSystemHelper.valid_list_operating_system?(list_operating) | |
228 | + OperatingSystem.where(:software_info_id => context.profile.software_info.id).destroy_all | |
229 | + list_operating.each do |operating_system| | |
230 | + operating_system.software_info = context.profile.software_info | |
231 | + operating_system.save! | |
232 | + end | |
233 | + else | |
234 | + raise 'Invalid Operating System fields' | |
235 | + end | |
236 | + end | |
237 | + end | |
238 | + | |
239 | + def user_transaction | |
240 | + User.transaction do | |
241 | + context.profile.user.update_attributes!(context.params[:user]) | |
242 | + end | |
243 | + end | |
244 | + | |
245 | + def institution_transaction | |
246 | + if context.params.has_key?(:governmental_power) | |
247 | + context.profile.institution.governmental_power_id = context.params[:governmental_power] | |
248 | + context.profile.institution.save! | |
249 | + end | |
250 | + | |
251 | + if context.params.has_key?(:governmental_sphere) | |
252 | + context.profile.institution.governmental_sphere_id = context.params[:governmental_sphere] | |
253 | + context.profile.institution.save! | |
254 | + end | |
255 | + | |
256 | + if context.params.has_key?(:institution) | |
257 | + Institution.transaction do | |
258 | + context.profile.institution.update_attributes!(context.params[:institution]) | |
259 | + end | |
260 | + end | |
261 | + end | |
262 | + | |
263 | + def software_info_transaction | |
264 | + SoftwareInfo.transaction do | |
265 | + context.profile.software_info.update_attributes!(context.params[:software_info]) | |
266 | + end | |
267 | + end | |
268 | + | |
269 | + def libraries_transaction | |
270 | + Library.transaction do | |
271 | + list_libraries = LibraryHelper.list_libraries(context.params[:library]) | |
272 | + | |
273 | + if LibraryHelper.valid_list_libraries?(list_libraries) | |
274 | + Library.where(:software_info_id=> context.profile.software_info.id).destroy_all | |
275 | + | |
276 | + list_libraries.each do |library| | |
277 | + library.software_info_id = context.profile.software_info.id | |
278 | + library.save! | |
279 | + end | |
280 | + else | |
281 | + raise 'Invalid Library fields' | |
282 | + end | |
283 | + end | |
284 | + end | |
285 | + | |
286 | + def databases_transaction | |
287 | + SoftwareDatabase.transaction do | |
288 | + list_databases = DatabaseHelper.list_database(context.params[:database]) | |
289 | + | |
290 | + if DatabaseHelper.valid_list_database?(list_databases) | |
291 | + SoftwareDatabase.where(:software_info_id => context.profile.software_info.id).destroy_all | |
292 | + list_databases.each do |database| | |
293 | + database.software_info = context.profile.software_info | |
294 | + database.save! | |
295 | + end | |
296 | + else | |
297 | + raise 'Invalid Database fields' | |
298 | + end | |
299 | + end | |
300 | + end | |
301 | + | |
302 | + def license_transaction | |
303 | + license = LicenseInfo.find(context.params[:version]) | |
304 | + context.profile.software_info.license_info = license | |
305 | + context.profile.software_info.save! | |
306 | + end | |
307 | + | |
308 | + def manage_software | |
309 | + [{:title => _('Manage Software'), :url => {:controller => 'mpog_software_plugin_myprofile', :action => 'new_software'}}] | |
310 | + end | |
311 | + | |
312 | + def language_transaction | |
313 | + SoftwareLanguage.transaction do | |
314 | + list_language = SoftwareLanguageHelper.list_language(context.params[:language]) | |
315 | + | |
316 | + if SoftwareLanguageHelper.valid_list_language?(list_language) | |
317 | + SoftwareLanguage.where(:software_info_id => context.profile.software_info.id).destroy_all | |
318 | + | |
319 | + list_language.each do |language| | |
320 | + language.software_info = context.profile.software_info | |
321 | + language.save! | |
322 | + end | |
323 | + else | |
324 | + raise 'Invalid Software Language fields' | |
325 | + end | |
326 | + end | |
327 | + end | |
328 | + | |
329 | + def add_new_user_search_filter | |
330 | + expanded_template('user_search/search_filter.html.erb') | |
331 | + end | |
332 | + | |
333 | + def custom_people_search params | |
334 | + Person.search(params[:name], | |
335 | + params[:state], | |
336 | + params[:city], | |
337 | + params[:email] | |
338 | + ) | |
339 | + end | |
340 | + | |
341 | + def controlled_vocabulary_transaction | |
342 | + ControlledVocabulary.transaction do | |
343 | + context.profile.software_info.controlled_vocabulary.update_attributes!(context.params[:controlled_vocabulary]) | |
344 | + end | |
345 | + end | |
346 | +end | ... | ... |
... | ... | @@ -0,0 +1,80 @@ |
1 | +module OperatingSystemHelper | |
2 | + def self.list_operating_system new_operating_systems | |
3 | + return [] if new_operating_systems.nil? or new_operating_systems.length == 0 | |
4 | + list_operating_system = [] | |
5 | + | |
6 | + new_operating_systems.each do |new_operating_system| | |
7 | + unless SoftwareHelper.all_table_is_empty? new_operating_system, ["operating_system_name_id"] | |
8 | + operating_system = OperatingSystem.new | |
9 | + operating_system.operating_system_name = OperatingSystemName.find(new_operating_system[:operating_system_name_id]) | |
10 | + operating_system.version = new_operating_system[:version] | |
11 | + list_operating_system << operating_system | |
12 | + end | |
13 | + end | |
14 | + list_operating_system | |
15 | + end | |
16 | + | |
17 | + def self.valid_list_operating_system? list_operating_system | |
18 | + return false if list_operating_system.nil? or list_operating_system.length == 0 | |
19 | + | |
20 | + list_operating_system.each do |operating_system| | |
21 | + return false unless operating_system.valid? | |
22 | + end | |
23 | + true | |
24 | + end | |
25 | + | |
26 | + def self.operating_system_as_tables (list_operating_system, have_delete_button = true, show_information = false) | |
27 | + extend( | |
28 | + ActionView::Helpers::TagHelper, | |
29 | + ActionView::Helpers::FormTagHelper, | |
30 | + ActionView::Helpers::UrlHelper, | |
31 | + ActionView::Helpers::FormOptionsHelper, | |
32 | + ApplicationHelper | |
33 | + ) | |
34 | + | |
35 | + lambdas_list = [] | |
36 | + | |
37 | + if not show_information | |
38 | + return operating_system_html_structure({:operating_system_name_id => "", :version => ""}, have_delete_button) if list_operating_system.nil? | |
39 | + | |
40 | + list_operating_system.each do |operating_system| | |
41 | + lambdas_list << operating_system_html_structure(operating_system,have_delete_button) | |
42 | + end | |
43 | + else | |
44 | + list_operating_system.each do |operating_system| | |
45 | + lambdas_list << operating_system_html_structure(operating_system) | |
46 | + end | |
47 | + end | |
48 | + | |
49 | + lambdas_list | |
50 | + end | |
51 | + | |
52 | + def self.operating_system_html_structure (operating_system_data,have_delete_button = true) | |
53 | + Proc::new do | |
54 | + content_tag('table', | |
55 | + content_tag('tr', | |
56 | + content_tag('td', label_tag(_("Name")))+ | |
57 | + content_tag('td', select_tag("operating_system[][operating_system_name_id]", SoftwareHelper.select_options(OperatingSystemName.all, operating_system_data[:operating_system_name_id]) ))+ | |
58 | + content_tag('td') | |
59 | + )+ | |
60 | + | |
61 | + content_tag('tr', | |
62 | + content_tag('td', label_tag(_("Version")))+ | |
63 | + content_tag('td', text_field_tag("operating_system[][version]", operating_system_data[:version]))+ | |
64 | + if have_delete_button | |
65 | + content_tag('td', | |
66 | + button_without_text(:delete, _('Delete'), "#" , :class=>"delete-dynamic-table"), | |
67 | + :align => 'right' | |
68 | + ) | |
69 | + else | |
70 | + content_tag('td', "") | |
71 | + end | |
72 | + ),:class => 'dynamic-table library-table' | |
73 | + ) | |
74 | + end | |
75 | + end | |
76 | + | |
77 | + def self.add_dynamic_table | |
78 | + operating_system_as_tables(nil).call | |
79 | + end | |
80 | +end | ... | ... |
... | ... | @@ -0,0 +1,5 @@ |
1 | +class PublicInstitution < Institution | |
2 | + validates :acronym, :governmental_power, :governmental_sphere, :presence=>true | |
3 | + validates_uniqueness_of :cnpj, :unit_code, :allow_nil => true, :allow_blank => true | |
4 | + validates_format_of :cnpj, :with => /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/, :allow_nil => true, :allow_blank => true | |
5 | +end | |
0 | 6 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,41 @@ |
1 | +module SoftwareHelper | |
2 | + def self.select_options programming_languages, selected=0 | |
3 | + value = "" | |
4 | + | |
5 | + programming_languages.each do |language| | |
6 | + value += "<option value=#{language.id} #{'selected' if selected == language.id}>#{language.name}</option>" | |
7 | + end | |
8 | + | |
9 | + value | |
10 | + end | |
11 | + | |
12 | + def self.create_list_with_file file_name, model | |
13 | + list_file = File.open file_name, "r" | |
14 | + | |
15 | + list_file.each_line do |line| | |
16 | + model.create(:name=>line.strip) | |
17 | + end | |
18 | + | |
19 | + list_file.close | |
20 | + end | |
21 | + | |
22 | + def self.all_table_is_empty? table, ignored_fields=[] | |
23 | + filled_fields = [] | |
24 | + | |
25 | + table.each do |key, value| | |
26 | + unless ignored_fields.include? key | |
27 | + filled_fields << if value.empty? | |
28 | + false | |
29 | + else | |
30 | + true | |
31 | + end | |
32 | + end | |
33 | + end | |
34 | + | |
35 | + if filled_fields.include? true | |
36 | + false | |
37 | + else | |
38 | + true | |
39 | + end | |
40 | + end | |
41 | +end | ... | ... |
... | ... | @@ -0,0 +1,63 @@ |
1 | +class SoftwareInfo < ActiveRecord::Base | |
2 | + attr_accessible :e_mag, :icp_brasil, :intern, :e_ping, :e_arq, :operating_platform, :demonstration_url, :acronym, :objectives, :features, :license_infos_id, :community_id | |
3 | + | |
4 | + has_many :libraries, :dependent => :destroy | |
5 | + has_many :software_databases | |
6 | + has_many :database_descriptions, :through => :software_databases | |
7 | + has_many :software_languages | |
8 | + has_many :operating_systems | |
9 | + has_many :programming_languages, :through => :software_languages | |
10 | + has_many :operating_system_names, :through => :operating_systems | |
11 | + | |
12 | + belongs_to :community | |
13 | + belongs_to :license_info | |
14 | + | |
15 | + has_one :controlled_vocabulary | |
16 | + | |
17 | + validate :validate_operating_platform, :validate_acronym, :valid_software_info, :valid_databases, :valid_operating_systems | |
18 | + | |
19 | + # used on find_by_contents | |
20 | + scope :like_search, lambda{ |name| | |
21 | + joins(:community).where("name ilike ?", "%#{name}%") | |
22 | + } | |
23 | + | |
24 | + def validate_operating_platform | |
25 | + self.errors.add(:operating_platform, _("can't be blank")) if self.operating_platform.blank? && self.errors.messages[:operating_platform].nil? | |
26 | + end | |
27 | + | |
28 | + def validate_acronym | |
29 | + if self.acronym.blank? && self.errors.messages[:acronym].nil? | |
30 | + self.errors.add(:acronym, _("can't be blank")) | |
31 | + elsif self.acronym.length > 8 && self.errors.messages[:acronym].nil? | |
32 | + self.errors.add(:acronym, _("can't have more than 8 characteres")) | |
33 | + end | |
34 | + end | |
35 | + | |
36 | + def valid_operating_systems | |
37 | + self.errors.add(:operating_system, _(": at least one must be filled")) if self.operating_systems.empty? | |
38 | + end | |
39 | + | |
40 | + def valid_software_info | |
41 | + self.errors.add(:software_languages, _(": at least one must be filled")) if self.software_languages.empty? | |
42 | + end | |
43 | + | |
44 | + def valid_databases | |
45 | + self.errors.add(:software_databases, _(": at least one must be filled")) if self.software_databases.empty? | |
46 | + end | |
47 | + | |
48 | + def visible? | |
49 | + self.community.visible? | |
50 | + end | |
51 | + | |
52 | + def name | |
53 | + self.community.name | |
54 | + end | |
55 | + | |
56 | + def short_name | |
57 | + self.community.short_name | |
58 | + end | |
59 | + | |
60 | + def identifier | |
61 | + self.community.identifier | |
62 | + end | |
63 | +end | ... | ... |
... | ... | @@ -0,0 +1,118 @@ |
1 | +module SoftwareLanguageHelper | |
2 | + | |
3 | + def self.list_language new_languages | |
4 | + return [] if new_languages.nil? or new_languages.length == 0 | |
5 | + list_languages = [] | |
6 | + | |
7 | + new_languages.each do |new_language| | |
8 | + unless SoftwareHelper.all_table_is_empty? new_language, ["programming_language_id"] | |
9 | + language = SoftwareLanguage.new | |
10 | + language.programming_language = ProgrammingLanguage.find(new_language[:programming_language_id]) | |
11 | + language.version = new_language[:version] | |
12 | + language.operating_system = new_language[:operating_system] | |
13 | + list_languages << language | |
14 | + end | |
15 | + end | |
16 | + | |
17 | + list_languages | |
18 | + end | |
19 | + | |
20 | + def self.valid_list_language? list_languages | |
21 | + return false if list_languages.nil? or list_languages.length == 0 | |
22 | + | |
23 | + list_languages.each do |language| | |
24 | + return false unless language.valid? | |
25 | + end | |
26 | + | |
27 | + true | |
28 | + end | |
29 | + | |
30 | + def self.language_as_tables(list_languages, have_delete_button = true, show_information = false) | |
31 | + extend( | |
32 | + ActionView::Helpers::TagHelper, | |
33 | + ActionView::Helpers::FormTagHelper, | |
34 | + ActionView::Helpers::UrlHelper, | |
35 | + ActionView::Helpers::FormOptionsHelper, | |
36 | + ApplicationHelper | |
37 | + ) | |
38 | + | |
39 | + lambdas_list = [] | |
40 | + | |
41 | + if not show_information | |
42 | + return language_html_structure({:programming_language_id => 1, :version => "", :operating_system => ""}, have_delete_button) if list_languages.nil? | |
43 | + | |
44 | + list_languages.each do |language| | |
45 | + lambdas_list << language_html_structure(language, have_delete_button) | |
46 | + end | |
47 | + | |
48 | + else | |
49 | + list_languages.each do |language| | |
50 | + lambdas_list << language_html_show_structure(language) | |
51 | + end | |
52 | + | |
53 | + end | |
54 | + | |
55 | + | |
56 | + lambdas_list | |
57 | + end | |
58 | + | |
59 | + def self.language_html_structure(language_data, have_delete_button = true) | |
60 | + Proc::new do | |
61 | + content_tag('table', | |
62 | + content_tag('tr', | |
63 | + content_tag('td', label_tag(_("Language Name: ")))+ | |
64 | + content_tag('td', select_tag("language[][programming_language_id]", SoftwareHelper.select_options(ProgrammingLanguage.all, language_data[:programming_language_id]) ))+ | |
65 | + content_tag('td') | |
66 | + )+ | |
67 | + | |
68 | + content_tag('tr', | |
69 | + content_tag('td', label_tag(_("Version")))+ | |
70 | + content_tag('td', text_field_tag("language[][version]", language_data[:version]))+ | |
71 | + content_tag('td') | |
72 | + )+ | |
73 | + | |
74 | + content_tag('tr', | |
75 | + content_tag('td', label_tag(_("Operating System")))+ | |
76 | + content_tag('td', text_field_tag("language[][operating_system]", language_data[:operating_system]))+ | |
77 | + | |
78 | + if have_delete_button | |
79 | + content_tag('td', | |
80 | + button_without_text(:delete, _('Delete'), "#" , :class=>"delete-dynamic-table"), | |
81 | + :align => 'right' | |
82 | + ) | |
83 | + else | |
84 | + content_tag('td', "") | |
85 | + end | |
86 | + ), :class => 'dynamic-table software-language-table' | |
87 | + ) | |
88 | + end | |
89 | + end | |
90 | + | |
91 | + def self.language_html_show_structure(language) | |
92 | + Proc::new do | |
93 | + content_tag('table', | |
94 | + content_tag('tr', | |
95 | + content_tag('td', label_tag(_("Language Name: ")))+ | |
96 | + content_tag('td', ProgrammingLanguage.where(:id => language[:programming_language_id])[0].name)+ | |
97 | + content_tag('td') | |
98 | + )+ | |
99 | + | |
100 | + content_tag('tr', | |
101 | + content_tag('td', label_tag(_("Version")))+ | |
102 | + content_tag('td', language[:version])+ | |
103 | + content_tag('td') | |
104 | + )+ | |
105 | + | |
106 | + content_tag('tr', | |
107 | + content_tag('td', label_tag(_("Operating System")))+ | |
108 | + content_tag('td', language[:operating_system])+ | |
109 | + content_tag('td', "") | |
110 | + ), :class => 'dynamic-table software-language-table' | |
111 | + ) | |
112 | + end | |
113 | + end | |
114 | + | |
115 | + def self.add_dynamic_table | |
116 | + language_as_tables(nil).call | |
117 | + end | |
118 | +end | ... | ... |
... | ... | @@ -0,0 +1,129 @@ |
1 | +(function(){ | |
2 | + function open_create_institution_modal(evt) { | |
3 | + evt.preventDefault(); | |
4 | + | |
5 | + jQuery.get("/plugin/mpog_software/create_institution", function(response){ | |
6 | + jQuery("#institution_dialog").html(response); | |
7 | + set_events(); | |
8 | + | |
9 | + jQuery("#institution_dialog").dialog({ | |
10 | + modal: true, | |
11 | + width: 500, | |
12 | + height: 530, | |
13 | + position: 'center', | |
14 | + close: function() { | |
15 | + jQuery("#institution_dialog").html(""); | |
16 | + jQuery('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); | |
17 | + } | |
18 | + }); | |
19 | + }); | |
20 | + } | |
21 | + | |
22 | + function show_public_institutions_fields() { | |
23 | + jQuery(".public-institutions-fields").show(); | |
24 | + jQuery("label[for='institutions_acronym']").html(jQuery("#acronym_translate").val()); | |
25 | + } | |
26 | + | |
27 | + function show_private_institutions_fields() { | |
28 | + jQuery(".public-institutions-fields").hide(); | |
29 | + jQuery("label[for='institutions_acronym']").html(jQuery("#fantasy_name_translate").val()); | |
30 | + | |
31 | + jQuery("#institutions_governmental_power option").selected(0); | |
32 | + jQuery("#institutions_governmental_sphere option").selected(0); | |
33 | + } | |
34 | + | |
35 | + function get_selected_institution_type() { | |
36 | + var radio_buttons = jQuery("input[type='radio'][name='type']"); | |
37 | + var type = ""; | |
38 | + | |
39 | + for( var i = 0; i < radio_buttons.length; i++ ) { | |
40 | + if( radio_buttons[i].checked ) { | |
41 | + type = radio_buttons[i].value; | |
42 | + break; | |
43 | + } | |
44 | + } | |
45 | + | |
46 | + return type; | |
47 | + } | |
48 | + | |
49 | + function get_post_data() { | |
50 | + return { | |
51 | + community : { name : jQuery("#community_name").val()}, | |
52 | + governmental : { | |
53 | + power : jQuery("#institutions_governmental_power").selected().val(), | |
54 | + sphere : jQuery("#institutions_governmental_sphere").selected().val() | |
55 | + } , | |
56 | + institution : { | |
57 | + cnpj: jQuery("#institutions_cnpj").val(), | |
58 | + type: get_selected_institution_type(), | |
59 | + acronym : jQuery("#institutions_acronym").val() | |
60 | + }, | |
61 | + authenticity_token : jQuery("input[name='authenticity_token']").val(), | |
62 | + recaptcha_response_field : jQuery('#recaptcha_response_field').val(), | |
63 | + recaptcha_challenge_field : jQuery('#recaptcha_challenge_field').val() | |
64 | + } | |
65 | + } | |
66 | + | |
67 | + function success_ajax_response(response) { | |
68 | + close_loading(); | |
69 | + if(response.success){ | |
70 | + jQuery("#institution_dialog").html("<div class='errorExplanation'><h2>"+response.message+"</h2></div>"); | |
71 | + jQuery("#input_institution").val(response.institution_data.name); | |
72 | + jQuery("#user_institution_id").val(response.institution_data.id); | |
73 | + jQuery("#create_institution_errors").switchClass("show-field", "hide-field"); | |
74 | + } else { | |
75 | + var errors = "<ul>"; | |
76 | + | |
77 | + for(var i = 0; i < response.errors.length; i++) { | |
78 | + errors += "<li>"+response.errors[i]+"</li>"; | |
79 | + } | |
80 | + errors += "</ul>"; | |
81 | + | |
82 | + jQuery("#create_institution_errors").switchClass("hide-field", "show-field").html("<h2>"+response.message+"</h2>"+errors); | |
83 | + } | |
84 | + } | |
85 | + | |
86 | + function save_institution(evt) { | |
87 | + evt.preventDefault(); | |
88 | + var form_data = jQuery("#institution_form").serialize(); | |
89 | + | |
90 | + open_loading(jQuery("#loading_message").val()); | |
91 | + jQuery.ajax({ | |
92 | + url: "/plugin/mpog_software/new_institution", | |
93 | + data : get_post_data(), | |
94 | + type: "POST", | |
95 | + success: success_ajax_response, | |
96 | + error: function() { | |
97 | + close_loading(); | |
98 | + var error_message = jQuery("#institution_error_message").val(); | |
99 | + jQuery("#create_institution_errors").switchClass("hide-field", "show-field").html("<h2>"+error_message+"</h2>"); | |
100 | + } | |
101 | + }); | |
102 | + } | |
103 | + | |
104 | + function institution_already_exists(){ | |
105 | + if( this.value.length >= 3 ) { | |
106 | + jQuery.get("/plugin/mpog_software/institution_already_exists", {name:this.value}, function(response){ | |
107 | + if( response == true ) { | |
108 | + jQuery("#already_exists_text").switchClass("hide-field", "show-field"); | |
109 | + } else { | |
110 | + jQuery("#already_exists_text").switchClass("show-field", "hide-field"); | |
111 | + } | |
112 | + }); | |
113 | + } | |
114 | + } | |
115 | + | |
116 | + function set_events() { | |
117 | + jQuery("#create_institution_link").click(open_create_institution_modal); | |
118 | + | |
119 | + jQuery("#type_PrivateInstitution").click(show_private_institutions_fields); | |
120 | + | |
121 | + jQuery("#type_PublicInstitution").click(show_public_institutions_fields); | |
122 | + | |
123 | + jQuery('#save_institution_button').click(save_institution); | |
124 | + | |
125 | + jQuery("#community_name").keyup(institution_already_exists); | |
126 | + } | |
127 | + | |
128 | + jQuery(document).ready(set_events); | |
129 | +})(); | |
0 | 130 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,159 @@ |
1 | +function delete_dynamic_table() { | |
2 | + var button = jQuery(".delete-dynamic-table"); | |
3 | + | |
4 | + button.each(function(){ | |
5 | + var table = jQuery(this).parent().parent().parent().parent(); | |
6 | + var color = table.css("background-color"); | |
7 | + | |
8 | + jQuery(this).click(function(){ | |
9 | + if( table.hasClass("software-language-table") && has_more_than_one("software-language-table")) | |
10 | + table.remove(); | |
11 | + | |
12 | + if( table.hasClass("database-table") && has_more_than_one("database-table")) | |
13 | + table.remove(); | |
14 | + | |
15 | + if( !table.hasClass("software-language-table") && !table.hasClass("database-table") ) | |
16 | + table.remove(); | |
17 | + | |
18 | + return false; | |
19 | + }).mouseover(function(){ | |
20 | + table.css("background-color", "#eee"); | |
21 | + }).mouseout(function(){ | |
22 | + table.css("background-color", color); | |
23 | + }); | |
24 | + }); | |
25 | +} | |
26 | + | |
27 | +function has_more_than_one(table_class) { | |
28 | + return (jQuery("."+table_class).length > 2); // One is always added by defaul and its hidden | |
29 | +} | |
30 | + | |
31 | +function add_dynamic_table(element_id, content) { | |
32 | + Element.insert(element_id, {bottom: content}); | |
33 | +} | |
34 | + | |
35 | +function get_license_link(select_id){ | |
36 | + var selected = jQuery('#'+select_id).selected().val(); | |
37 | + var link = jQuery("#version_" + selected).val(); | |
38 | + | |
39 | + jQuery("#version_link") | |
40 | + .attr("href", link) | |
41 | + .text(link); | |
42 | +} | |
43 | + | |
44 | +function hide_infos(){ | |
45 | + jQuery(".language-info").hide(); | |
46 | + jQuery(".database-info").hide(); | |
47 | + jQuery(".libraries-info").hide(); | |
48 | + jQuery(".operating-system-info").hide(); | |
49 | + jQuery(".language-button-hide").hide(); | |
50 | + jQuery(".database-button-hide").hide(); | |
51 | + jQuery(".libraries-button-hide").hide(); | |
52 | + jQuery(".operating-system-button-hide").hide(); | |
53 | + | |
54 | + | |
55 | +} | |
56 | + | |
57 | +function animate_fields() { | |
58 | + jQuery(".expand-field").focus(function(){ | |
59 | + jQuery(this).switchClass("expand-field", "expand-field-focus", 700, "easeInOutQuad"); | |
60 | + }).blur(function(){ | |
61 | + jQuery(this).switchClass("expand-field-focus", "expand-field", 700, "easeInOutQuad"); | |
62 | + }); | |
63 | +} | |
64 | + | |
65 | + | |
66 | +jQuery(document).ready(function(){ | |
67 | + var dynamic_tables = ["dynamic-databases", "dynamic-languages", "dynamic-libraries","dynamic-operating_systems"]; | |
68 | + | |
69 | + delete_dynamic_table(); | |
70 | + | |
71 | + jQuery(".new-dynamic-table").click(function(){ | |
72 | + var link = jQuery(this); | |
73 | + | |
74 | + dynamic_tables.each(function(value){ | |
75 | + if( link.hasClass(value) ) { | |
76 | + var table_id = value.split("-")[1]; | |
77 | + | |
78 | + var table_html = jQuery("#table_structure_"+table_id).html(); | |
79 | + add_dynamic_table(table_id, table_html); | |
80 | + } | |
81 | + }); | |
82 | + | |
83 | + delete_dynamic_table(); | |
84 | + return false; | |
85 | + }); | |
86 | + | |
87 | + hide_infos(); | |
88 | + | |
89 | + jQuery(".language-button-hide").click(function(event){ | |
90 | + event.preventDefault(); | |
91 | + jQuery(".language-info").hide(); | |
92 | + jQuery(".language-button-show").show(); | |
93 | + jQuery(".language-button-hide").hide(); | |
94 | + }); | |
95 | + | |
96 | + jQuery(".language-button-show").click(function(event){ | |
97 | + event.preventDefault(); | |
98 | + jQuery(".language-info").show(); | |
99 | + jQuery(".language-button-show").hide(); | |
100 | + jQuery(".language-button-hide").show(); | |
101 | + }); | |
102 | + | |
103 | + jQuery(".operating-system-button-hide").click(function(event){ | |
104 | + event.preventDefault(); | |
105 | + jQuery(".operating-system-info").hide(); | |
106 | + jQuery(".operating-system-button-show").show(); | |
107 | + jQuery(".operating-system-button-hide").hide(); | |
108 | + }); | |
109 | + | |
110 | + jQuery(".operating-system-button-show").click(function(event){ | |
111 | + event.preventDefault(); | |
112 | + jQuery(".operating-system-info").show(); | |
113 | + jQuery(".operating-system-button-show").hide(); | |
114 | + jQuery(".operating-system-button-hide").show(); | |
115 | + }); | |
116 | + | |
117 | + jQuery(".database-button-hide").click(function(event){ | |
118 | + event.preventDefault(); | |
119 | + jQuery(".database-info").hide(); | |
120 | + jQuery(".database-button-show").show(); | |
121 | + jQuery(".database-button-hide").hide(); | |
122 | + }); | |
123 | + | |
124 | + jQuery(".database-button-show").click(function(event){ | |
125 | + event.preventDefault(); | |
126 | + jQuery(".database-info").show(); | |
127 | + jQuery(".database-button-show").hide(); | |
128 | + jQuery(".database-button-hide").show(); | |
129 | + }); | |
130 | + | |
131 | + jQuery(".libraries-button-hide").click(function(event){ | |
132 | + event.preventDefault(); | |
133 | + jQuery(".libraries-info").hide(); | |
134 | + jQuery(".libraries-button-show").show(); | |
135 | + jQuery(".libraries-button-hide").hide(); | |
136 | + }); | |
137 | + | |
138 | + jQuery(".libraries-button-show").click(function(event){ | |
139 | + event.preventDefault(); | |
140 | + jQuery(".libraries-info").show(); | |
141 | + jQuery(".libraries-button-show").hide(); | |
142 | + jQuery(".libraries-button-hide").show(); | |
143 | + }); | |
144 | + | |
145 | + jQuery(".operating_systems-button-hide").click(function(event){ | |
146 | + event.preventDefault(); | |
147 | + jQuery(".operating_systems-info").hide(); | |
148 | + jQuery(".operating_systems-button-show").show(); | |
149 | + jQuery(".operating_systems-button-hide").hide(); | |
150 | + }); | |
151 | + | |
152 | + jQuery(".operating_systems-button-show").click(function(event){ | |
153 | + event.preventDefault(); | |
154 | + jQuery(".operating_systems-info").show(); | |
155 | + jQuery(".operating_systems-button-show").hide(); | |
156 | + jQuery(".operating_systems-button-hide").show(); | |
157 | + }); | |
158 | + animate_fields(); | |
159 | +}); | ... | ... |
... | ... | @@ -0,0 +1,112 @@ |
1 | +function check_reactivate_account(value, input_object){ | |
2 | + jQuery.ajax({ | |
3 | + url : "/plugin/mpog_software/check_reactivate_account", | |
4 | + type: "GET", | |
5 | + data: { "email": value }, | |
6 | + success: function(response) { | |
7 | + if( jQuery("#forgot_link").length == 0 ) | |
8 | + jQuery(input_object).parent().append(response); | |
9 | + else | |
10 | + jQuery("#forgot_link").html(response); | |
11 | + }, | |
12 | + error: function(type, err, message) { | |
13 | + console.log(type+" -- "+err+" -- "+message); | |
14 | + } | |
15 | + }); | |
16 | +} | |
17 | + | |
18 | +function put_brazil_based_on_email(){ | |
19 | + var suffixes = ['gov.br', 'jus.br', 'leg.br', 'mp.br']; | |
20 | + var value = this.value; | |
21 | + var input_object = this; | |
22 | + | |
23 | + suffixes.each(function(suffix){ | |
24 | + var has_suffix = new RegExp("(.*)"+suffix+"$", "i"); | |
25 | + | |
26 | + if( has_suffix.test(value) ) | |
27 | + jQuery("#profile_data_country").val("BR"); | |
28 | + }); | |
29 | + | |
30 | + check_reactivate_account(value, input_object) | |
31 | +} | |
32 | + | |
33 | +function validate_email_format(){ | |
34 | + var correct_format_regex = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/; | |
35 | + | |
36 | + if( this.value.length > 0 ) { | |
37 | + if(correct_format_regex.test(this.value)) | |
38 | + this.className = "validated"; | |
39 | + else | |
40 | + this.className = "invalid"; | |
41 | + } else | |
42 | + this.className = ""; | |
43 | +} | |
44 | + | |
45 | +function institution_autocomplete() { | |
46 | + jQuery("#input_institution").autocomplete({ | |
47 | + source : function(request, response){ | |
48 | + jQuery.ajax({ | |
49 | + type: "GET", | |
50 | + url: "/plugin/mpog_software/get_institutions", | |
51 | + data: {query: request.term}, | |
52 | + success: function(result){ | |
53 | + response(result); | |
54 | + | |
55 | + if( result.length == 0 ) { | |
56 | + jQuery('#institution_empty_ajax_message').switchClass("hide-field", "show-field"); | |
57 | + } else { | |
58 | + jQuery('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); | |
59 | + } | |
60 | + }, | |
61 | + error: function(ajax, stat, errorThrown) { | |
62 | + console.log('Link not found : ' + errorThrown); | |
63 | + } | |
64 | + }); | |
65 | + }, | |
66 | + | |
67 | + minLength: 2, | |
68 | + | |
69 | + select : function (event, selected) { | |
70 | + jQuery("#user_institution_id").val(selected.item.id); | |
71 | + } | |
72 | + }); | |
73 | +} | |
74 | + | |
75 | + | |
76 | +function hide_incomplete_percentage(evt) { | |
77 | + evt.preventDefault(); | |
78 | + var link_div = jQuery(this).parent(); | |
79 | + | |
80 | + jQuery.get("/plugin/mpog_software/hide_registration_incomplete_percentage", {hide:true}, function(response){ | |
81 | + if( response == true ) | |
82 | + link_div.hide(); | |
83 | + }); | |
84 | +} | |
85 | + | |
86 | +jQuery(document).ready(function(){ | |
87 | + jQuery('#secondary_email_field').blur( | |
88 | + validate_email_format | |
89 | + ); | |
90 | + | |
91 | + jQuery("#user_email").blur( | |
92 | + put_brazil_based_on_email | |
93 | + ); | |
94 | + | |
95 | + jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); | |
96 | + | |
97 | + jQuery('#secondary_email_field').focus(function() { jQuery('#secondary-email-balloon').fadeIn('slow'); }); | |
98 | + jQuery('#secondary_email_field').blur(function() { jQuery('#secondary-email-balloon').fadeOut('slow'); }); | |
99 | + | |
100 | + jQuery('#role_field').focus(function() { jQuery('#role-balloon').fadeIn('slow'); }); | |
101 | + jQuery('#role_field').blur(function() { jQuery('#role-balloon').fadeOut('slow'); }); | |
102 | + | |
103 | + jQuery('#area_interest_field').focus(function() { jQuery('#area-interest-balloon').fadeIn('slow'); }); | |
104 | + jQuery('#area_interest_field').blur(function() { jQuery('#area-interest-balloon').fadeOut('slow'); }); | |
105 | + | |
106 | + institution_autocomplete(); | |
107 | + | |
108 | + jQuery("#input_institution").blur(function(){ | |
109 | + if( this.value == "" ) | |
110 | + jQuery("#user_institution_id").val(""); | |
111 | + }); | |
112 | +}); | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | +Array.prototype.removeValue = function(value) { | |
2 | + for (var i = 0; i < this.length; i++) { | |
3 | + if (this[i] === value) { | |
4 | + this.splice(i, 1); | |
5 | + i--; | |
6 | + } | |
7 | + } | |
8 | + | |
9 | + return this; | |
10 | +} | |
11 | + | |
12 | +Array.prototype.removeIndex = function(index) { | |
13 | + this.splice(index, 1); | |
14 | + | |
15 | + return this; | |
16 | +} | ... | ... |
... | ... | @@ -0,0 +1,176 @@ |
1 | +4th Dimension | |
2 | +Adabas D | |
3 | +Aerospike | |
4 | +AllegroGraph | |
5 | +Alpha Five | |
6 | +Altibase | |
7 | +Amazon DynamoDB | |
8 | +Apache Accumulo | |
9 | +Apache Cassandra | |
10 | +Apache CouchDB | |
11 | +Apache Derby | |
12 | +Apache Hbase | |
13 | +Apache JENA | |
14 | +Apache River | |
15 | +Aster Data | |
16 | +BaseX | |
17 | +Berkeley DB | |
18 | +BigTable | |
19 | +BlackRay | |
20 | +CA-Datacom | |
21 | +CDB | |
22 | +CSQL | |
23 | +CUBRID | |
24 | +Clarion | |
25 | +Cloudant | |
26 | +Cloudant Data Layer (CouchDB) | |
27 | +Clusterpoint | |
28 | +Clusterpoint XML database | |
29 | +Clustrix | |
30 | +Coherence | |
31 | +CoreFoundation Property list | |
32 | +Couchbase Server | |
33 | +D3 Pick database | |
34 | +DEX/Sparksee | |
35 | +Daffodil database | |
36 | +DataEase | |
37 | +Database Management Library | |
38 | +Dataphor | |
39 | +Datastore on Google Appengine | |
40 | +Derby aka Java DB | |
41 | +Dynamo | |
42 | +EXASolution | |
43 | +ElasticSearch | |
44 | +Empress Embedded Database | |
45 | +EnterpriseDB | |
46 | +Extensible Storage Engine (ESE/NT) | |
47 | +FileMaker Pro | |
48 | +Firebird | |
49 | +FlockDB | |
50 | +FoundationDB | |
51 | +Freebase | |
52 | +GT.M | |
53 | +GemStone/S | |
54 | +GigaSpaces | |
55 | +Greenplum | |
56 | +GroveSite | |
57 | +H2 | |
58 | +HSQLDB | |
59 | +Hazelcast | |
60 | +Helix database | |
61 | +Hibari | |
62 | +Hypertable | |
63 | +IBM DB2 | |
64 | +IBM DB2 Express-C | |
65 | +IBM Informix C-ISAM | |
66 | +IBM Lotus Approach | |
67 | +IBM Notes and IBM Domino | |
68 | +InfiniteGraph | |
69 | +InfinityDB | |
70 | +Infobright | |
71 | +Informix | |
72 | +Ingres | |
73 | +InterBase | |
74 | +InterSystems Caché | |
75 | +JADE | |
76 | +Jackrabbit | |
77 | +Keyspace | |
78 | +LevelDB | |
79 | +Linter | |
80 | +MariaDB | |
81 | +MarkLogic | |
82 | +MarkLogic Server | |
83 | +MaxDB | |
84 | +MemSQL | |
85 | +MemcacheDB | |
86 | +Microsoft Access | |
87 | +Microsoft Jet Database Engine | |
88 | +Microsoft SQL Server | |
89 | +Microsoft SQL Server Express | |
90 | +Microsoft Visual FoxPro | |
91 | +Mimer SQL | |
92 | +Mnesia | |
93 | +MonetDB | |
94 | +MongoDB | |
95 | +MySQL | |
96 | +NDBM | |
97 | +Neo4j | |
98 | +NeoDatis ODB | |
99 | +Netezza | |
100 | +NexusDB | |
101 | +NonStop SQL | |
102 | +ODABA | |
103 | +OWLIM | |
104 | +Object database | |
105 | +ObjectDB | |
106 | +ObjectDatabase++ | |
107 | +ObjectStore | |
108 | +Objectivity/DB | |
109 | +Ontotext-OWLIM | |
110 | +OpenLink Virtuoso | |
111 | +OpenLink Virtuoso Universal Server | |
112 | +OpenOffice.org Base | |
113 | +OpenQM | |
114 | +Openbase | |
115 | +Oracle | |
116 | +Oracle NoSQL Database | |
117 | +Oracle Rdb for OpenVMS | |
118 | +OrientDB | |
119 | +Panorama | |
120 | +Perst | |
121 | +Pervasive PSQL | |
122 | +Polyhedra | |
123 | +PostgreSQL | |
124 | +Postgres Plus Advanced Server | |
125 | +Progress Software | |
126 | +R:Base | |
127 | +RDM Embedded | |
128 | +RDM Server | |
129 | +Revelation Software's OpenInsight | |
130 | +Riak | |
131 | +Rocket U2 | |
132 | +SAND CDBMS | |
133 | +SAP HANA | |
134 | +SAP Sybase Adaptive Server Enterprise | |
135 | +SAP Sybase IQ | |
136 | +SQL Anywhere | |
137 | +SQLBase | |
138 | +SQLite | |
139 | +ScimoreDB | |
140 | +Sedna | |
141 | +SimpleDB | |
142 | +SmallSQL | |
143 | +Solr | |
144 | +Sones GraphDB | |
145 | +SparkleDB | |
146 | +Sqrrl Enterprise | |
147 | +Sybase Advantage Database Server | |
148 | +Tarantool | |
149 | +Teradata | |
150 | +The SAS system | |
151 | +TimesTen | |
152 | +TokuMX | |
153 | +Tokyo Cabinet | |
154 | +Tuple space | |
155 | +UniData | |
156 | +UniVerse | |
157 | +Unisys RDMS 2200 | |
158 | +VMDS | |
159 | +Vectorwise | |
160 | +Versant Object Database | |
161 | +Vertica | |
162 | +Virtuoso Universal Server | |
163 | +WakandaDB | |
164 | +XAP | |
165 | +ZODB | |
166 | +dBase | |
167 | +db4o | |
168 | +djondb | |
169 | +eXist | |
170 | +eXtremeDB | |
171 | +mSQL | |
172 | +memcached | |
173 | +mizanSQL | |
174 | +redis | |
175 | +solidDB | |
176 | +txtSQL | ... | ... |
... | ... | @@ -0,0 +1,673 @@ |
1 | +A# | |
2 | +A-0 System | |
3 | +A+ | |
4 | +A++ | |
5 | +ABAP | |
6 | +ABC | |
7 | +ABC ALGOL | |
8 | +ABLE | |
9 | +ABSET | |
10 | +ABSYS | |
11 | +ACC | |
12 | +Accent | |
13 | +Ace DASL | |
14 | +ACL2 | |
15 | +ACT-III | |
16 | +Action! | |
17 | +ActionScript | |
18 | +Ada | |
19 | +Adenine | |
20 | +Agda | |
21 | +Agilent VEE | |
22 | +Agora | |
23 | +AIMMS | |
24 | +Alef | |
25 | +ALF | |
26 | +ALGOL 58 | |
27 | +ALGOL 60 | |
28 | +ALGOL 68 | |
29 | +ALGOL W | |
30 | +Alice | |
31 | +Alma-0 | |
32 | +AmbientTalk | |
33 | +Amiga E | |
34 | +AMOS | |
35 | +AMPL | |
36 | +APL | |
37 | +AppleScript | |
38 | +Arc | |
39 | +ARexx | |
40 | +Argus | |
41 | +AspectJ | |
42 | +Assembly language | |
43 | +ATS | |
44 | +Ateji PX | |
45 | +AutoHotkey | |
46 | +Autocoder | |
47 | +AutoIt | |
48 | +AutoLISP / Visual LISP | |
49 | +Averest | |
50 | +AWK | |
51 | +Axum | |
52 | +B | |
53 | +Babbage | |
54 | +BAIL | |
55 | +Bash | |
56 | +BASIC | |
57 | +bc | |
58 | +BCPL | |
59 | +BeanShell | |
60 | +Batch | |
61 | +Bertrand | |
62 | +BETA | |
63 | +Bigwig | |
64 | +Bistro | |
65 | +BitC | |
66 | +BLISS | |
67 | +Blue | |
68 | +Bon | |
69 | +Boo | |
70 | +Boomerang | |
71 | +Bourne shell | |
72 | +BREW | |
73 | +BPEL | |
74 | +BuildProfessional | |
75 | +C | |
76 | +C-- | |
77 | +C++ | |
78 | +C# | |
79 | +C/AL | |
80 | +Caché ObjectScript | |
81 | +C Shell | |
82 | +Caml | |
83 | +Candle | |
84 | +Cayenne | |
85 | +CDuce | |
86 | +Cecil | |
87 | +Cel | |
88 | +Cesil | |
89 | +Ceylon | |
90 | +CFML | |
91 | +Cg | |
92 | +Ch | |
93 | +Chapel | |
94 | +CHAIN | |
95 | +Charity | |
96 | +Charm | |
97 | +Chef | |
98 | +CHILL | |
99 | +CHIP-8 | |
100 | +chomski | |
101 | +ChucK | |
102 | +CICS | |
103 | +Cilk | |
104 | +CL (IBM) | |
105 | +Claire | |
106 | +Clarion | |
107 | +Clean | |
108 | +Clipper | |
109 | +CLIST | |
110 | +Clojure | |
111 | +CLU | |
112 | +CMS-2 | |
113 | +COBOL | |
114 | +Cobra | |
115 | +CODE | |
116 | +CoffeeScript | |
117 | +Cola | |
118 | +ColdC | |
119 | +ColdFusion | |
120 | +Cool | |
121 | +COMAL | |
122 | +Combined Programming Language | |
123 | +Common Intermediate Language | |
124 | +Common Lisp | |
125 | +COMPASS | |
126 | +Component Pascal | |
127 | +COMIT | |
128 | +Constraint Handling Rules | |
129 | +Converge | |
130 | +Coral 66 | |
131 | +Corn | |
132 | +CorVision | |
133 | +Coq | |
134 | +COWSEL | |
135 | +CPL | |
136 | +csh | |
137 | +CSP | |
138 | +Csound | |
139 | +Curl | |
140 | +Curry | |
141 | +Cyclone | |
142 | +Cython | |
143 | +D | |
144 | +DASL | |
145 | +Dart | |
146 | +DataFlex | |
147 | +Datalog | |
148 | +DATATRIEVE | |
149 | +dBase | |
150 | +dc | |
151 | +Deesel | |
152 | +Delphi | |
153 | +DCL | |
154 | +DinkC | |
155 | +DIBOL | |
156 | +Dog | |
157 | +Draco | |
158 | +DRAKON | |
159 | +Dylan | |
160 | +DYNAMO | |
161 | +E | |
162 | +E# | |
163 | +Ease | |
164 | +Easy PL/I | |
165 | +EASYTRIEVE PLUS | |
166 | +ECMAScript | |
167 | +Edinburgh IMP | |
168 | +EGL | |
169 | +Eiffel | |
170 | +ELAN | |
171 | +Elixir | |
172 | +Elm | |
173 | +Emacs Lisp | |
174 | +Emerald | |
175 | +Epigram | |
176 | +Erlang | |
177 | +es | |
178 | +Escapade | |
179 | +Escher | |
180 | +ESPOL | |
181 | +Esterel | |
182 | +Etoys | |
183 | +Euclid | |
184 | +Euler | |
185 | +Euphoria | |
186 | +EusLisp | |
187 | +CMS EXEC | |
188 | +EXEC 2 | |
189 | +Executable UML | |
190 | +F | |
191 | +F# | |
192 | +Factor | |
193 | +Falcon | |
194 | +Fancy | |
195 | +Fantom | |
196 | +FAUST | |
197 | +Felix | |
198 | +Ferite | |
199 | +FFP | |
200 | +Fjölnir | |
201 | +FL | |
202 | +Flavors | |
203 | +Flex | |
204 | +FLOW-MATIC | |
205 | +FOCAL | |
206 | +FOCUS | |
207 | +FOIL | |
208 | +FORMAC | |
209 | +@Formula | |
210 | +Forth | |
211 | +Fortran | |
212 | +Fortress | |
213 | +FoxBase | |
214 | +FoxPro | |
215 | +FP | |
216 | +FPr | |
217 | +Franz Lisp | |
218 | +F-Script | |
219 | +FSProg | |
220 | +G | |
221 | +Game Maker Language | |
222 | +GameMonkey Script | |
223 | +GAMS | |
224 | +GAP | |
225 | +G-code | |
226 | +Genie | |
227 | +GDL | |
228 | +Gibiane | |
229 | +GJ | |
230 | +GEORGE | |
231 | +GLSL | |
232 | +GNU E | |
233 | +GM | |
234 | +Go | |
235 | +Go! | |
236 | +GOAL | |
237 | +Gödel | |
238 | +Godiva | |
239 | +GOM | |
240 | +Goo | |
241 | +Gosu | |
242 | +GOTRAN | |
243 | +GPSS | |
244 | +GraphTalk | |
245 | +GRASS | |
246 | +Groovy | |
247 | +Hack | |
248 | +HAL/S | |
249 | +Hamilton C shell | |
250 | +Harbour | |
251 | +Hartmann pipelines | |
252 | +Haskell | |
253 | +Haxe | |
254 | +High Level Assembly | |
255 | +HLSL | |
256 | +Hop | |
257 | +Hope | |
258 | +Hugo | |
259 | +Hume | |
260 | +HyperTalk | |
261 | +IBM Basic assembly language | |
262 | +IBM HAScript | |
263 | +IBM Informix-4GL | |
264 | +IBM RPG | |
265 | +ICI | |
266 | +Icon | |
267 | +Id | |
268 | +IDL | |
269 | +Idris | |
270 | +IMP | |
271 | +Inform | |
272 | +Io | |
273 | +Ioke | |
274 | +IPL | |
275 | +IPTSCRAE | |
276 | +ISLISP | |
277 | +ISPF | |
278 | +ISWIM | |
279 | +J | |
280 | +J# | |
281 | +J++ | |
282 | +JADE | |
283 | +Jako | |
284 | +JAL | |
285 | +Janus | |
286 | +JASS | |
287 | +Java | |
288 | +JavaScript | |
289 | +JCL | |
290 | +JEAN | |
291 | +Join Java | |
292 | +JOSS | |
293 | +Joule | |
294 | +JOVIAL | |
295 | +Joy | |
296 | +JScript | |
297 | +JavaFX Script | |
298 | +Julia | |
299 | +K | |
300 | +Kaleidoscope | |
301 | +Karel | |
302 | +Karel++ | |
303 | +KEE | |
304 | +KIF | |
305 | +Kojo | |
306 | +Kotlin | |
307 | +KRC | |
308 | +KRL | |
309 | +KRYPTON | |
310 | +ksh | |
311 | +L | |
312 | +L# | |
313 | +LabVIEW | |
314 | +Ladder | |
315 | +Lagoona | |
316 | +LANSA | |
317 | +Lasso | |
318 | +LaTeX | |
319 | +Lava | |
320 | +LC-3 | |
321 | +Leadwerks Script | |
322 | +Leda | |
323 | +Legoscript | |
324 | +LIL | |
325 | +LilyPond | |
326 | +Limbo | |
327 | +Limnor | |
328 | +LINC | |
329 | +Lingo | |
330 | +Linoleum | |
331 | +LIS | |
332 | +LISA | |
333 | +Lisaac | |
334 | +Lisp | |
335 | +Lite-C | |
336 | +Lithe | |
337 | +Little b | |
338 | +Logo | |
339 | +Logtalk | |
340 | +LPC | |
341 | +LSE | |
342 | +LSL | |
343 | +LiveCode | |
344 | +LiveScript | |
345 | +Lua | |
346 | +Lucid | |
347 | +Lustre | |
348 | +LYaPAS | |
349 | +Lynx | |
350 | +M | |
351 | +M2001 | |
352 | +M4 | |
353 | +Machine code | |
354 | +MAD | |
355 | +MAD/I | |
356 | +Magik | |
357 | +Magma | |
358 | +make | |
359 | +Maple | |
360 | +MAPPER | |
361 | +MARK-IV | |
362 | +Mary | |
363 | +MASM | |
364 | +Mathematica | |
365 | +MATLAB | |
366 | +Maxima | |
367 | +Max | |
368 | +MaxScript | |
369 | +Maya | |
370 | +MDL | |
371 | +Mercury | |
372 | +Mesa | |
373 | +Metacard | |
374 | +Metafont | |
375 | +MetaL | |
376 | +Microcode | |
377 | +MicroScript | |
378 | +MIIS | |
379 | +MillScript | |
380 | +MIMIC | |
381 | +Mirah | |
382 | +Miranda | |
383 | +MIVA Script | |
384 | +ML | |
385 | +Moby | |
386 | +Model 204 | |
387 | +Modelica | |
388 | +Modula | |
389 | +Modula-2 | |
390 | +Modula-3 | |
391 | +Mohol | |
392 | +MOO | |
393 | +Mortran | |
394 | +Mouse | |
395 | +MPD | |
396 | +MSIL | |
397 | +MSL | |
398 | +MUMPS | |
399 | +NASM | |
400 | +NATURAL | |
401 | +Napier88 | |
402 | +Neko | |
403 | +Nemerle | |
404 | +nesC | |
405 | +NESL | |
406 | +Net.Data | |
407 | +NetLogo | |
408 | +NetRexx | |
409 | +NewLISP | |
410 | +NEWP | |
411 | +Newspeak | |
412 | +NewtonScript | |
413 | +NGL | |
414 | +Nial | |
415 | +Nice | |
416 | +Nickle | |
417 | +NPL | |
418 | +Not eXactly C | |
419 | +Not Quite C | |
420 | +NSIS | |
421 | +Nu | |
422 | +NWScript | |
423 | +o:XML | |
424 | +Oak | |
425 | +Oberon | |
426 | +Obix | |
427 | +OBJ2 | |
428 | +Object Lisp | |
429 | +ObjectLOGO | |
430 | +Object REXX | |
431 | +Object Pascal | |
432 | +Objective-C | |
433 | +Objective-J | |
434 | +Obliq | |
435 | +Obol | |
436 | +OCaml | |
437 | +occam | |
438 | +occam-π | |
439 | +Octave | |
440 | +OmniMark | |
441 | +Onyx | |
442 | +Opa | |
443 | +Opal | |
444 | +OpenEdge ABL | |
445 | +OPL | |
446 | +OPS5 | |
447 | +OptimJ | |
448 | +Orc | |
449 | +ORCA/Modula-2 | |
450 | +Oriel | |
451 | +Orwell | |
452 | +Oxygene | |
453 | +Oz | |
454 | +P# | |
455 | +PARI/GP | |
456 | +Pascal | |
457 | +Pawn | |
458 | +PCASTL | |
459 | +PCF | |
460 | +PEARL | |
461 | +PeopleCode | |
462 | +Perl | |
463 | +PDL | |
464 | +PHP | |
465 | +Phrogram | |
466 | +Pico | |
467 | +Pict | |
468 | +Pike | |
469 | +PIKT | |
470 | +PILOT | |
471 | +Pipelines | |
472 | +Pizza | |
473 | +PL-11 | |
474 | +PL/0 | |
475 | +PL/B | |
476 | +PL/C | |
477 | +PL/I | |
478 | +PL/M | |
479 | +PL/P | |
480 | +PL/SQL | |
481 | +PL360 | |
482 | +PLANC | |
483 | +Plankalkül | |
484 | +PLEX | |
485 | +PLEXIL | |
486 | +Plus | |
487 | +POP-11 | |
488 | +PostScript | |
489 | +PortablE | |
490 | +Powerhouse | |
491 | +PowerBuilder | |
492 | +PowerShell | |
493 | +PPL | |
494 | +Processing | |
495 | +Processing.js | |
496 | +Prograph | |
497 | +PROIV | |
498 | +Prolog | |
499 | +Visual Prolog | |
500 | +Promela | |
501 | +PROSE modeling language | |
502 | +PROTEL | |
503 | +ProvideX | |
504 | +Pro*C | |
505 | +Pure | |
506 | +Python | |
507 | +Q | |
508 | +Qalb | |
509 | +Qi | |
510 | +QtScript | |
511 | +QuakeC | |
512 | +QPL | |
513 | +R | |
514 | +R++ | |
515 | +Racket | |
516 | +RAPID | |
517 | +Rapira | |
518 | +Ratfiv | |
519 | +Ratfor | |
520 | +rc | |
521 | +REBOL | |
522 | +Red | |
523 | +Redcode | |
524 | +REFAL | |
525 | +Reia | |
526 | +Revolution | |
527 | +rex | |
528 | +REXX | |
529 | +Rlab | |
530 | +RobotC | |
531 | +ROOP | |
532 | +RPG | |
533 | +RPL | |
534 | +RSL | |
535 | +RTL/2 | |
536 | +Ruby | |
537 | +Rust | |
538 | +S | |
539 | +S2 | |
540 | +S3 | |
541 | +S-Lang | |
542 | +S-PLUS | |
543 | +SA-C | |
544 | +SabreTalk | |
545 | +SAIL | |
546 | +SALSA | |
547 | +SAM76 | |
548 | +SAS | |
549 | +SASL | |
550 | +Sather | |
551 | +Sawzall | |
552 | +SBL | |
553 | +Scala | |
554 | +Scheme | |
555 | +Scilab | |
556 | +Scratch | |
557 | +Script.NET | |
558 | +Sed | |
559 | +Seed7 | |
560 | +Self | |
561 | +SenseTalk | |
562 | +SequenceL | |
563 | +SETL | |
564 | +Shift Script | |
565 | +SIMPOL | |
566 | +SIMSCRIPT | |
567 | +Simula | |
568 | +Simulink | |
569 | +SISAL | |
570 | +SLIP | |
571 | +SMALL | |
572 | +Smalltalk | |
573 | +Small Basic | |
574 | +SML | |
575 | +SNOBOL | |
576 | +Snowball | |
577 | +SOL | |
578 | +Span | |
579 | +SPARK | |
580 | +SPIN | |
581 | +SP/k | |
582 | +SPS | |
583 | +Squeak | |
584 | +Squirrel | |
585 | +SR | |
586 | +S/SL | |
587 | +Starlogo | |
588 | +Strand | |
589 | +Stata | |
590 | +Stateflow | |
591 | +Subtext | |
592 | +SuperCollider | |
593 | +SuperTalk | |
594 | +SYMPL | |
595 | +SyncCharts | |
596 | +SystemVerilog | |
597 | +T | |
598 | +TACL | |
599 | +TACPOL | |
600 | +TADS | |
601 | +TAL | |
602 | +Tcl | |
603 | +Tea | |
604 | +TECO | |
605 | +TELCOMP | |
606 | +TeX | |
607 | +TEX | |
608 | +TIE | |
609 | +Timber | |
610 | +TMG, compiler-compiler | |
611 | +Tom | |
612 | +TOM | |
613 | +Topspeed | |
614 | +TPU | |
615 | +Trac | |
616 | +TTM | |
617 | +T-SQL | |
618 | +TTCN | |
619 | +Turing | |
620 | +TUTOR | |
621 | +TXL | |
622 | +TypeScript | |
623 | +Turbo C++ | |
624 | +Ubercode | |
625 | +UCSD Pascal | |
626 | +Umple | |
627 | +Unicon | |
628 | +Uniface | |
629 | +UNITY | |
630 | +Unix shell | |
631 | +UnrealScript | |
632 | +Vala | |
633 | +VBA | |
634 | +VBScript | |
635 | +Verilog | |
636 | +VHDL | |
637 | +Visual Basic | |
638 | +Visual Basic .NET | |
639 | +Microsoft Visual C++ | |
640 | +Visual C# | |
641 | +Visual DataFlex | |
642 | +Visual DialogScript | |
643 | +Visual Fortran | |
644 | +Visual FoxPro | |
645 | +Visual J++ | |
646 | +Visual J# | |
647 | +Visual Objects | |
648 | +VSXu | |
649 | +Vvvv | |
650 | +WATFIV, WATFOR | |
651 | +WebDNA | |
652 | +WebQL | |
653 | +Windows PowerShell | |
654 | +Winbatch | |
655 | +X++ | |
656 | +X# | |
657 | +X10 | |
658 | +XBL | |
659 | +XC | |
660 | +xHarbour | |
661 | +XL | |
662 | +XOTcl | |
663 | +XPL | |
664 | +XPL0 | |
665 | +XQuery | |
666 | +XSB | |
667 | +XSLT | |
668 | +Yorick | |
669 | +YQL | |
670 | +Z notation | |
671 | +Zeno | |
672 | +ZOPL | |
673 | +ZPL | |
0 | 674 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,115 @@ |
1 | +.mpog_hidden_field{ | |
2 | + display: none; | |
3 | +} | |
4 | + | |
5 | +#signup-form small#secondary-email-balloon , | |
6 | +#signup-form small#role-balloon, | |
7 | +#signup-form small#area-interest-balloon | |
8 | +{ | |
9 | + display: none; | |
10 | + width: 142px; | |
11 | + height: 69px; | |
12 | + color: #FFFFFF; | |
13 | + font-weight: bold; | |
14 | + font-size: 11px; | |
15 | + padding: 5px 10px 45px 10px; | |
16 | + margin: 0; | |
17 | + line-height: 1.5em; | |
18 | + background: transparent url(/images/gray-balloon.png) bottom center no-repeat; | |
19 | + position: absolute; | |
20 | + z-index: 2; | |
21 | + right: -150px; | |
22 | +} | |
23 | + | |
24 | +#signup-form #signup-secondary-email, | |
25 | +#signup-form #signup-role, | |
26 | +#signup-form #signup-area-interest | |
27 | +{ | |
28 | + position: relative; | |
29 | +} | |
30 | + | |
31 | +#signup-form small#secondary-email-balloon, | |
32 | +#signup-form small#role-balloon, | |
33 | +#signup-form small#area-interest-balloon | |
34 | +{ | |
35 | + top: -80px; | |
36 | +} | |
37 | + | |
38 | +.dynamic-table { | |
39 | + border: solid 1px #000; | |
40 | + margin-top: 5px; | |
41 | + margin-bottom: 15px; | |
42 | +} | |
43 | +.dynamic-table td, .dynamic-table tr { | |
44 | + border: none; | |
45 | +} | |
46 | + | |
47 | +.expand-field { | |
48 | + height: 80px; | |
49 | +} | |
50 | + | |
51 | +.expand-field-focus { | |
52 | + height: 300px; | |
53 | +} | |
54 | + | |
55 | +.mpog-incomplete-percentage img { | |
56 | + margin-left: 5px; | |
57 | +} | |
58 | + | |
59 | +.mpog-incomplete-percentage img:hover { | |
60 | + cursor: pointer; | |
61 | +} | |
62 | + | |
63 | +#institution_dialog { | |
64 | + display: none; | |
65 | +} | |
66 | + | |
67 | +.errorExplanation { | |
68 | + color: red; | |
69 | + margin-left: 10px; | |
70 | +} | |
71 | + | |
72 | +.hide-field { | |
73 | + display: none !important; | |
74 | +} | |
75 | + | |
76 | +.show-field { | |
77 | + display: block !important; | |
78 | +} | |
79 | + | |
80 | +#user_filter_content { | |
81 | + display: block; | |
82 | + width: 100%; | |
83 | + height: auto; | |
84 | +} | |
85 | + | |
86 | +.user_filter_options { | |
87 | + width: 80%; | |
88 | + height: auto; | |
89 | + position: relative; | |
90 | + float: left; | |
91 | +} | |
92 | + | |
93 | +.user_filter_options input[type='text'] { | |
94 | + width: 78%; | |
95 | + | |
96 | +} | |
97 | + | |
98 | +.user_filter_actions { | |
99 | + width: 18 %; | |
100 | + height: auto; | |
101 | + position: relative; | |
102 | + float: right; | |
103 | + text-align: right; | |
104 | +} | |
105 | + | |
106 | +.search-table tr td:first-child { | |
107 | + width: 40px; | |
108 | +} | |
109 | + | |
110 | +.formfieldline { | |
111 | + margin-top: 10px; | |
112 | +} | |
113 | +.formfieldline input[type="text"] { | |
114 | + width: 180px; | |
115 | +} | |
0 | 116 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,88 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | +require File.dirname(__FILE__) + '/../../controllers/mpog_software_plugin_controller' | |
3 | + | |
4 | +class AccountController; def rescue_action(e) raise e end; end | |
5 | + | |
6 | +class AccountControllerTest < ActionController::TestCase | |
7 | + | |
8 | + def setup | |
9 | + @response = ActionController::TestResponse.new | |
10 | + @institution_list = [] | |
11 | + @institution_list << create_institution("Ministerio Publico da Uniao", "MPU") | |
12 | + @institution_list << create_institution("Tribunal Regional da Uniao", "TRU") | |
13 | + | |
14 | + @user_info = { | |
15 | + :login=>"novo_usuario", | |
16 | + :password=>"nova_senha", | |
17 | + :password_confirmation=>"nova_senha", | |
18 | + :email=>"um@novo.usuario", | |
19 | + :secondary_email=>"outro@email.com", | |
20 | + :role=>"um role ai", | |
21 | + :institution_id=>@institution_list.last.id | |
22 | + } | |
23 | + | |
24 | + @profile_data_info = { | |
25 | + :name=>"Um novo usuario", | |
26 | + :area_interest=>"uma area ai" | |
27 | + } | |
28 | + end | |
29 | + | |
30 | + should "Create a user without gov email and institution" do | |
31 | + @user_info[:institution_id] = nil | |
32 | + | |
33 | + post :signup, :user => @user_info, :profile_data => @profile_data_info | |
34 | + | |
35 | + assert_equal assigns(:user).login, @user_info[:login] | |
36 | + assert assigns(:user).save | |
37 | + end | |
38 | + | |
39 | + should "Create a user with gov email and institution" do | |
40 | + @user_info[:email] = "email@gov.br" | |
41 | + | |
42 | + post :signup, :user => @user_info, :profile_data => @profile_data_info | |
43 | + | |
44 | + assert_equal assigns(:user).login, @user_info[:login] | |
45 | + assert assigns(:user).save | |
46 | + end | |
47 | + | |
48 | + should "Do not create a user with gov email without institution" do | |
49 | + @user_info[:email] = "email@gov.br" | |
50 | + @user_info[:institution_id] = nil | |
51 | + | |
52 | + post :signup, :user => @user_info, :profile_data => @profile_data_info | |
53 | + | |
54 | + assert_equal assigns(:user).login, @user_info[:login] | |
55 | + assert !assigns(:user).save | |
56 | + end | |
57 | + | |
58 | + private | |
59 | + | |
60 | + def create_institution name, acronym | |
61 | + institution = Institution.new | |
62 | + institution.name = name | |
63 | + institution.acronym = acronym | |
64 | + institution.type = "PublicInstitution" | |
65 | + institution.save | |
66 | + institution | |
67 | + end | |
68 | + | |
69 | + def form_params | |
70 | + user = { | |
71 | + :login=>"novo_usuario", | |
72 | + :password=>"nova_senha", | |
73 | + :password_confirmation=>"nova_senha", | |
74 | + :email=>"um@novo.usuario", | |
75 | + :secondary_email=>"outro@email.com", | |
76 | + :role=>"um role ai", | |
77 | + :institution_id=>@institution_list.last.id | |
78 | + } | |
79 | + | |
80 | + profile_data = { | |
81 | + :name=>"Um novo usuario", | |
82 | + :area_interest=>"uma area ai" | |
83 | + } | |
84 | + | |
85 | + user["profile_data"] = profile_data | |
86 | + user | |
87 | + end | |
88 | +end | |
0 | 89 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,112 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | +require File.dirname(__FILE__) + '/../../controllers/mpog_software_plugin_controller' | |
3 | + | |
4 | +class MpogSoftwarePluginController; def rescue_action(e) raise e end; end | |
5 | + | |
6 | + | |
7 | +class MpogSoftwarePluginControllerTest < ActionController::TestCase | |
8 | + | |
9 | + def setup | |
10 | + @govPower = GovernmentalPower.create(:name=>"Some Gov Power") | |
11 | + @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") | |
12 | + @response = ActionController::TestResponse.new | |
13 | + @institution_list = [] | |
14 | + @institution_list << create_public_institution("Ministerio Publico da Uniao", "MPU", @govPower, @govSphere) | |
15 | + @institution_list << create_public_institution("Tribunal Regional da Uniao", "TRU", @govPower, @govSphere) | |
16 | + end | |
17 | + | |
18 | + should "Search for institution with acronym" do | |
19 | + xhr :get, :get_institutions, :query=>"TRU" | |
20 | + | |
21 | + json_response = ActiveSupport::JSON.decode(@response.body) | |
22 | + | |
23 | + assert_equal "Tribunal Regional da Uniao", json_response[0]["value"] | |
24 | + end | |
25 | + | |
26 | + should "Search for institution with name" do | |
27 | + xhr :get, :get_institutions, :query=>"Minis" | |
28 | + | |
29 | + json_response = ActiveSupport::JSON.decode(@response.body) | |
30 | + | |
31 | + assert_equal "Ministerio Publico da Uniao", json_response[0]["value"] | |
32 | + end | |
33 | + | |
34 | + should "search with name or acronym and return a list with institutions" do | |
35 | + xhr :get, :get_institutions, :query=>"uni" | |
36 | + | |
37 | + json_response = ActiveSupport::JSON.decode(@response.body) | |
38 | + | |
39 | + assert_equal "Ministerio Publico da Uniao", json_response[0]["value"] | |
40 | + assert_equal "Tribunal Regional da Uniao", json_response[1]["value"] | |
41 | + end | |
42 | + | |
43 | + should "method create_institution return the html for modal" do | |
44 | + xhr :get, :create_institution | |
45 | + assert_template 'create_institution' | |
46 | + end | |
47 | + | |
48 | + should "create new institution with ajax" do | |
49 | + @controller.stubs(:verify_recaptcha).returns(true) | |
50 | + | |
51 | + xhr :get, :new_institution, | |
52 | + :authenticity_token=>"dsa45a6das52sd", | |
53 | + :community=>{:name=>"foo bar"}, | |
54 | + :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, | |
55 | + :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, | |
56 | + :recaptcha_response_field=>'' | |
57 | + | |
58 | + json_response = ActiveSupport::JSON.decode(@response.body) | |
59 | + | |
60 | + assert json_response["success"] | |
61 | + end | |
62 | + | |
63 | + should "not create a institution that already exists" do | |
64 | + @controller.stubs(:verify_recaptcha).returns(true) | |
65 | + | |
66 | + xhr :get, :new_institution, | |
67 | + :authenticity_token=>"dsa45a6das52sd", | |
68 | + :community=>{:name=>"Ministerio Publico da Uniao"}, | |
69 | + :institution => {:cnpj=>"12.234.567/8900-10", :acronym=>"fb", :type=>"PublicInstitution"}, | |
70 | + :governmental=>{:power=>@govPower.id, :sphere=>@govSphere.id}, | |
71 | + :recaptcha_response_field=>'' | |
72 | + | |
73 | + json_response = ActiveSupport::JSON.decode(@response.body) | |
74 | + | |
75 | + assert !json_response["success"] | |
76 | + end | |
77 | + | |
78 | + should "verify if institution name already exists" do | |
79 | + xhr :get, :institution_already_exists, :name=>"Ministerio Publico da Uniao" | |
80 | + assert_equal "true", @response.body | |
81 | + | |
82 | + xhr :get, :institution_already_exists, :name=>"Another name here" | |
83 | + assert_equal "false", @response.body | |
84 | + end | |
85 | + | |
86 | + | |
87 | + should "response as XML to export softwares" do | |
88 | + get :download, :format => 'xml' | |
89 | + assert_equal 'text/xml', @response.content_type | |
90 | + end | |
91 | + | |
92 | + should "response as CSV to export softwares" do | |
93 | + get :download, :format => 'csv' | |
94 | + assert_equal 'text/csv', @response.content_type | |
95 | + assert_equal "name;acronym;demonstration_url;e_arq;e_mag;e_ping;features;icp_brasil;objectives;operating_platform\n", @response.body | |
96 | + end | |
97 | + | |
98 | + | |
99 | + private | |
100 | + | |
101 | + def create_public_institution name, acronym, gov_p, gov_s | |
102 | + institution_community = Community::new :name=>name | |
103 | + institution = PublicInstitution.new | |
104 | + institution.community = institution_community | |
105 | + institution.name = name | |
106 | + institution.acronym = acronym | |
107 | + institution.governmental_power = gov_p | |
108 | + institution.governmental_sphere = gov_s | |
109 | + institution.save | |
110 | + institution | |
111 | + end | |
112 | +end | ... | ... |
... | ... | @@ -0,0 +1,47 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class ControlledVocabularyTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + @community = fast_create(Community) | |
7 | + @language = ProgrammingLanguage.new(:name => 'C++') | |
8 | + @language.save | |
9 | + @software_language = SoftwareLanguage.new(:version => '1', :operating_system => 'os') | |
10 | + @software_language.programming_language = @language | |
11 | + @software_language.save | |
12 | + @database = DatabaseDescription.new(:name => 'Oracle') | |
13 | + @database.save | |
14 | + @software_database = SoftwareDatabase.new(:version => '2', :operating_system => 'os2') | |
15 | + @software_database.database_description = @database | |
16 | + @software_database.save | |
17 | + @software_info = SoftwareInfo.new(:community_id=>1, :acronym => "SFTW", :e_mag => true,:icp_brasil => true,:intern => true,:e_ping => true, | |
18 | + :e_arq => true,:name => true,:operating_platform => true,:objectives => "",:features => "") | |
19 | + @controlled_language = ControlledVocabulary.new() | |
20 | + @controlled_vocabulary = ControlledVocabulary.new(:administration => true, :agriculture => true, :business_and_services => true, :communication => true, | |
21 | + :culture => true, :national_defense => true, :economy_and_finances => true, :education => true, | |
22 | + :energy => true, :sports => false , :habitation => true, :industry => true, :environment => true, | |
23 | + :research_and_development => true, :social_security => false , :social_protection => true, | |
24 | + :international_relations => true, :sanitation => true, :health => false, | |
25 | + :security_public_order => true, :work => true, :transportation => true, :urbanism => true) | |
26 | + @software_info.software_languages << @software_language | |
27 | + @software_info.software_databases << @software_database | |
28 | + @software_info.controlled_vocabulary = @controlled_vocabulary | |
29 | + end | |
30 | + | |
31 | + should "save software correctly with ControlledVocabulary filds" do | |
32 | + assert @software_info.save | |
33 | + end | |
34 | + | |
35 | + should "set in software_info a reference to controlled_vocabulary" do | |
36 | + @software_info.save | |
37 | + @controlled_vocabulary.save | |
38 | + assert_equal SoftwareInfo.last.controlled_vocabulary, ControlledVocabulary.last | |
39 | + end | |
40 | + | |
41 | + should "return a valid value from database" do | |
42 | + @software_info.save | |
43 | + @controlled_vocabulary.save | |
44 | + controlled_vocabulary = ControlledVocabulary.find(SoftwareInfo.last.controlled_vocabulary) | |
45 | + assert_equal true, controlled_vocabulary.education | |
46 | + end | |
47 | +end | ... | ... |
... | ... | @@ -0,0 +1,58 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class DatabaseHelperTest < ActiveSupport::TestCase | |
4 | + | |
5 | + include DatabaseHelper | |
6 | + | |
7 | + def setup | |
8 | + @database_objects = [{"database_description_id" => "1" ,"version" => "2.0", "operating_system" => "debian"}, | |
9 | + {"database_description_id" => "2" ,"version" => "2.1", "operating_system" => "debian"}, | |
10 | + {"database_description_id" => "3" ,"version" => "2.2", "operating_system" => "debian"}] | |
11 | + @database_objects | |
12 | + end | |
13 | + | |
14 | + def teardown | |
15 | + @database_objects = nil | |
16 | + end | |
17 | + | |
18 | + should "return an empty list" do | |
19 | + empty_list = [] | |
20 | + assert_equal [],DatabaseHelper.list_database(empty_list) | |
21 | + end | |
22 | + | |
23 | + should "return a list with current database objects" do | |
24 | + list_compare = [] | |
25 | + assert_equal list_compare.class, DatabaseHelper.list_database(@database_objects).class | |
26 | + end | |
27 | + | |
28 | + should "have same information from the list passed as parameter" do | |
29 | + list_compare = DatabaseHelper.list_database(@database_objects) | |
30 | + assert_equal @database_objects.first[:database_description_id], list_compare.first.database_description_id | |
31 | + end | |
32 | + | |
33 | + should "return a list with the same size of the parameter" do | |
34 | + list_compare = DatabaseHelper.list_database(@database_objects) | |
35 | + assert_equal @database_objects.count, list_compare.count | |
36 | + end | |
37 | + | |
38 | + should "return false if list_database are empty or null" do | |
39 | + list_compare = [] | |
40 | + assert_equal false,DatabaseHelper.valid_list_database?(list_compare) | |
41 | + end | |
42 | + | |
43 | + should "return a html text with operating system equals to linux" do | |
44 | + databases = [] | |
45 | + | |
46 | + database_description = DatabaseDescription.new | |
47 | + database_description.name = "teste" | |
48 | + | |
49 | + software_database = SoftwareDatabase.new | |
50 | + software_database.version = 2 | |
51 | + software_database.operating_system = "linux" | |
52 | + software_database.database_description = database_description | |
53 | + | |
54 | + databases << software_database | |
55 | + | |
56 | + assert_not_nil DatabaseHelper.database_as_tables(databases).first.call.index("linux") | |
57 | + end | |
58 | + end | ... | ... |
... | ... | @@ -0,0 +1,36 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class DatabaseValidationTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + @database_desc = DatabaseDescription.create(:name => "ABC") | |
7 | + @database = SoftwareDatabase.new | |
8 | + @database.database_description = @database_desc | |
9 | + @database.version = "MYSQL" | |
10 | + @database.operating_system = "debian" | |
11 | + @database | |
12 | + end | |
13 | + | |
14 | + def teardown | |
15 | + @database = nil | |
16 | + end | |
17 | + | |
18 | + should "Save database if all fields are filled" do | |
19 | + assert_equal true, @database.save | |
20 | + end | |
21 | + | |
22 | + should "Don't save database if database_description database_description is empty" do | |
23 | + @database.database_description = nil | |
24 | + assert_equal true, !@database.save | |
25 | + end | |
26 | + | |
27 | + should "Don't save database if operating system are empty" do | |
28 | + @database.operating_system = " " | |
29 | + assert_equal true, !@database.save | |
30 | + end | |
31 | + | |
32 | + should "Don't save database if version are empty" do | |
33 | + @database.version = " " | |
34 | + assert_equal true, !@database.save | |
35 | + end | |
36 | +end | ... | ... |
... | ... | @@ -0,0 +1,45 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class GovernmentalPowerTest < ActiveSupport::TestCase | |
4 | + def teardown | |
5 | + Institution.destroy_all | |
6 | + end | |
7 | + | |
8 | + should "get public institutions" do | |
9 | + gov_power = GovernmentalPower::new :name=>"Some gov power" | |
10 | + | |
11 | + assert build_institution("one").save | |
12 | + assert build_institution("two").save | |
13 | + assert build_institution("three").save | |
14 | + | |
15 | + assert gov_power.public_institutions.count == PublicInstitution.count | |
16 | + end | |
17 | + | |
18 | + should "not get private institutions" do | |
19 | + gov_power = GovernmentalPower::new :name=>"Some gov power" | |
20 | + | |
21 | + assert build_institution("one", "PrivateInstitution", "00.000.000/0000-00").save | |
22 | + assert build_institution("two","PrivateInstitution", "00.000.000/0000-01").save | |
23 | + assert build_institution("three","PrivateInstitution", "00.000.000/0000-02").save | |
24 | + | |
25 | + assert gov_power.public_institutions.count == 0 | |
26 | + assert gov_power.public_institutions.count == PublicInstitution.count | |
27 | + assert gov_power.public_institutions.count != PrivateInstitution.count | |
28 | + end | |
29 | + | |
30 | + private | |
31 | + | |
32 | + def build_institution name, type="PublicInstitution", cnpj=nil | |
33 | + institution = Institution::new | |
34 | + institution.name = name | |
35 | + institution.type = type | |
36 | + institution.cnpj = cnpj | |
37 | + | |
38 | + if type == "PublicInstitution" | |
39 | + institution.governmental_power = GovernmentalPower.first | |
40 | + institution.governmental_sphere = GovernmentalSphere.first | |
41 | + end | |
42 | + | |
43 | + institution | |
44 | + end | |
45 | +end | |
0 | 46 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,18 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class InstitutionHelperTest < ActiveSupport::TestCase | |
4 | + | |
5 | + should "populate public institutions with data from SIORG" do | |
6 | + Institution.destroy_all | |
7 | + | |
8 | + InstitutionHelper.mass_update | |
9 | + | |
10 | + assert Institution.count != 0 | |
11 | + end | |
12 | + | |
13 | + should "receive json data from SIORG" do | |
14 | + data = InstitutionHelper.get_json(2, 1) | |
15 | + | |
16 | + assert data["unidades"].count != 0 | |
17 | + end | |
18 | +end | ... | ... |
... | ... | @@ -0,0 +1,16 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class InstitutionTest < ActiveSupport::TestCase | |
4 | + | |
5 | + should "save public institutions without name" do | |
6 | + institution = Institution::new | |
7 | + assert !institution.save | |
8 | + assert institution.errors.full_messages.include? "Name can't be blank" | |
9 | + end | |
10 | + | |
11 | + should "not save if institution has invalid type" do | |
12 | + institution = Institution::new :name => "teste", :type => "Other type" | |
13 | + assert !institution.save | |
14 | + assert institution.errors.full_messages.include? "Type invalid, only public and private institutions are allowed." | |
15 | + end | |
16 | +end | |
0 | 17 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,52 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class LibraryHelperTest < ActiveSupport::TestCase | |
4 | + | |
5 | + include LibraryHelper | |
6 | + | |
7 | + def setup | |
8 | + @license_objects = [{"name" => "license1" ,"version" => "2.0", "license" => "debian", "software_id" => "1"}, | |
9 | + {"name" => "license2" ,"version" => "2.1", "license" => "debian", "software_id" => "1"}, | |
10 | + {"name" => "license3" ,"version" => "2.2", "license" => "debian", "software_id" => "1"}] | |
11 | + end | |
12 | + | |
13 | + def teardown | |
14 | + @license_objects = nil | |
15 | + end | |
16 | + | |
17 | + should "return an empty list" do | |
18 | + empty_list = [] | |
19 | + assert_equal [],LibraryHelper.list_libraries(empty_list) | |
20 | + end | |
21 | + | |
22 | + should "return a list with current library objects" do | |
23 | + list_compare = [] | |
24 | + assert_equal list_compare.class, LibraryHelper.list_libraries(@license_objects).class | |
25 | + end | |
26 | + | |
27 | + should "have same information from the list passed as parameter" do | |
28 | + list_compare = LibraryHelper.list_libraries(@license_objects) | |
29 | + assert_equal @license_objects.first[:name], list_compare.first.name | |
30 | + end | |
31 | + | |
32 | + should "return a list with the same size of the parameter" do | |
33 | + list_compare = LibraryHelper.list_libraries(@license_objects) | |
34 | + assert_equal @license_objects.count, list_compare.count | |
35 | + end | |
36 | + | |
37 | + should "return false if list_database are empty or null" do | |
38 | + list_compare = [] | |
39 | + assert_equal true, LibraryHelper.valid_list_libraries?(list_compare) | |
40 | + end | |
41 | + | |
42 | + should "return a html text with license name equals to linux" do | |
43 | + libraries = [] | |
44 | + | |
45 | + library_description = Library.new | |
46 | + library_description.name = "Lib" | |
47 | + | |
48 | + libraries << library_description | |
49 | + | |
50 | + assert_not_nil LibraryHelper.library_as_tables(libraries).first.call.index("lib") | |
51 | + end | |
52 | +end | ... | ... |
... | ... | @@ -0,0 +1,34 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class LibraryValidationTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + @library = Library.new | |
7 | + @library.name = "name" | |
8 | + @library.version = "version" | |
9 | + @library.license = "license" | |
10 | + end | |
11 | + | |
12 | + def teardown | |
13 | + @Libray = nil | |
14 | + end | |
15 | + | |
16 | + should "Save Libray if all fields are filled" do | |
17 | + assert @library.save | |
18 | + end | |
19 | + | |
20 | + should "Don't save Library of name are not filed" do | |
21 | + @library.name = "" | |
22 | + assert !@library.save | |
23 | + end | |
24 | + | |
25 | + should "Don't save Library of version are not filed" do | |
26 | + @library.version = "" | |
27 | + assert !@library.save | |
28 | + end | |
29 | + | |
30 | + should "Don't save Library of license are not filed" do | |
31 | + @library.license = "" | |
32 | + assert !@library.save | |
33 | + end | |
34 | +end | ... | ... |
... | ... | @@ -0,0 +1,60 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class MpogSoftwarePluginTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + @plugin = MpogSoftwarePlugin.new | |
7 | + @user = create_user | |
8 | + @person = @user.person | |
9 | + end | |
10 | + | |
11 | + def teardown | |
12 | + @user.person.destroy | |
13 | + @user.destroy | |
14 | + end | |
15 | + | |
16 | + | |
17 | + should 'be a noosfero plugin' do | |
18 | + assert_kind_of Noosfero::Plugin, @plugin | |
19 | + end | |
20 | + | |
21 | + should 'calculate the percentege of person incomplete fields' do | |
22 | + @person.name = "Person Name" | |
23 | + @person.cell_phone = "76888919" | |
24 | + | |
25 | + required_list = ["cell_phone","contact_phone","institution","comercial_phone","country","city","state","organization_website","role","area_interest","image"] | |
26 | + | |
27 | + empty_fields = required_list.count - 1 | |
28 | + test_percentege = (empty_fields * 100) / required_list.count | |
29 | + | |
30 | + plugin_percentege = @plugin.calc_percentage_registration(@person) | |
31 | + | |
32 | + assert_equal(test_percentege, plugin_percentege) | |
33 | + end | |
34 | + | |
35 | + should 'return message with percentege of incomplete registration' do | |
36 | + @user.person.name = "Person Name" | |
37 | + @user.person.cell_phone = "76888919" | |
38 | + | |
39 | + plugin_percentege = @plugin.calc_percentage_registration(@user.person) | |
40 | + | |
41 | + expected_result = "Registration " + plugin_percentege.to_s + "% incomplete "; | |
42 | + plugin_result = @plugin.incomplete_registration({:user => @user}) | |
43 | + | |
44 | + assert_equal(expected_result, plugin_result) | |
45 | + end | |
46 | + | |
47 | + private | |
48 | + | |
49 | + def create_user | |
50 | + user = User.new | |
51 | + user.login = "login" | |
52 | + user.email = "user@email.com" | |
53 | + user.password = "123456" | |
54 | + user.password_confirmation = "123456" | |
55 | + user.secondary_email = "user@secondary_email.com" | |
56 | + user.save | |
57 | + user.person.save | |
58 | + user | |
59 | + end | |
60 | +end | ... | ... |
... | ... | @@ -0,0 +1,121 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class MpogSoftwarePluginUserTest < ActiveSupport::TestCase | |
4 | + | |
5 | + should 'not save user whose both email and secondary email are the same' do | |
6 | + | |
7 | + user = fast_create(User) | |
8 | + user.email = "test@email.com" | |
9 | + user.secondary_email = "test@email.com" | |
10 | + | |
11 | + assert !user.save | |
12 | + end | |
13 | + | |
14 | + should 'not save user whose both email and secondary email have already been used' do | |
15 | + user1 = create_default_user | |
16 | + user2 = fast_create(User) | |
17 | + | |
18 | + user2.email = "primary@email.com" | |
19 | + user2.secondary_email = "secondary@email.com" | |
20 | + assert !user2.save | |
21 | + end | |
22 | + | |
23 | + should 'not save user whose email has already been used' do | |
24 | + user1 = create_default_user | |
25 | + user2 = fast_create(User) | |
26 | + | |
27 | + user2.email = "primary@email.com" | |
28 | + user2.secondary_email = "noosfero@email.com" | |
29 | + assert !user2.save | |
30 | + end | |
31 | + | |
32 | + should 'not save user whose email has already been used in another users secondary email' do | |
33 | + user1 = create_default_user | |
34 | + user2 = fast_create(User) | |
35 | + | |
36 | + user2.login = "another-login" | |
37 | + user2.email = "secondary@email.com" | |
38 | + user2.secondary_email = "noosfero@email.com" | |
39 | + assert !user2.save | |
40 | + end | |
41 | + | |
42 | + should 'not save user whose secondary email has already been used in another users email' do | |
43 | + user1 = create_default_user | |
44 | + user2 = fast_create(User) | |
45 | + | |
46 | + user2.login = "another-login" | |
47 | + user2.email = "noosfero@email.com" | |
48 | + user2.secondary_email = "primary@email.com" | |
49 | + assert !user2.save | |
50 | + end | |
51 | + | |
52 | + should 'not save user whose secondary email has already been used in another users secondary email' do | |
53 | + user1 = create_default_user | |
54 | + user2 = fast_create(User) | |
55 | + | |
56 | + user2.login = "another-login" | |
57 | + user2.email = "noosfero@email.com" | |
58 | + user2.secondary_email = "secondary@email.com" | |
59 | + assert !user2.save | |
60 | + end | |
61 | + | |
62 | + should 'not save user whose secondary email is in the wrong format' do | |
63 | + user = fast_create(User) | |
64 | + user.email = "test@email.com" | |
65 | + user.secondary_email = "notarightformat.com" | |
66 | + | |
67 | + assert !user.save | |
68 | + | |
69 | + user.secondary_email = "not@arightformatcom" | |
70 | + | |
71 | + assert !user.save | |
72 | + end | |
73 | + | |
74 | + should 'return an error if secondary email is governmental and primary is not' do | |
75 | + user = fast_create(User) | |
76 | + | |
77 | + user.email = "test@email.com" | |
78 | + user.secondary_email = "test@gov.br" | |
79 | + | |
80 | + assert !user.save | |
81 | + assert user.errors.full_messages.include?("The governamental email must be the primary one.") | |
82 | + end | |
83 | + | |
84 | + should 'have institution if email is governmental' do | |
85 | + user = fast_create(User) | |
86 | + | |
87 | + user.email = "test@gov.br" | |
88 | + user.role = "Developer" | |
89 | + | |
90 | + user.institution = nil | |
91 | + assert !user.save | |
92 | + | |
93 | + user.institution = Institution::new(:name=>"Test Other institution") | |
94 | + assert user.save | |
95 | + end | |
96 | + | |
97 | + should 'have role if email is governmental' do | |
98 | + user = fast_create(User) | |
99 | + | |
100 | + user.email = "test@gov.br" | |
101 | + user.institution = Institution::new(:name=>"Test Other institution") | |
102 | + | |
103 | + user.role = nil | |
104 | + assert !user.save | |
105 | + | |
106 | + user.role = "Developer" | |
107 | + assert user.save | |
108 | + end | |
109 | + | |
110 | + private | |
111 | + | |
112 | + def create_default_user | |
113 | + user = fast_create(User) | |
114 | + user.login = "a-login" | |
115 | + user.email = "primary@email.com" | |
116 | + user.secondary_email = "secondary@email.com" | |
117 | + user.save | |
118 | + | |
119 | + return user | |
120 | + end | |
121 | +end | ... | ... |
... | ... | @@ -0,0 +1,41 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class MpogSoftwarePluginValidationTest < ActiveSupport::TestCase | |
4 | + def setup | |
5 | + @plugin = MpogSoftwarePlugin.new | |
6 | + institution = Institution::new(:name => "Test institution") | |
7 | + institution.save | |
8 | + @user = fast_create(User) | |
9 | + @user.institution = institution | |
10 | + end | |
11 | + | |
12 | + def teardown | |
13 | + @plugin = nil | |
14 | + @user = nil | |
15 | + end | |
16 | + | |
17 | + should 'be a noosfero plugin' do | |
18 | + assert_kind_of Noosfero::Plugin, @plugin | |
19 | + end | |
20 | + | |
21 | + should 'return true when the email has gov.br,jus.br,leg.br or mp.br as sufix and role its not empty' do | |
22 | + @user.secondary_email = "test_email2@net.br" | |
23 | + @user.email = "test_email@jus.br" | |
24 | + @user.role = "Team" | |
25 | + assert @user.save | |
26 | + end | |
27 | + | |
28 | + should 'return false when the email has gov.br,jus.br,leg.br or mp.br as sufix and role its empty' do | |
29 | + @user.role = "" | |
30 | + @user.secondary_email = "test_email@leg.br" | |
31 | + @user.email = "test_email@mp.br" | |
32 | + assert !@user.save | |
33 | + end | |
34 | + | |
35 | + should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do | |
36 | + @user.role = "" | |
37 | + @user.secondary_email = "test_email@com.br" | |
38 | + @user.email = "test_email@net.br" | |
39 | + assert @user.save | |
40 | + end | |
41 | +end | ... | ... |
... | ... | @@ -0,0 +1,61 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +OperatingSystemName.create(:name=>"Debina") | |
4 | +OperatingSystemName.create(:name=>"Fedora") | |
5 | +OperatingSystemName.create(:name=>"CentOS") | |
6 | + | |
7 | +class OperatingSystemHelperTest < ActiveSupport::TestCase | |
8 | + | |
9 | + include OperatingSystemHelper | |
10 | + | |
11 | + def setup | |
12 | + @operating_system_objects = [{:operating_system_name_id => "1" ,:version => "2.0"}, | |
13 | + {:operating_system_name_id => "2" ,"version" => "2.1"}, | |
14 | + {:operating_system_name_id => "3" ,"version" => "2.2"}] | |
15 | + @operating_system_objects | |
16 | + end | |
17 | + | |
18 | + def teardown | |
19 | + @database_objects = nil | |
20 | + end | |
21 | + | |
22 | + should "return an empty list" do | |
23 | + empty_list = [] | |
24 | + assert_equal [],OperatingSystemHelper.list_operating_system(empty_list) | |
25 | + end | |
26 | + | |
27 | + should "return a list with current OperatingSystems" do | |
28 | + list_compare = [] | |
29 | + assert_equal list_compare.class, OperatingSystemHelper.list_operating_system(@operating_system_objects).class | |
30 | + end | |
31 | + | |
32 | + should "have same information from the list passed as parameter" do | |
33 | + list_compare = OperatingSystemHelper.list_operating_system(@operating_system_objects) | |
34 | + assert_equal @operating_system_objects.first[:operating_system_name_id], list_compare.first.operating_system_name_id.to_s | |
35 | + end | |
36 | + | |
37 | + should "return a list with the same size of the parameter" do | |
38 | + list_compare = OperatingSystemHelper.list_operating_system(@operating_system_objects) | |
39 | + assert_equal @operating_system_objects.count, list_compare.count | |
40 | + end | |
41 | + | |
42 | + should "return false if list_operating_system are empty or null" do | |
43 | + list_compare = [] | |
44 | + assert_equal false,OperatingSystemHelper.valid_list_operating_system?(list_compare) | |
45 | + end | |
46 | + | |
47 | + should "return a html text with operating system" do | |
48 | + operating_systems = [] | |
49 | + | |
50 | + operating_system = OperatingSystemName.new | |
51 | + operating_system.name = "teste" | |
52 | + | |
53 | + software_operating_system = OperatingSystem.new | |
54 | + software_operating_system.version = 2 | |
55 | + software_operating_system.operating_system_name = operating_system | |
56 | + | |
57 | + operating_systems << software_operating_system | |
58 | + | |
59 | + assert_not_nil OperatingSystemHelper.operating_system_as_tables(operating_systems).first.call.index(OperatingSystemName.first.name) | |
60 | + end | |
61 | +end | ... | ... |
... | ... | @@ -0,0 +1,26 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class OperatingSystemValidationTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + operating_system_name = OperatingSystemName::new :name=>"Linux" | |
7 | + @operating_system = OperatingSystem::new :version=>"3.0" | |
8 | + @operating_system.operating_system_name = operating_system_name | |
9 | + @operating_system | |
10 | + end | |
11 | + | |
12 | + should "save OperatingSystem if all fields are filled" do | |
13 | + assert @operating_system.save | |
14 | + end | |
15 | + | |
16 | + should "not save if OperatingSystem does not have version" do | |
17 | + @operating_system.version = " " | |
18 | + assert !@operating_system.save | |
19 | + end | |
20 | + | |
21 | + should "not save if OperatingSystem does not have operating_system_name" do | |
22 | + @operating_system.operating_system_name = nil | |
23 | + assert !@operating_system.save | |
24 | + end | |
25 | + | |
26 | +end | ... | ... |
... | ... | @@ -0,0 +1,25 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class PrivateInstitutionTest < ActiveSupport::TestCase | |
4 | + def setup | |
5 | + @institution = PrivateInstitution::new :name=>"Simple Private Institution", | |
6 | + :cnpj=>"00.000.000/0001-00" | |
7 | + end | |
8 | + | |
9 | + should "not save without a cnpj" do | |
10 | + @institution.cnpj = nil | |
11 | + | |
12 | + assert !@institution.save | |
13 | + assert @institution.errors.full_messages.include? "Cnpj can't be blank" | |
14 | + end | |
15 | + | |
16 | + should "not save with a repeated cnpj" do | |
17 | + assert @institution.save | |
18 | + | |
19 | + sec_institution = PrivateInstitution::new :name=>"Another Private Institution", | |
20 | + :cnpj=>"00.000.000/0001-00" | |
21 | + | |
22 | + assert !sec_institution.save | |
23 | + assert sec_institution.errors.full_messages.include? "Cnpj has already been taken" | |
24 | + end | |
25 | +end | |
0 | 26 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,38 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class PublicInstitutionTest < ActiveSupport::TestCase | |
4 | + def setup | |
5 | + govPower = GovernmentalPower.create(:name=>"Some Gov Power") | |
6 | + govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") | |
7 | + | |
8 | + @institution = PublicInstitution::new :name=>"Simple Public Institution", :acronym=>"SPI", | |
9 | + :governmental_power=>govPower, :governmental_sphere=>govSphere | |
10 | + end | |
11 | + | |
12 | + should "save without a cnpj" do | |
13 | + @institution.cnpj = nil | |
14 | + | |
15 | + assert @institution.save | |
16 | + end | |
17 | + | |
18 | + should "Not save institution without an acronym" do | |
19 | + @institution.acronym = nil | |
20 | + | |
21 | + assert !@institution.save | |
22 | + assert @institution.errors.full_messages.include? "Acronym can't be blank" | |
23 | + end | |
24 | + | |
25 | + should "Not save institution without a governmental_power" do | |
26 | + @institution.governmental_power = nil | |
27 | + | |
28 | + assert !@institution.save | |
29 | + assert @institution.errors.full_messages.include? "Governmental power can't be blank" | |
30 | + end | |
31 | + | |
32 | + should "Not save institution without a governmental_sphere" do | |
33 | + @institution.governmental_sphere = nil | |
34 | + | |
35 | + assert !@institution.save | |
36 | + assert @institution.errors.full_messages.include? "Governmental sphere can't be blank" | |
37 | + end | |
38 | +end | |
0 | 39 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,64 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class SearchPersonTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + create_person("Jose_Augusto", "DF", "Gama", "jose_augusto@email.com") | |
7 | + create_person("Maria_cunha", "RJ", "Rio de Janeiro", "maria_cunha@email.com") | |
8 | + create_person("Joao_da_silva_costa_cunha", "RJ", "Rio de Janeiro", "joao_da_silva_costa_cunha@gemail.com") | |
9 | + end | |
10 | + | |
11 | + should "Find people with Jo in name" do | |
12 | + people_list = Person.search("Jo") | |
13 | + | |
14 | + assert_equal 2, people_list.count | |
15 | + end | |
16 | + | |
17 | + should "Find people with RJ in state" do | |
18 | + people_list = Person.search("", "RJ") | |
19 | + | |
20 | + assert_equal 2, people_list.count | |
21 | + end | |
22 | + | |
23 | + should "Find people with Gama in city" do | |
24 | + people_list = Person.search("", "", "Gama") | |
25 | + | |
26 | + assert_equal 1, people_list.count | |
27 | + end | |
28 | + | |
29 | + should "Find people with jose in email" do | |
30 | + people_list = Person.search("", "", "", "jose") | |
31 | + | |
32 | + assert_equal 1, people_list.count | |
33 | + end | |
34 | + | |
35 | + should "Find people with Jo in name and j in email" do | |
36 | + people_list = Person.search("Jo", "", "", "j") | |
37 | + | |
38 | + assert_equal 2, people_list.count | |
39 | + end | |
40 | + | |
41 | + should "Find people with Ma in name and RJ in state and Rio in city and ma in email" do | |
42 | + people_list = Person.search("Ma", "RJ", "Rio", "ma") | |
43 | + | |
44 | + assert_equal 1, people_list.count | |
45 | + end | |
46 | + | |
47 | + def create_person name, state, city, email | |
48 | + user = User::new | |
49 | + user.login = name.downcase | |
50 | + user.email = email | |
51 | + user.secondary_email = "#{name}_secondary@email2.com" | |
52 | + user.password = "adlasdasd" | |
53 | + user.password_confirmation = "adlasdasd" | |
54 | + user.save! | |
55 | + | |
56 | + user.person.name = name | |
57 | + user.person.state = state | |
58 | + user.person.city = city | |
59 | + user.person.save! | |
60 | + | |
61 | + user.save! | |
62 | + end | |
63 | + | |
64 | +end | |
0 | 65 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,18 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class SoftwareHelperTest < ActiveSupport::TestCase | |
4 | + | |
5 | + include SoftwareHelper | |
6 | + | |
7 | + should "Create ProgrammingLanguages based on file with languages names" do | |
8 | + ProgrammingLanguage.delete_all | |
9 | + SoftwareHelper.create_list_with_file("plugins/mpog_software/public/static/languages.txt", ProgrammingLanguage) | |
10 | + | |
11 | + list = File.open("plugins/mpog_software/public/static/languages.txt", "r") | |
12 | + count = list.readlines.count | |
13 | + list.close | |
14 | + | |
15 | + assert(ProgrammingLanguage.count == count) | |
16 | + end | |
17 | + | |
18 | +end | ... | ... |
... | ... | @@ -0,0 +1,47 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class SoftwareInfoValidationTest < ActiveSupport::TestCase | |
4 | + | |
5 | + def setup | |
6 | + @community = fast_create(Community) | |
7 | + @language = ProgrammingLanguage.new(:name => 'C++') | |
8 | + @language.save | |
9 | + @software_language = SoftwareLanguage.new(:version => '1', :operating_system => 'os') | |
10 | + @software_language.programming_language = @language | |
11 | + @software_language.save | |
12 | + | |
13 | + @database = DatabaseDescription.new(:name => 'Oracle') | |
14 | + @database.save | |
15 | + @software_database = SoftwareDatabase.new(:version => '2', :operating_system => 'os2') | |
16 | + @software_database.database_description = @database | |
17 | + @software_database.save | |
18 | + @software_info = SoftwareInfo.new(:community_id=>1, :acronym => "SFTW", :e_mag => true,:icp_brasil => true,:intern => true,:e_ping => true, | |
19 | + :e_arq => true,:name => true,:operating_platform => true,:objectives => "",:features => "") | |
20 | + @software_info.software_languages << @software_language | |
21 | + @software_info.software_databases << @software_database | |
22 | + end | |
23 | + | |
24 | + should 'Save SoftwareInfo if all fields are filled' do | |
25 | + assert_equal true, @software_info.save | |
26 | + end | |
27 | + | |
28 | + should 'Not save SoftwareInfo if operating_platform is blank' do | |
29 | + @software_info.operating_platform = '' | |
30 | + assert_equal false, @software_info.save | |
31 | + end | |
32 | + | |
33 | + should 'Save SoftwareInfo without demonstration_url be filled' do | |
34 | + @software_info.demonstration_url = '' | |
35 | + assert_equal true, @software_info.save | |
36 | + end | |
37 | + | |
38 | + should "Not save SoftwareInfo if acronym is blank" do | |
39 | + @software_info.acronym = "" | |
40 | + assert_equal false, @software_info.save | |
41 | + end | |
42 | + | |
43 | + should "Not save SoftwareInfo if acronym has more than 8 characters" do | |
44 | + @software_info.acronym = "123456789" | |
45 | + assert_equal false, @software_info.save | |
46 | + end | |
47 | +end | ... | ... |
... | ... | @@ -0,0 +1,63 @@ |
1 | +require File.dirname(__FILE__) + '/../../../../test/test_helper' | |
2 | + | |
3 | +class SoftwareLanguageValidationTest < ActiveSupport::TestCase | |
4 | + def setup | |
5 | + create_programming_language | |
6 | + @software_info = create_software_info | |
7 | + @software_info.save | |
8 | + end | |
9 | + | |
10 | + should "Save SoftwareLanguage if version and programming_language are filled" do | |
11 | + @software_language = create_software_language | |
12 | + assert_equal true, @software_language.save | |
13 | + end | |
14 | + | |
15 | + should "Don't save SoftwareLanguage if programming_language is not filed" do | |
16 | + @software_language = create_software_language | |
17 | + @software_language.programming_language = nil | |
18 | + assert_equal true, !@software_language.save | |
19 | + end | |
20 | + | |
21 | + should "Don't save SoftwareLanguage if version is not filed" do | |
22 | + @software_language = create_software_language | |
23 | + @software_language.version = "" | |
24 | + assert_equal true, !@software_language.save | |
25 | + end | |
26 | + | |
27 | + should "Save SoftwareLanguage if operating_system is not filed" do | |
28 | + @software_language = create_software_language | |
29 | + @software_language.operating_system = "" | |
30 | + assert_equal false, @software_language.save | |
31 | + end | |
32 | + | |
33 | + private | |
34 | + | |
35 | + def create_software_language | |
36 | + software_language = SoftwareLanguage.new | |
37 | + software_language.software_info = @software_info | |
38 | + software_language.programming_language = ProgrammingLanguage.last | |
39 | + software_language.version = "version" | |
40 | + software_language.operating_system = "GNU/Linux" | |
41 | + software_language | |
42 | + end | |
43 | + | |
44 | + def create_software_info | |
45 | + software_info = SoftwareInfo.new | |
46 | + software_info.community_id = fast_create(Community).id | |
47 | + software_info.e_mag = true | |
48 | + software_info.icp_brasil = true | |
49 | + software_info.intern = true | |
50 | + software_info.e_ping = true | |
51 | + software_info.e_arq = true | |
52 | + software_info.name = true | |
53 | + software_info.operating_platform = true | |
54 | + software_info | |
55 | + end | |
56 | + | |
57 | + def create_programming_language | |
58 | + ProgrammingLanguage.create(:name=>"C") | |
59 | + ProgrammingLanguage.create(:name=>"C++") | |
60 | + ProgrammingLanguage.create(:name=>"Ruby") | |
61 | + ProgrammingLanguage.create(:name=>"Python") | |
62 | + end | |
63 | +end | |
0 | 64 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,31 @@ |
1 | +<h2><%= _('Institution Information') %></h2> | |
2 | + | |
3 | +<div class="formfield type-text"> | |
4 | + <%= labelled_text_field(_("CNPJ"), 'institution[cnpj]', context.profile.institution.cnpj, :class=>"formlabel") %> | |
5 | +</div> | |
6 | + | |
7 | +<span class='required-field'> | |
8 | +<div class="formfield type-text"> | |
9 | + <% if context.profile.institution.type == "PublicInstitution" %> | |
10 | + <%= labelled_text_field(_("Acronym"), "institution[acronym]", context.profile.institution.acronym, :class=>"formlabel") %> | |
11 | + <% else %> | |
12 | + <%= labelled_text_field(_("Fantasy name"), "institution[acronym]", context.profile.institution.acronym, :class=>"formlabel") %> | |
13 | + <% end %> | |
14 | +</div> | |
15 | +</span> | |
16 | + | |
17 | +<% if context.profile.institution.type == "PublicInstitution" %> | |
18 | + <span class='public-institutions-fields'> | |
19 | + <div class="formfield type-select"> | |
20 | + <%= label_tag('governmental_power', _("Governmental Power")) %> | |
21 | + <%= select_tag(:governmental_power, options_for_select(GovernmentalPower.all.map {|g| [g.name, g.id]}, :selected => context.profile.institution.governmental_power_id), :class=>"formlabel") %> | |
22 | + </div> | |
23 | + </span> | |
24 | + | |
25 | + <span class= 'public-institutions-fields'> | |
26 | + <div class="formfield type-select"> | |
27 | + <%= label_tag('governmental_sphere', _("Governmental Sphere")) %> | |
28 | + <%= select_tag(:governmental_sphere, options_for_select(GovernmentalSphere.all.map {|s| [s.name, s.id]}, :selected => context.profile.institution.governmental_sphere_id), :class=>"formlabel") %> | |
29 | + </div> | |
30 | + </span> | |
31 | +<% end %> | |
0 | 32 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,5 @@ |
1 | +<% button_bar do %> | |
2 | + <%= button :'text-plain', _('Software list as [CSV]'), :action => 'download.csv' %> | |
3 | + <%= button :'text-html', _('Software list as [XML]'), :action => 'download.xml' %> | |
4 | + <%= button :back, _('Back'), :controller => 'admin_panel' %> | |
5 | +<% end %> | |
0 | 6 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,31 @@ |
1 | +<div class="environment-softwares-results-header"> | |
2 | + <div style="clear: both"></div> | |
3 | +</div> | |
4 | + | |
5 | +<table> | |
6 | + <colgroup> | |
7 | + <col width="80%"> | |
8 | + <col width="20%"> | |
9 | + </colgroup> | |
10 | + <tr> | |
11 | + <th><%= _('Software') %></th> | |
12 | + <th><%= _('Actions') %></th> | |
13 | + </tr> | |
14 | + <% @collection.each do |s| %> | |
15 | + <tr title="<%= s.name %>"> | |
16 | + <td><%= link_to_profile s.short_name, s.identifier, :title => s.name %> </td> | |
17 | + <td class='actions'> | |
18 | + <div class="members-buttons-cell"> | |
19 | + <% if !s.visible? %> | |
20 | + <%= button_without_text :'activate-user', _('Activate Software'), {:action => 'activate', :id => s, :q => @q}, :filter => @filter, :confirm => _("Do you want to activate this software?") %> | |
21 | + <% else %> | |
22 | + <%= button_without_text :'deactivate-user', _('Deactivate software'), {:action => 'deactivate', :id => s, :q => @q,:from_profile => false}, :filter => @filter, :confirm => _("Do you want to deactivate this software?") %> | |
23 | + <% end %> | |
24 | + <%= button_without_text :'delete', _('Remove'), {:action => :destroy_user, :id => s, :q => @q}, :method => :post, :filter => @filter, :confirm => _("Do you want to remove this software?") %> | |
25 | + </div> | |
26 | + </td> | |
27 | + </tr> | |
28 | + <% end %> | |
29 | +</table> | |
30 | + | |
31 | +<%= pagination_links @collection, {:param_name => 'npage', :page_links => true} %> | ... | ... |
views/mpog_software_plugin/_softwares_search_form.html.erb
0 → 100644
... | ... | @@ -0,0 +1,13 @@ |
1 | +<h1><%= _('Manage softwares') %></h1> | |
2 | + | |
3 | +<%= form_tag( { :action => 'archive_software' }, :method => 'get', :class => 'users-search' ) do %> | |
4 | + | |
5 | +<div id="search-softwares"> | |
6 | + <%= render :partial => 'softwares_search_form' %> | |
7 | +</div> | |
8 | +<div id="softwares-list"> | |
9 | + <%= render :partial => 'software_list' %> | |
10 | +</div> | |
11 | +<% end %> | |
12 | + | |
13 | +<%= render :partial => 'index_buttons' %> | |
0 | 14 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,79 @@ |
1 | +<h1><%= _('New Institution') %></h1> | |
2 | + | |
3 | +<% if environment.enabled?('admin_must_approve_new_communities') %> | |
4 | + <div class='explanation'> | |
5 | + <%= _("Note that the creation of communities in this environment is restricted. Your request to create this new community will be sent to %{environment} administrators and will be approved or rejected according to their methods and criteria.") % { :environment => environment.name }%> | |
6 | + </div> | |
7 | +<%end %> | |
8 | + | |
9 | +<% unless @errors.blank? %> | |
10 | +<div class="errorExplanation" id="errorExplanation"> | |
11 | + <h2> <%= _("Can`t create new Institution: #{@errors.length} errors") %> </h2> | |
12 | + <ul> | |
13 | + <% @errors.each do |error| %> | |
14 | + <li> <%= error %> </li> | |
15 | + <% end %> | |
16 | + </ul> | |
17 | +</div> | |
18 | +<% end %> | |
19 | + | |
20 | +<div id = 'create_institution_errors' class='errorExplanation hide-field'></div> | |
21 | + | |
22 | +<div> | |
23 | + <%= labelled_form_for :community, :html => { :multipart => true, :id=>"institution_form" } do |f| %> | |
24 | + <%= required f.text_field(:name) %> | |
25 | + <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %> | |
26 | + | |
27 | + <%= fields_for :institutions do |inst| %> | |
28 | + | |
29 | + <span class='required-field'> | |
30 | + <div class="formfield type-text"> | |
31 | + <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> | |
32 | + <%= required inst.text_field(:cnpj) %> | |
33 | + </div> | |
34 | + </span> | |
35 | + | |
36 | + <span class=''> | |
37 | + <div class='formfield type-radio'> | |
38 | + <%= label_tag("type_PublicInstitution", _("Public Institution")) %> | |
39 | + <%= radio_button_tag(:type,"PublicInstitution", true)%> | |
40 | + <%= label_tag("type_PrivateInstitution", _("Private Institution")) %> | |
41 | + <%= radio_button_tag(:type,"PrivateInstitution")%> | |
42 | + </div> | |
43 | + </span> | |
44 | + | |
45 | + <span class='required-field'> | |
46 | + <div class="formfield type-text"> | |
47 | + <%= hidden_field_tag "acronym_translate", _("Acronym") %> | |
48 | + <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %> | |
49 | + <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %> | |
50 | + <%= required inst.text_field(:acronym) %> | |
51 | + </div> | |
52 | + </span> | |
53 | + | |
54 | + <span class='required-field public-institutions-fields'> | |
55 | + <div class="formfield type-text"> | |
56 | + <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> | |
57 | + <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=>0})%> | |
58 | + </div> | |
59 | + </span> | |
60 | + | |
61 | + <span class='required-field public-institutions-fields'> | |
62 | + <div class="formfield type-text"> | |
63 | + <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> | |
64 | + <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>0})%> | |
65 | + </div> | |
66 | + </span> | |
67 | + | |
68 | + <br /> | |
69 | + | |
70 | + <div> | |
71 | + <p><%= recaptcha_tags :ajax => true, :display => {:theme => 'clean'} %> </p> | |
72 | + <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %> | |
73 | + </div> | |
74 | + <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %> | |
75 | + <% end %> | |
76 | + | |
77 | + <% end %> | |
78 | +</div> | |
79 | +<%= hidden_field_tag :loading_message, _("Creating institution") %> | |
0 | 80 | \ No newline at end of file | ... | ... |
views/mpog_software_plugin_myprofile/_database_fields.html.erb
0 → 100644
... | ... | @@ -0,0 +1,11 @@ |
1 | +<%= fields_for :database_description, @database_description do |db| %> | |
2 | + | |
3 | +<div id='databases'> | |
4 | + <% DatabaseHelper.database_as_tables(database).each do |tab| %> | |
5 | + <%= tab.call %> | |
6 | + <%end%> | |
7 | +</div> | |
8 | + | |
9 | +<div id='table_structure_databases' style="display:none"><%= DatabaseHelper.add_dynamic_table %></div> | |
10 | +<%= link_to _('New Database'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-databases"%> | |
11 | +<% end %> | ... | ... |
views/mpog_software_plugin_myprofile/_language_fields.html.erb
0 → 100644
... | ... | @@ -0,0 +1,11 @@ |
1 | +<%= fields_for :software_language, @software_language do |lng| %> | |
2 | + | |
3 | +<div id='languages'> | |
4 | + <% SoftwareLanguageHelper.language_as_tables(languages).each do |tab| %> | |
5 | + <%= tab.call %> | |
6 | + <%end%> | |
7 | +</div> | |
8 | + | |
9 | +<div id='table_structure_languages' style="display:none"><%= SoftwareLanguageHelper.add_dynamic_table %></div> | |
10 | +<%= link_to _('New language'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-languages"%> | |
11 | +<% end %> | |
0 | 12 | \ No newline at end of file | ... | ... |
views/mpog_software_plugin_myprofile/_library_fields.html.erb
0 → 100644
... | ... | @@ -0,0 +1,11 @@ |
1 | +<%= fields_for :library ,@library do |lib| %> | |
2 | + | |
3 | +<div id='libraries'> | |
4 | + <% LibraryHelper.library_as_tables(libraries).each do |tab| %> | |
5 | + <%= tab.call %> | |
6 | + <% end %> | |
7 | +</div> | |
8 | + | |
9 | +<div id='table_structure_libraries' style="display:none"><%= LibraryHelper.add_dynamic_table %></div> | |
10 | +<%= link_to _('New Library'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-libraries"%> | |
11 | +<% end %> | ... | ... |
views/mpog_software_plugin_myprofile/_operating_system_fields.html.erb
0 → 100644
... | ... | @@ -0,0 +1,11 @@ |
1 | +<%= fields_for :operating_systems ,@operating_systems do |lib| %> | |
2 | + | |
3 | +<div id='operating_systems'> | |
4 | + <% OperatingSystemHelper.operating_system_as_tables(operating_systems_fields).each do |tab| %> | |
5 | + <%= tab.call %> | |
6 | + <% end %> | |
7 | +</div> | |
8 | + | |
9 | +<div id='table_structure_operating_systems' style="display:none"><%= OperatingSystemHelper.add_dynamic_table %></div> | |
10 | +<%= link_to _('New Operating System'), "#", :class=>"button icon-add with-text new-dynamic-table dynamic-operating_systems"%> | |
11 | +<% end %> | ... | ... |