diff --git a/controllers/software_communities_plugin_controller.rb b/controllers/software_communities_plugin_controller.rb
index 8667a85..b275a72 100644
--- a/controllers/software_communities_plugin_controller.rb
+++ b/controllers/software_communities_plugin_controller.rb
@@ -20,6 +20,27 @@ class SoftwareCommunitiesPluginController < ApplicationController
render 'box_organizer/_download_list_template', :layout => false
end
+ def get_field_data
+ condition = !request.xhr? || params[:query].nil? || params[:field].nil?
+ return render :json=>{} if condition
+
+ model = get_model_by_params_field
+
+ data = model.where("name ILIKE ?", "%#{params[:query]}%").select("id, name")
+ .collect { |db|
+ {:id=>db.id, :label=>db.name}
+ }
+
+ other = [model.select("id, name").last].collect { |db|
+ {:id=>db.id, :label=>db.name}
+ }
+
+ # Always has other in the list
+ data |= other
+
+ render :json=> data
+ end
+
protected
def get_model_by_params_field
diff --git a/features/institution_registration.feature b/features/institution_registration.feature
deleted file mode 100644
index 086b14e..0000000
--- a/features/institution_registration.feature
+++ /dev/null
@@ -1,32 +0,0 @@
-Feature: Institution Field
- As a user
- I want to sign up resgistring my institution
- So others users can use it
-
- Background:
- Given "SoftwareCommunitiesPlugin" plugin is enabled
- And I am logged in as mpog_admin
- And I go to /admin/plugins
- And I check "SoftwareCommunitiesPlugin"
- And I press "Save changes"
- And Institutions has initial default values on database
- And I am logged in as mpog_admin
-
- @selenium
- Scenario: Show new institution fields when clicked in create new institution
- Given I follow "Edit Profile"
- When I follow "Create new institution"
- And I should see "New Institution"
- And I should see "Public Institution"
- And I should see "Private Institution"
- And I should see "Corporate Name"
- And I should see "Name"
- And I should see "State"
- And I should see "City"
- And I should see "Country"
- And I should see "CNPJ"
- And I should see "Acronym"
- And I choose "Public Institution"
- Then I should see "Governmental Sphere:"
- And I should see "Governmental Power:"
- And I should see "Juridical Nature:"
\ No newline at end of file
diff --git a/features/public_software_validation.feature b/features/public_software_validation.feature
index 8cdc7a5..6f26b1d 100644
--- a/features/public_software_validation.feature
+++ b/features/public_software_validation.feature
@@ -47,6 +47,3 @@ Feature: edit adherent fields
And I check "software[public_software]"
And I uncheck "software[public_software]"
Then I should not see "Adherent to e-ping ?"
-
-
-
diff --git a/features/step_definitions/software_communities_steps.rb b/features/step_definitions/software_communities_steps.rb
index 12e1897..e87447b 100644
--- a/features/step_definitions/software_communities_steps.rb
+++ b/features/step_definitions/software_communities_steps.rb
@@ -18,28 +18,6 @@ Given /^SoftwareInfo has initial default values on database$/ do
OperatingSystemName.create(:name=>"CentOS")
end
-Given /^Institutions has initial default values on database$/ do
- GovernmentalPower.create(:name => "Executivo")
- GovernmentalPower.create(:name => "Legislativo")
- GovernmentalPower.create(:name => "Judiciario")
-
- GovernmentalSphere.create(:name => "Federal")
-
- JuridicalNature.create(:name => "Autarquia")
- JuridicalNature.create(:name => "Administracao Direta")
- JuridicalNature.create(:name => "Empresa Publica")
- JuridicalNature.create(:name => "Fundacao")
- JuridicalNature.create(:name => "Orgao Autonomo")
- JuridicalNature.create(:name => "Sociedade")
- JuridicalNature.create(:name => "Sociedade Civil")
- JuridicalNature.create(:name => "Sociedade de Economia Mista")
-
- national_region = NationalRegion.new
- national_region.name = "Distrito Federal"
- national_region.national_region_code = '35'
- national_region.national_region_type_id = NationalRegionType::STATE
- national_region.save
-end
Given /^I type in "([^"]*)" in autocomplete list "([^"]*)" and I choose "([^"]*)"$/ do |typed, input_field_selector, should_select|
# Wait the page javascript load
@@ -64,27 +42,6 @@ Given /^I type in "([^"]*)" in autocomplete list "([^"]*)" and I choose "([^"]*)
sleep 1
end
-Given /^the following public institutions?$/ do |table|
- # table is a Cucumber::Ast::Table
- table.hashes.each do |item|
- community = Community.new
- community.name = item[:name]
- community.country = item[:country]
- community.state = item[:state]
- community.city = item[:city]
- community.save!
-
- governmental_power = GovernmentalPower.where(:name => item[:governmental_power]).first
- governmental_sphere = GovernmentalSphere.where(:name => item[:governmental_sphere]).first
-
- juridical_nature = JuridicalNature.create(:name => item[:juridical_nature])
-
- institution = PublicInstitution.new(:name => item[:name], :type => "PublicInstitution", :acronym => item[:acronym], :cnpj => item[:cnpj], :juridical_nature => juridical_nature, :governmental_power => governmental_power, :governmental_sphere => governmental_sphere)
- institution.community = community
- institution.corporate_name = item[:corporate_name]
- institution.save!
- end
-end
Given /^the following software language$/ do |table|
table.hashes.each do |item|
diff --git a/features/user_profile_edition.feature b/features/user_profile_edition.feature
deleted file mode 100644
index 759e583..0000000
--- a/features/user_profile_edition.feature
+++ /dev/null
@@ -1,53 +0,0 @@
-Feature: Institution Field
- As a user
- I want to update my update my user data
- So I can maintain my personal data updated
-
- Background:
- Given "SoftwareCommunitiesPlugin" plugin is enabled
- And I am logged in as mpog_admin
- And I go to /admin/plugins
- And I check "SoftwareCommunitiesPlugin"
- And I press "Save changes"
- And feature "skip_new_user_email_confirmation" is enabled on environment
- And I go to /admin/features/manage_fields
- And I check "person_fields_country_active"
- And I check "person_fields_state_active"
- And I check "person_fields_city_active"
- And I press "Save changes"
- And Institutions has initial default values on database
- And the following public institutions
- | name | acronym | country | state | city | cnpj | juridical_nature | governmental_power | governmental_sphere | corporate_name |
- | Ministerio das Cidades | MC | BR | DF | Gama | 58.745.189/0001-21 | Autarquia | Executivo | Federal | Ministerio das Cidades |
- | Governo do DF | GDF | BR | DF | Taguatinga | 12.645.166/0001-44 | Autarquia | Legislativo | Federal | Governo do DF |
- | Ministerio do Planejamento | MP | BR | DF | Brasilia | 41.769.591/0001-43 | Autarquia | Judiciario | Federal | Ministerio do Planejamento |
- And I am logged in as mpog_admin
-
- @selenium
- Scenario: Add more then one instituion on profile editor
- Given I follow "Edit Profile"
- And I follow "Add new institution"
- And I type in "Minis" in autocomplete list "#input_institution" and I choose "Ministerio do Planejamento"
- And I follow "Add new institution"
- And I type in "Gover" in autocomplete list "#input_institution" and I choose "Governo do DF"
- And I follow "Add new institution"
- Then I should see "Ministerio do Planejamento" within ".institutions_added"
- And I should see "Governo do DF" within ".institutions_added"
-
- @selenium
- Scenario: Verify if field 'city' is shown when Brazil is selected
- Given I follow "Edit Profile"
- Then I should see "City"
-
- @selenium
- Scenario: Verify if field 'city' does not appear when Brazil is not selected as country
- Given I follow "Edit Profile"
- When I select "United States" from "profile_data_country"
- Then I should not see "City" within ".type-text"
-
- @selenium
- Scenario: Show message of institution not found
- Given I follow "Edit Profile"
- And I fill in "input_institution" with "Some Nonexistent Institution"
- And I sleep for 1 seconds
- Then I should see "No institution found"
diff --git a/lib/software_communities_plugin.rb b/lib/software_communities_plugin.rb
index a2b3d35..0cbfa92 100644
--- a/lib/software_communities_plugin.rb
+++ b/lib/software_communities_plugin.rb
@@ -73,14 +73,12 @@ class SoftwareCommunitiesPlugin < Noosfero::Plugin
vendor/jquery.js
lib/noosfero-root.js
lib/select-element.js
- lib/select-field-choices
+ lib/select-field-choices.js
lib/auto-complete.js
lib/software-catalog-component.js
views/control-panel.js
views/edit-software.js
views/new-software.js
- views/user-edit-profile.js
- views/create-institution.js
views/search-software-catalog.js
views/profile-tabs-software.js
views/new-community.js
diff --git a/public/initializer.js b/public/initializer.js
index f4f8916..b882e32 100644
--- a/public/initializer.js
+++ b/public/initializer.js
@@ -5,8 +5,6 @@
'ControlPanel',
'EditSoftware',
'NewSoftware',
- 'UserEditProfile',
- 'CreateInstitution',
'SearchSoftwareCatalog',
'SoftwareDownload',
'ProfileTabsSoftware',
diff --git a/public/static/governmental_powers.txt b/public/static/governmental_powers.txt
deleted file mode 100644
index 6fffa27..0000000
--- a/public/static/governmental_powers.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Executivo
-Legislativo
-Judiciario
-Nao se aplica
diff --git a/public/static/governmental_sphere.txt b/public/static/governmental_sphere.txt
deleted file mode 100644
index ffaa31e..0000000
--- a/public/static/governmental_sphere.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Federal
-Estadual
-Distrital
-Municipal
\ No newline at end of file
diff --git a/public/static/juridical_nature.txt b/public/static/juridical_nature.txt
deleted file mode 100644
index 517bbd6..0000000
--- a/public/static/juridical_nature.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-Administracao Direta
-Autarquia
-Empresa Publica
-Fundacao
-Orgao Autonomo
-Sociedade
-Sociedade Civil
-Sociedade de Economia Mista
diff --git a/public/views/control-panel.js b/public/views/control-panel.js
index 52ac8d6..e7d6e29 100644
--- a/public/views/control-panel.js
+++ b/public/views/control-panel.js
@@ -9,22 +9,11 @@ modulejs.define('ControlPanel', ['jquery'], function($) {
}
}
-
- function add_institution_on_control_panel(control_panel) {
- var institution_link = $(".control-panel-instituton-link").remove();
-
- if( institution_link.size() > 0 ) {
- control_panel.prepend(institution_link);
- }
- }
-
-
function add_itens_on_controla_panel() {
var control_panel = $(".control-panel");
if( control_panel.size() > 0 ) {
add_software_on_control_panel(control_panel);
- add_institution_on_control_panel(control_panel);
}
}
diff --git a/public/views/create-institution.js b/public/views/create-institution.js
deleted file mode 100644
index f909bc4..0000000
--- a/public/views/create-institution.js
+++ /dev/null
@@ -1,312 +0,0 @@
-modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'], function($, NoosferoRoot, SelectElement) {
- 'use strict';
-
- var AJAX_URL = {
- create_institution_modal:
- NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/create_institution"),
- new_institution:
- NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/new_institution"),
- institution_already_exists:
- NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/institution_already_exists"),
- get_institutions:
- NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/get_institutions")
- };
-
-
- function open_create_institution_modal(evt) {
- evt.preventDefault();
-
- $.get(AJAX_URL.create_institution_modal, function(response){
- $("#institution_dialog").html(response);
-
- set_form_count_custom_data();
- set_events();
-
- $("#institution_dialog").dialog({
- modal: true,
- width: 500,
- height: 530,
- position: 'center',
- close: function() {
- $("#institution_dialog").html("");
- $('#institution_empty_ajax_message').switchClass("show-field", "hide-field");
- }
- });
- });
- }
-
-
- function show_public_institutions_fields() {
- $(".public-institutions-fields").show();
- }
-
-
- function show_private_institutions_fields() {
- $(".public-institutions-fields").hide();
-
- $("#institutions_governmental_power option").selected(0);
- $("#institutions_governmental_sphere option").selected(0);
- }
-
-
- function get_comunity_post_data() {
- return {
- name : $("#community_name").val(),
- country : $("#community_country").val(),
- state : $("#community_state").val(),
- city : $("#community_city").val()
- }
- }
-
-
- function get_institution_post_data() {
- return {
- cnpj: $("#institutions_cnpj").val(),
- type: $("input[name='institutions[type]']:checked").val(),
- acronym : $("#institutions_acronym").val(),
- governmental_power: $("#institutions_governmental_power").selected().val(),
- governmental_sphere: $("#institutions_governmental_sphere").selected().val(),
- juridical_nature: $("#institutions_juridical_nature").selected().val(),
- corporate_name: $("#institutions_corporate_name").val()
- }
- }
-
-
- function get_post_data() {
- var post_data = {};
-
- post_data.community = get_comunity_post_data();
- post_data.institutions = get_institution_post_data();
-
- return post_data;
- }
-
-
- function success_ajax_response(response) {
- close_loading();
-
- if(response.success){
- var institution_name = response.institution_data.name;
- var institution_id = response.institution_data.id;
-
- $("#institution_dialog").html("
-
-<%= hidden_field_tag("full_name_error", _("Should begin with a capital letter and no special characters")) %>
-<%= hidden_field_tag("email_error", _("Email should have the following format: name@host.br")) %>
-<%= hidden_field_tag("site_error", _("Site should have a valid format: http://name.hosts")) %>
-
<%= _("If you work in a public agency use your government e-Mail") %>
diff --git a/views/search/institutions.html.erb b/views/search/institutions.html.erb
deleted file mode 100644
index 1b33ed2..0000000
--- a/views/search/institutions.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-<%= search_page_title( @titles[@asset], @category ) %>
-
-<%= render :partial => 'search_form', :locals => { :hint => _("Type words about the %s you're looking for") % @asset.to_s.singularize } %>
-
-<%= display_results(@searches, @asset) %>
-<% if params[:display] != 'map' %>
- <%= pagination_links @searches[@asset][:results] %>
-<% end %>
-
-
-
-<% if @asset == :product %>
- <%= javascript_tag do %>
- jQuery('.search-product-price-details').altBeautify();
- <% end %>
-<% end %>
diff --git a/views/software_communities_plugin_myprofile/edit_institution.html.erb b/views/software_communities_plugin_myprofile/edit_institution.html.erb
deleted file mode 100644
index db95e3a..0000000
--- a/views/software_communities_plugin_myprofile/edit_institution.html.erb
+++ /dev/null
@@ -1,119 +0,0 @@
-
<%= _('Edit Institution') %>
-
-<% if environment.enabled?('admin_must_approve_new_communities') %>
-
- <%= _("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 }%>
-
-<%end %>
-
-<% unless flash[:errors].nil? %>
-
-
<%= _("Can`t create new Institution: #{flash[:errors].length} errors") %>