diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 783cd5b..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.swp - diff --git a/controllers/gov_user_plugin_controller.rb b/controllers/gov_user_plugin_controller.rb deleted file mode 100644 index 80a41db..0000000 --- a/controllers/gov_user_plugin_controller.rb +++ /dev/null @@ -1,251 +0,0 @@ -#aqui deve ter so usuario e instituicao -class GovUserPluginController < ApplicationController - - def hide_registration_incomplete_percentage - response = false - - if request.xhr? && params[:hide] - session[:hide_incomplete_percentage] = true - response = session[:hide_incomplete_percentage] - end - - render :json=>response.to_json - end - - def create_institution - @show_sisp_field = environment.admins.include?(current_user.person) - @state_list = get_state_list() - @governmental_sphere = [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]} - @governmental_power = [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]} - @juridical_nature = [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]} - @state_options = [[_('Select a state'), '-1']] | @state_list.collect {|state| [state.name, state.name]} - - params[:community] ||= {} - params[:institutions] ||= {} - - if request.xhr? - render :layout=>false - else - redirect_to "/" - end - end - - def split_http_referer http_referer - split_list = [] - split_list = http_referer.split("/") - @url_token = split_list.last - return @url_token - end - - def create_institution_admin - @show_sisp_field = environment.admins.include?(current_user.person) - @state_list = get_state_list() - @governmental_sphere = [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]} - @governmental_power = [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]} - @juridical_nature = [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]} - @state_options = [[_('Select a state'), '-1']] | @state_list.collect {|state| [state.name, state.name]} - - @url_token = split_http_referer request.original_url() - - params[:community] ||= {} - params[:institutions] ||= {} - - end - - def new_institution - redirect_to "/" if params[:community].blank? || params[:institutions].blank? - - response_message = {} - - institution_template = Community["institution"] - add_template_in_params institution_template - - @institutions = private_create_institution - add_environment_admins_to_institution @institutions - - response_message = save_institution @institutions - - if request.xhr? #User create institution - render :json => response_message.to_json - else #Admin create institution - session[:notice] = response_message[:message] # consume the notice - - redirect_depending_on_institution_creation response_message - end - end - - def institution_already_exists - redirect_to "/" if !request.xhr? || params[:name].blank? - - already_exists = !Community.where(:name=>params[:name]).empty? - - render :json=>already_exists.to_json - end - - def get_institutions - redirect_to "/" if !request.xhr? || params[:query].blank? - - list = Institution.search_institution(params[:query]).map{ |institution| - {:value=>institution.name, :id=>institution.id} - } - - render :json => list.to_json - end - - def get_brazil_states - redirect_to "/" unless request.xhr? - - state_list = get_state_list() - render :json=>state_list.collect {|state| state.name }.to_json - 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 - case params[:field] - when "software_language" - return ProgrammingLanguage - else - return DatabaseDescription - end - end - - def get_state_list - NationalRegion.find( - :all, - :conditions=>["national_region_type_id = ?", 2], - :order=>"name" - ) - end - - def set_institution_type - institution_params = params[:institutions].except(:governmental_power, - :governmental_sphere, - :juridical_nature - ) - if params[:institutions][:type] == "PublicInstitution" - PublicInstitution::new institution_params - else - PrivateInstitution::new institution_params - end - end - - def set_public_institution_fields institution - inst_fields = params[:institutions] - - begin - gov_power = GovernmentalPower.find inst_fields[:governmental_power] - gov_sphere = GovernmentalSphere.find inst_fields[:governmental_sphere] - jur_nature = JuridicalNature.find inst_fields[:juridical_nature] - - institution.juridical_nature = jur_nature - institution.governmental_power = gov_power - institution.governmental_sphere = gov_sphere - rescue - institution.errors.add( - :governmental_fields, - _("Could not find Governmental Power or Governmental Sphere") - ) - end - end - - def private_create_institution - community = Community.new(params[:community]) - community.environment = environment - institution = set_institution_type - - institution.name = community[:name] - institution.community = community - - if institution.type == "PublicInstitution" - set_public_institution_fields institution - end - - institution.date_modification = DateTime.now - institution.save - institution - end - - def add_template_in_params institution_template - com_fields = params[:community] - if !institution_template.blank? && institution_template.is_template - com_fields[:template_id]= institution_template.id unless com_fields.blank? - end - end - - def add_environment_admins_to_institution institution - edit_page = params[:edit_institution_page] == false - if environment.admins.include?(current_user.person) && edit_page - environment.admins.each do |adm| - institution.community.add_admin(adm) - end - end - end - - def save_institution institution - inst_errors = institution.errors.messages - com_errors = institution.community.errors.messages - - set_errors institution - - if inst_errors.empty? && com_errors.empty? && institution.valid? && institution.save - { :success => true, - :message => _("Institution successful created!"), - :institution_data => {:name=>institution.name, :id=>institution.id} - } - else - { :success => false, - :message => _("Institution could not be created!"), - :errors => inst_errors.merge(com_errors) - } - end - end - - def redirect_depending_on_institution_creation response_message - if response_message[:success] - redirect_to :controller => "/admin_panel", :action => "index" - else - flash[:errors] = response_message[:errors] - - redirect_to :controller => "gov_user_plugin", :action => "create_institution_admin", :params => params - end - end - - def set_errors institution - institution.valid? if institution - institution.community.valid? if institution.community - - flash[:error_community_name] = institution.community.errors.include?(:name) ? "highlight-error" : "" - flash[:error_community_country] = institution.errors.include?(:country) ? "highlight-error" : "" - flash[:error_community_state] = institution.errors.include?(:state) ? "highlight-error" : "" - flash[:error_community_city] = institution.errors.include?(:city) ? "highlight-error" : "" - flash[:error_institution_corporate_name] = institution.errors.include?(:corporate_name) ? "highlight-error" : "" - flash[:error_institution_cnpj] = institution.errors.include?(:cnpj) ? "highlight-error" : "" - flash[:error_institution_governmental_sphere] = institution.errors.include?(:governmental_sphere) ? "highlight-error" : "" - flash[:error_institution_governmental_power] = institution.errors.include?(:governmental_power) ? "highlight-error" : "" - flash[:error_institution_juridical_nature] = institution.errors.include?(:juridical_nature) ? "highlight-error" : "" - flash[:error_institution_sisp] = institution.errors.include?(:sisp) ? "highlight-error" : "" - end - -end diff --git a/controllers/gov_user_plugin_myprofile_controller.rb b/controllers/gov_user_plugin_myprofile_controller.rb deleted file mode 100644 index 6b4d03e..0000000 --- a/controllers/gov_user_plugin_myprofile_controller.rb +++ /dev/null @@ -1,50 +0,0 @@ -class GovUserPluginMyprofileController < MyProfileController - append_view_path File.join(File.dirname(__FILE__) + '/../views') - - def index - end - - def edit_institution - @show_sisp_field = environment.admins.include?(current_user.person) - @state_list = NationalRegion.find( - :all, - :conditions => { :national_region_type_id => 2 }, - :order => 'name' - ) - @institution = @profile.institution - update_institution if request.post? - end - - private - - def update_institution - @institution.community.update_attributes(params[:community]) - @institution.update_attributes(params[:institutions].except(:governmental_power, :governmental_sphere, :juridical_nature)) - if @institution.type == "PublicInstitution" - begin - governmental_updates - rescue - @institution.errors.add(:governmental_fields, - _("Could not find Governmental Power or Governmental Sphere")) - end - end - if @institution.valid? - redirect_to :controller => 'profile_editor', :action => 'index', :profile => profile.identifier - else - flash[:errors] = @institution.errors.full_messages - end - end - - def governmental_updates - gov_power = GovernmentalPower.find params[:institutions][:governmental_power] - gov_sphere = GovernmentalSphere.find params[:institutions][:governmental_sphere] - jur_nature = JuridicalNature.find params[:institutions][:juridical_nature] - - @institution.juridical_nature = jur_nature - @institution.governmental_power = gov_power - @institution.governmental_sphere = gov_sphere - @institution.save - end - - -end diff --git a/db/migrate/20140528193816_add_extra_fields_to_user.rb b/db/migrate/20140528193816_add_extra_fields_to_user.rb deleted file mode 100644 index 087fc62..0000000 --- a/db/migrate/20140528193816_add_extra_fields_to_user.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddExtraFieldsToUser < ActiveRecord::Migration - def self.up - change_table :users do |t| - t.string :secondary_email - t.references :institution - t.string :role - end - end - - def self.down - change_table :users do |t| - t.remove :secondary_email - t.remove_references :institution - t.remove :role - end - end -end diff --git a/db/migrate/20140528193835_create_institutions_table.rb b/db/migrate/20140528193835_create_institutions_table.rb deleted file mode 100644 index 294c791..0000000 --- a/db/migrate/20140528193835_create_institutions_table.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateInstitutionsTable < ActiveRecord::Migration - def self.up - create_table :institutions do |t| - t.string :name - - t.timestamps - end - end - - def self.down - drop_table :institutions - end -end diff --git a/db/migrate/20140617125143_add_new_fields_institution.rb b/db/migrate/20140617125143_add_new_fields_institution.rb deleted file mode 100644 index 70ecf88..0000000 --- a/db/migrate/20140617125143_add_new_fields_institution.rb +++ /dev/null @@ -1,27 +0,0 @@ -class AddNewFieldsInstitution < ActiveRecord::Migration - def up - add_column :institutions, :acronym, :string - add_column :institutions, :unit_code, :integer - add_column :institutions, :parent_code, :integer - add_column :institutions, :unit_type, :string - add_column :institutions, :juridical_nature, :string - add_column :institutions, :sub_juridical_nature, :string - add_column :institutions, :normalization_level, :string - add_column :institutions, :version, :string - add_column :institutions, :cnpj, :string - add_column :institutions, :type, :string - end - - def down - remove_column :institutions, :acronym - remove_column :institutions, :unit_code - remove_column :institutions, :parent_code - remove_column :institutions, :unit_type - remove_column :institutions, :juridical_nature - remove_column :institutions, :sub_juridical_nature - remove_column :institutions, :normalization_level - remove_column :institutions, :version - remove_column :institutions, :cnpj - remove_column :institutions, :type - end -end diff --git a/db/migrate/20140617132133_create_governmental_spheres.rb b/db/migrate/20140617132133_create_governmental_spheres.rb deleted file mode 100644 index 22c1fc7..0000000 --- a/db/migrate/20140617132133_create_governmental_spheres.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateGovernmentalSpheres < ActiveRecord::Migration - def change - create_table :governmental_spheres do |t| - t.string :name - t.string :acronym - t.integer :unit_code - t.integer :parent_code - t.string :unit_type - t.string :juridical_nature - t.string :sub_juridical_nature - t.string :normalization_level - t.string :version - t.string :cnpj - t.string :type - - t.timestamps - end - end -end diff --git a/db/migrate/20140617132451_create_governmental_powers.rb b/db/migrate/20140617132451_create_governmental_powers.rb deleted file mode 100644 index ce88ee7..0000000 --- a/db/migrate/20140617132451_create_governmental_powers.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateGovernmentalPowers < ActiveRecord::Migration - def change - create_table :governmental_powers do |t| - t.string :name - - t.timestamps - end - end -end diff --git a/db/migrate/20140617134556_add_references_to_institution.rb b/db/migrate/20140617134556_add_references_to_institution.rb deleted file mode 100644 index e5203e1..0000000 --- a/db/migrate/20140617134556_add_references_to_institution.rb +++ /dev/null @@ -1,15 +0,0 @@ -class AddReferencesToInstitution < ActiveRecord::Migration - def up - change_table :institutions do |t| - t.references :governmental_power - t.references :governmental_sphere - end - end - - def down - change_table :institutions do |t| - t.remove_references :governmental_power - t.remove_references :governmental_sphere - end - end -end diff --git a/db/migrate/20140630183326_add_relation_between_community_and_institution.rb b/db/migrate/20140630183326_add_relation_between_community_and_institution.rb deleted file mode 100644 index 4dde5a9..0000000 --- a/db/migrate/20140630183326_add_relation_between_community_and_institution.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddRelationBetweenCommunityAndInstitution < ActiveRecord::Migration - def up - change_table :institutions do |t| - t.references :community - end - end - - def down - change_table :institutions do |t| - t.remove_references :community - end - end -end diff --git a/db/migrate/20140812143218_remove_field_role_from_user.rb b/db/migrate/20140812143218_remove_field_role_from_user.rb deleted file mode 100644 index e4d4fc6..0000000 --- a/db/migrate/20140812143218_remove_field_role_from_user.rb +++ /dev/null @@ -1,13 +0,0 @@ -class RemoveFieldRoleFromUser < ActiveRecord::Migration - def up - change_table :users do |t| - t.remove :role - end - end - - def down - change_table :users do |t| - t.string :role - end - end -end diff --git a/db/migrate/20140814125947_add_new_fields_to_public_institution.rb b/db/migrate/20140814125947_add_new_fields_to_public_institution.rb deleted file mode 100644 index 232f50a..0000000 --- a/db/migrate/20140814125947_add_new_fields_to_public_institution.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddNewFieldsToPublicInstitution < ActiveRecord::Migration - def up - add_column :institutions, :sisp, :boolean, :default => false - remove_column :institutions, :juridical_nature - end - - def down - remove_column :institutions, :sisp - add_column :institutions, :juridical_nature, :string - end -end diff --git a/db/migrate/20140814131606_create_juridical_natures_table.rb b/db/migrate/20140814131606_create_juridical_natures_table.rb deleted file mode 100644 index f2c9c18..0000000 --- a/db/migrate/20140814131606_create_juridical_natures_table.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateJuridicalNaturesTable < ActiveRecord::Migration - def up - create_table :juridical_natures do |t| - t.string :name - end - end - - def down - drop_table :juridical_natures - end -end diff --git a/db/migrate/20140814134827_add_juridical_nature_reference_to_institutions_table.rb b/db/migrate/20140814134827_add_juridical_nature_reference_to_institutions_table.rb deleted file mode 100644 index 03baff8..0000000 --- a/db/migrate/20140814134827_add_juridical_nature_reference_to_institutions_table.rb +++ /dev/null @@ -1,13 +0,0 @@ -class AddJuridicalNatureReferenceToInstitutionsTable < ActiveRecord::Migration - def up - change_table :institutions do |t| - t.references :juridical_nature - end - end - - def down - change_table :institutions do |t| - t.remove_references :juridical_nature - end - end -end diff --git a/db/migrate/20140815194530_register_institution_modification.rb b/db/migrate/20140815194530_register_institution_modification.rb deleted file mode 100644 index 3183ec0..0000000 --- a/db/migrate/20140815194530_register_institution_modification.rb +++ /dev/null @@ -1,13 +0,0 @@ -class RegisterInstitutionModification < ActiveRecord::Migration - def up - change_table :institutions do |t| - t.string :date_modification - end - end - - def down - change_table :institutions do |t| - t.remove :date_modification - end - end -end diff --git a/db/migrate/20140818195821_remove_institution_from_user.rb b/db/migrate/20140818195821_remove_institution_from_user.rb deleted file mode 100644 index 37486cd..0000000 --- a/db/migrate/20140818195821_remove_institution_from_user.rb +++ /dev/null @@ -1,9 +0,0 @@ -class RemoveInstitutionFromUser < ActiveRecord::Migration - def up - remove_column :users, :institution_id - end - - def down - add_column :users, :institution_id - end -end diff --git a/db/migrate/20140818200738_create_institution_user_relation_table.rb b/db/migrate/20140818200738_create_institution_user_relation_table.rb deleted file mode 100644 index 7068d72..0000000 --- a/db/migrate/20140818200738_create_institution_user_relation_table.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateInstitutionUserRelationTable < ActiveRecord::Migration - def up - create_table :institutions_users do |t| - t.belongs_to :user - t.belongs_to :institution - end - end - - def down - drop_table :institutions_users - end -end diff --git a/db/migrate/20141103183013_add_corporate_name_to_institution.rb b/db/migrate/20141103183013_add_corporate_name_to_institution.rb deleted file mode 100644 index 69d4a19..0000000 --- a/db/migrate/20141103183013_add_corporate_name_to_institution.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddCorporateNameToInstitution < ActiveRecord::Migration - def up - add_column :institutions, :corporate_name, :string - end - - def down - remove_column :institutions, :corporate_name - end -end diff --git a/db/migrate/20150910135510_add_siorg_code_to_institution.rb b/db/migrate/20150910135510_add_siorg_code_to_institution.rb deleted file mode 100644 index 83cdec5..0000000 --- a/db/migrate/20150910135510_add_siorg_code_to_institution.rb +++ /dev/null @@ -1,9 +0,0 @@ -class AddSiorgCodeToInstitution < ActiveRecord::Migration - def up - add_column :institutions, :siorg_code, :integer - end - - def down - remove_column :institutions, :siorg_code - end -end diff --git a/db/migrate/20150910203559_add_institution_to_organization_rating.rb b/db/migrate/20150910203559_add_institution_to_organization_rating.rb deleted file mode 100644 index cf97528..0000000 --- a/db/migrate/20150910203559_add_institution_to_organization_rating.rb +++ /dev/null @@ -1,11 +0,0 @@ -class AddInstitutionToOrganizationRating < ActiveRecord::Migration - def up - change_table :organization_ratings do |t| - t.belongs_to :institution - end - end - - def down - remove_column :organization_ratings, :institution_id - end -end \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb deleted file mode 100644 index b9065f0..0000000 --- a/db/seeds.rb +++ /dev/null @@ -1,19 +0,0 @@ -# encoding: UTF-8 -powers = ["Executivo", "Legislativo", "Judiciário", "Não se Aplica"] -spheres = ["Federal", "Estadual", "Distrital", "Municipal"] -jur_natures = ["Administração Direta", "Autarquia", "Empresa Pública", "Fundação", - "Orgão Autônomo", "Sociedade", "Sociedade Civil", - "Sociedade de Economia Mista" - ] - -powers.each do |power| - GovernmentalPower.create(:name => power) -end - -spheres.each do |sphere| - GovernmentalSphere.create(:name => sphere) -end - -jur_natures.each do |jur_nature| - JuridicalNature.create(:name => jur_nature) -end diff --git a/features/institution_registration.feature b/features/institution_registration.feature deleted file mode 100644 index c1fbb4e..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 "GovUserPlugin" plugin is enabled - And I am logged in as mpog_admin - And I go to /admin/plugins - And I check "GovUserPlugin" - 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:" diff --git a/features/steps_definitions/gov_user_steps.rb b/features/steps_definitions/gov_user_steps.rb deleted file mode 100644 index 97cf5e2..0000000 --- a/features/steps_definitions/gov_user_steps.rb +++ /dev/null @@ -1,90 +0,0 @@ -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 -sleep 1 -# Basicaly it, search for the input field, type something, wait for ajax end select an item -page.driver.browser.execute_script %Q{ - var search_query = "#{input_field_selector}.ui-autocomplete-input"; - var input = jQuery(search_query).first(); - - input.trigger('click'); - input.val('#{typed}'); - input.trigger('keydown'); - - window.setTimeout(function(){ - search_query = ".ui-menu-item a:contains('#{should_select}')"; - var typed = jQuery(search_query).first(); - - typed.trigger('mouseenter').trigger('click'); - console.log(jQuery('#license_info_id')); - }, 1000); - } - 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 /^I sleep for (\d+) seconds$/ do |time| - sleep time.to_i -end - -Given /^I am logged in as mpog_admin$/ do - visit('/account/logout') - - user = User.new(:login => 'admin_user', :password => '123456', :password_confirmation => '123456', :email => 'admin_user@example.com') - person = Person.new :name=>"Mpog Admin", :identifier=>"mpog-admin" - user.person = person - user.save! - - user.activate - e = Environment.default - e.add_admin(user.person) - - visit('/account/login') - fill_in("Username", :with => user.login) - fill_in("Password", :with => '123456') - click_button("Log in") -end - diff --git a/features/user_profile_edition.feature b/features/user_profile_edition.feature deleted file mode 100644 index be7ecfa..0000000 --- a/features/user_profile_edition.feature +++ /dev/null @@ -1,77 +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 "GovUserPlugin" plugin is enabled - And the following users - | login | name | - | joao | Joao Silva | - And I am logged in as admin - And I go to /admin/plugins - And I check "GovUserPlugin" - 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 | - - Scenario: Go to control panel when clicked on 'Complete your profile' link - Given I am logged in as "joao" - And I am on joao's control panel - When I follow "Complete your profile" - Then I should see "Profile settings for " - And I should see "Personal information" - - @selenium - Scenario: Verify text information to use governmental e-mail - Given I am logged in as "joao" - And I am on joao's control panel - When I follow "Edit Profile" - Then I should see "If you work in a public agency use your government e-Mail" - - @selenium - Scenario: Add more then one instituion on profile editor - Given I am logged in as "joao" - And I am on joao's control panel - When 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 am logged in as "joao" - And I am on joao's control panel - When 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 am logged in as "joao" - And I am on joao's control panel - When I follow "Edit Profile" - And 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 am logged in as "joao" - And I am on joao's control panel - When 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/ext/communities_block.rb b/lib/ext/communities_block.rb deleted file mode 100644 index 4a5fcaa..0000000 --- a/lib/ext/communities_block.rb +++ /dev/null @@ -1,45 +0,0 @@ -require_dependency 'communities_block' - -class CommunitiesBlock - - def profile_list - result = get_visible_profiles - result.slice(0..get_limit-1) - end - - def profile_count - profile_list.count - end - - private - - def get_visible_profiles - visible_profiles = profiles.visible.includes( - [:image,:domains,:preferred_domain,:environment] - ) - - delete_communities = [] - valid_communities_string = Community.get_valid_communities_string - Community.all.each{|community| delete_communities << community.id unless eval(valid_communities_string)} - - visible_profiles = visible_profiles.where(["profiles.id NOT IN (?)", delete_communities]) unless delete_communities.empty? - - if !prioritize_profiles_with_image - return visible_profiles.all( - :limit => get_limit, - :order => 'profiles.updated_at DESC' - ).sort_by {rand} - elsif profiles.visible.with_image.count >= get_limit - return visible_profiles.with_image.all( - :limit => get_limit * 5, - :order => 'profiles.updated_at DESC' - ).sort_by {rand} - else - visible_profiles = visible_profiles.with_image.sort_by {rand} + - visible_profiles.without_image.all( - :limit => get_limit * 5, :order => 'profiles.updated_at DESC' - ).sort_by {rand} - return visible_profiles - end - end -end diff --git a/lib/ext/community.rb b/lib/ext/community.rb deleted file mode 100644 index d274660..0000000 --- a/lib/ext/community.rb +++ /dev/null @@ -1,25 +0,0 @@ -require_dependency 'community' - -class Community - has_one :institution, :dependent=>:destroy - - def institution? - return !institution.nil? - end - - def remove_of_community_search_institution? - return institution? - end - - def self.get_valid_communities_string - remove_of_communities_methods = Community.instance_methods.select{|m| m =~ /remove_of_community_search/} - valid_communities_string = "!(" - remove_of_communities_methods.each do |method| - valid_communities_string += "community.send('#{method}') || " - end - valid_communities_string = valid_communities_string[0..-5] - valid_communities_string += ")" - - valid_communities_string - end -end diff --git a/lib/ext/organization_rating.rb b/lib/ext/organization_rating.rb deleted file mode 100644 index fb2b59e..0000000 --- a/lib/ext/organization_rating.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_dependency "organization_rating" - -OrganizationRating.class_eval do - - belongs_to :institution - - attr_accessible :institution, :institution_id - - validate :verify_institution - - private - - def verify_institution - if self.institution != nil - institution = Institution.find_by_id self.institution.id - self.errors.add :institution, _("not found") unless institution - end - end - -end diff --git a/lib/ext/person.rb b/lib/ext/person.rb deleted file mode 100644 index 0260a99..0000000 --- a/lib/ext/person.rb +++ /dev/null @@ -1,35 +0,0 @@ -# encoding: utf-8 - -require_dependency 'person' - -class Person - - settings_items :percentage_incomplete, :type => :string, :default => "" - - attr_accessible :percentage_incomplete - - delegate :login, :to => :user, :prefix => true - - def institution? - false - end - - def secondary_email - self.user.secondary_email unless self.user.nil? - end - - def secondary_email= value - self.user.secondary_email = value unless self.user.nil? - end - - def institutions - institutions = [] - unless self.user.institutions.nil? - self.user.institutions.each do |institution| - institutions << institution.name - end - end - institutions - end - -end diff --git a/lib/ext/search_controller.rb b/lib/ext/search_controller.rb deleted file mode 100644 index 45a0523..0000000 --- a/lib/ext/search_controller.rb +++ /dev/null @@ -1,42 +0,0 @@ -require_dependency 'search_controller' - -class SearchController - - def communities - delete_communities = [] - valid_communities_string = Community.get_valid_communities_string - Community.all.each{|community| delete_communities << community.id unless eval(valid_communities_string)} - - @scope = visible_profiles(Community) - @scope = @scope.where(["id NOT IN (?)", delete_communities]) unless delete_communities.empty? - - full_text_search - end - - def institutions - @titles[:institutions] = _("Institution Catalog") - results = filter_communities_list{|community| community.institution?} - results = results.paginate(:per_page => 24, :page => params[:page]) - @searches[@asset] = {:results => results} - @search = results - end - - def filter_communities_list - unfiltered_list = visible_profiles(Community) - - unless params[:query].nil? - unfiltered_list = unfiltered_list.select do |com| - com.name.downcase =~ /#{params[:query].downcase}/ - end - end - - communities_list = [] - unfiltered_list.each do |profile| - if profile.class == Community && !profile.is_template? && yield(profile) - communities_list << profile - end - end - - communities_list - end -end diff --git a/lib/ext/search_helper.rb b/lib/ext/search_helper.rb deleted file mode 100644 index aae5940..0000000 --- a/lib/ext/search_helper.rb +++ /dev/null @@ -1,8 +0,0 @@ -require_dependency 'search_helper' - -module SearchHelper - - COMMON_PROFILE_LIST_BLOCK ||= [] - COMMON_PROFILE_LIST_BLOCK << :institutions - -end diff --git a/lib/ext/user.rb b/lib/ext/user.rb deleted file mode 100644 index ec5f7ce..0000000 --- a/lib/ext/user.rb +++ /dev/null @@ -1,60 +0,0 @@ -require_dependency 'user' - -class User - - GOV_SUFFIX = /^.*@[gov.br|jus.br|leg.br|mp.br]+$/ - - has_and_belongs_to_many :institutions - - validate :email_different_secondary?, :email_has_already_been_used?, - :secondary_email_format - - scope :primary_or_secondary_email_already_used?, lambda { |email| - where("email=? OR secondary_email=?", email, email) - } - - def email_different_secondary? - self.errors.add( - :base, - _("Email must be different from secondary email.") - ) if self.email == self.secondary_email - end - - def email_has_already_been_used? - user_already_saved = User.find(:first, - :conditions => ["email = ?", self.email]) - - if user_already_saved.nil? - primary_email_hasnt_been_used = - User.primary_or_secondary_email_already_used?(self.email).empty? - - if !self.secondary_email.nil? and self.secondary_email.empty? - self.secondary_email = nil - end - - secondary_email_hasnt_been_used = - User.primary_or_secondary_email_already_used?(self.secondary_email). - empty? - - if !primary_email_hasnt_been_used or !secondary_email_hasnt_been_used - self.errors.add(:base, _("E-mail or secondary e-mail already taken.")) - end - end - end - - def secondary_email_format - if !self.secondary_email.nil? and self.secondary_email.length > 0 - test = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/ - - unless test.match(self.secondary_email) - self.errors.add(:base, _("Invalid secondary email format.")) - end - end - end - - private - - def valid_format?(value, string_format) - !value.nil? && value.length > 0 && !string_format.match(value).nil? - end -end diff --git a/lib/gov_user_plugin.rb b/lib/gov_user_plugin.rb deleted file mode 100644 index 5cd63dc..0000000 --- a/lib/gov_user_plugin.rb +++ /dev/null @@ -1,332 +0,0 @@ -class GovUserPlugin < Noosfero::Plugin - include ActionView::Helpers::TagHelper - include ActionView::Helpers::FormTagHelper - include ActionView::Helpers::FormOptionsHelper - include ActionView::Helpers::JavaScriptHelper - include ActionView::Helpers::AssetTagHelper - include FormsHelper - include ActionView::Helpers - include ActionDispatch::Routing - include Rails.application.routes.url_helpers - - def self.plugin_name - "GovUserPlugin" - end - - def self.plugin_description - _("Add features related to Brazilian government.") - end - - def stylesheet? - true - end - - # Hotspot to insert html without an especific hotspot on view. - def body_beginning - return if context.session[:user].nil? or context.session[:hide_incomplete_percentage] == true - - person = context.environment.people.where(:user_id=>context.session[:user]).first - - if context.profile && context.profile.person? and !person.nil? - @person = person - @percentege = calc_percentage_registration(person) - - if @percentege >= 0 and @percentege < 100 - expanded_template('incomplete_registration.html.erb') - end - end - end - - def profile_editor_transaction_extras - single_hash_transactions = { :user => 'user', - :instituton => 'instituton' - } - - single_hash_transactions.each do |model, transaction| - call_model_transaction(model, transaction) - end - end - - def profile_editor_controller_filters - block = proc do - if request.post? && params[:institution] - is_admin = environment.admins.include?(current_user.person) - - unless is_admin - institution = profile.user.institutions - - if !params[:institution].blank? && params[:institution].class == Hash && !params[:institution][:sisp].nil? - if params[:institution][:sisp] != institution.sisp - params[:institution][:sisp] = institution.sisp - end - end - end - end - end - - [{ - :type => 'before_filter', - :method_name => 'validate_institution_sisp_field_access', - :options => { :only => :edit }, - :block => block - }] - end - - def profile_tabs - if context.profile.community? - return profile_tabs_institution if context.profile.institution? - end - end - - def control_panel_buttons - if context.profile.institution? - return institution_info_button - end - end - - def self.extra_blocks - { - InstitutionsBlock => { :type => [Environment, Person] } - } - end - - def custom_user_registration_attributes(user) - return if context.params[:user][:institution_ids].nil? - context.params[:user][:institution_ids].delete('') - - update_user_institutions(user) - - user.institutions.each do |institution| - community = institution.community - community.add_member user.person - end - end - - def profile_editor_extras - profile = context.profile - - if profile.person? - expanded_template('person_editor_extras.html.erb') - end - end - - - def calc_percentage_registration(person) - required_list = profile_required_list - empty_fields = profile_required_empty_list person - count = required_list[:person_fields].count + - required_list[:user_fields].count - percentege = 100 - ((empty_fields.count * 100) / count) - person.percentage_incomplete = percentege - person.save(validate: false) - percentege - end - - def stylesheet? - true - end - - def admin_panel_links - [ - { - :title => _('Create Institution'), - :url => { - :controller => 'gov_user_plugin', - :action => 'create_institution_admin' - } - } - ] - end - - - def js_files - %w( - vendor/modulejs-1.5.0.min.js - vendor/jquery.js - lib/noosfero-root.js - lib/select-element.js - lib/select-field-choices.js - views/complete-registration.js - views/control-panel.js - views/create-institution.js - views/new-community.js - views/user-edit-profile.js - views/gov-user-comments-extra-fields.js - initializer.js - app.js - ) - end - - def admin_panel_links - [ - { - :title => _('Create Institution'), - :url => { - :controller => 'gov_user_plugin', - :action => 'create_institution_admin' - } - } - ] - end - - protected - - def profile_required_list - fields = {} - fields[:person_fields] = %w(cell_phone - contact_phone - comercial_phone - country - city - state - organization_website - image - identifier - name) - - fields[:user_fields] = %w(secondary_email email) - fields - end - - def profile_required_empty_list(person) - empty_fields = [] - required_list = profile_required_list - - required_list[:person_fields].each do |field| - empty_fields << field.sub('_',' ') if person.send(field).blank? - end - required_list[:user_fields].each do |field| - empty_fields << field.sub('_',' ') if person.user.send(field).blank? - end - empty_fields - end - - - protected - - def user_transaction - user_editor_institution_actions - - User.transaction do - context.profile.user.update_attributes!(context.params[:user]) - end - end - - def institution_transaction - institution.date_modification = DateTime.now - institution.save - institution_models = %w(governmental_power governmental_sphere - juridical_nature) - - institution_models.each do |model| - call_institution_transaction(model) - end - - if context.params.has_key?(:institution) - Institution.transaction do - context.profile. - institution. - update_attributes!(context.params[:institution]) - end - end - end - - def organization_ratings_plugin_comments_extra_fields - Proc::new do render :file => 'ratings_extra_field' end - end - - def organization_ratings_plugin_extra_fields_show_data user_rating - gov_user_self = self - - Proc::new { - if logged_in? - is_admin = environment.admins.include?(current_user.person) - is_admin ||= user_rating.organization.admins.include?(current_user.person) - - if is_admin and gov_user_self.context.profile.software? - render :file => 'organization_ratings_extra_fields_show_institution', - :locals => {:user_rating => user_rating} - end - end - } - end - - private - - def call_model_transaction(model,name) - send(name + '_transaction') if context.params.key?(model.to_sym) - end - - def call_institution_transaction(model) - context.profile.institution.send(model + '_id = ', - context.params[model.to_sym]) - context.profile.institution.save! - end - - # Add and remove the user from it's institutions communities - def user_editor_institution_actions - user = context.profile.user - - old_communities = [] - context.profile.user.institutions.each do |institution| - old_communities << institution.community - end - - new_communities = [] - unless context.params[:user][:institution_ids].nil? - context.params[:user][:institution_ids].delete('') - - context.params[:user][:institution_ids].each do |id| - new_communities << Institution.find(id).community - end - end - - manage_user_institutions(user, old_communities, new_communities) - end - - def institution_info_button - { - :title => _('Institution Info'), - :icon => 'edit-profile-group control-panel-instituton-link', - :url => { - :controller => 'gov_user_plugin_myprofile', - :action => 'edit_institution' - } - } - end - - def manage_user_institutions(user, old_communities, new_communities) - leave_communities = (old_communities - new_communities) - enter_communities = (new_communities - old_communities) - - leave_communities.each do |community| - community.remove_member(user.person) - user.institutions.delete(community.institution) - end - - enter_communities.each do |community| - community.add_member(user.person) - user.institutions << community.institution - end - end - - def profile_tabs_institution - { :title => _('Institution'), - :id => 'intitution-fields', - :content => Proc::new do render :partial => 'profile/institution_tab' end, - :start => true - } - end - - def update_user_institutions(user) - context.params[:user][:institution_ids].each do |institution_id| - institution = Institution.find institution_id - user.institutions << institution - - if institution.community.admins.blank? - institution.community.add_admin(user.person) - end - end - user.save unless user.institution_ids.empty? - end -end diff --git a/lib/governmental_power.rb b/lib/governmental_power.rb deleted file mode 100644 index cb7ca36..0000000 --- a/lib/governmental_power.rb +++ /dev/null @@ -1,13 +0,0 @@ -class GovernmentalPower < ActiveRecord::Base - attr_accessible :name - - validates :name, :presence=>true, :uniqueness=>true - has_many :institutions - - def public_institutions - Institution.where( - :type=>"PublicInstitution", - :governmental_power_id=>self.id - ) - end -end diff --git a/lib/governmental_sphere.rb b/lib/governmental_sphere.rb deleted file mode 100644 index aef8f8f..0000000 --- a/lib/governmental_sphere.rb +++ /dev/null @@ -1,7 +0,0 @@ -class GovernmentalSphere < ActiveRecord::Base - attr_accessible :name - - validates :name, :presence=>true, :uniqueness=>true - - has_many :institutions -end diff --git a/lib/institution.rb b/lib/institution.rb deleted file mode 100644 index ee5e870..0000000 --- a/lib/institution.rb +++ /dev/null @@ -1,107 +0,0 @@ -class Institution < ActiveRecord::Base - has_many :comments - - SEARCH_FILTERS = { - :order => %w[], - :display => %w[compact] - } - - def self.default_search_display - 'compact' - end - - belongs_to :governmental_power - belongs_to :governmental_sphere - belongs_to :juridical_nature - - has_and_belongs_to_many :users - - attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, - :sub_juridical_nature, :normalization_level, - :version, :cnpj, :type, :governmental_power, - :governmental_sphere, :sisp, :juridical_nature, - :corporate_name, :siorg_code, :community - - validates :name, :presence=>true, :uniqueness=>true - - before_save :verify_institution_type - - belongs_to :community - - scope :search_institution, lambda{ |value| - where("name ilike ? OR acronym ilike ?", "%#{value}%", "%#{value}%" ) - } - - validate :validate_country, :validate_state, :validate_city, - :verify_institution_type, :validate_format_cnpj - - - protected - - def verify_institution_type - valid_institutions_type = ["PublicInstitution", "PrivateInstitution"] - - unless valid_institutions_type.include? self.type - self.errors.add( - :type, - _("invalid, only public and private institutions are allowed.") - ) - - return false - end - - return true - end - - def validate_country - unless self.community.blank? - if self.community.country.blank? && self.errors[:country].blank? - self.errors.add(:country, _("can't be blank")) - return false - end - end - - return true - end - - def validate_state - unless self.community.blank? - if self.community.country == "BR" && - (self.community.state.blank? || self.community.state == "-1") && - self.errors[:state].blank? - - self.errors.add(:state, _("can't be blank")) - return false - end - end - - return true - end - - def validate_city - unless self.community.blank? - if self.community.country == "BR" && self.community.city.blank? && - self.errors[:city].blank? - - self.errors.add(:city, _("can't be blank")) - return false - end - end - - return true - end - - def validate_format_cnpj - return true if self.community.blank? && self.community.country != "BR" - return true if self.cnpj.blank? - - format = /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/ - - if !self.cnpj.blank? && format.match(self.cnpj) - return true - else - self.errors.add(:cnpj, _("invalid format")) - return false - end - end -end diff --git a/lib/institutions_block.rb b/lib/institutions_block.rb deleted file mode 100644 index 8ef8f59..0000000 --- a/lib/institutions_block.rb +++ /dev/null @@ -1,71 +0,0 @@ -class InstitutionsBlock < CommunitiesBlock - - def self.description - _('Institutions') - end - - def profile_count - profile_list.count - end - - def default_title - n_('{#} institution', '{#} institutions', profile_count) - end - - def help - _('This block displays the institutions in which the user is a member.') - end - - def footer - owner = self.owner - case owner - when Profile - lambda do |context| - link_to s_('institutions|View all'), :profile => owner.identifier, - :controller => 'profile', :action => 'communities', - :type => 'Institution' - end - when Environment - lambda do |context| - link_to s_('institutions|View all'), :controller => 'search', - :action => 'communities', :type => 'Institution' - end - else - '' - end - end - - def profile_list - result = get_visible_profiles - - result = result.select { |p| p.class == Community && p.institution? } - - result.slice(0..get_limit-1) - end - - def profiles - owner.communities - end - - private - - def get_visible_profiles - include_list = [:image,:domains,:preferred_domain,:environment] - visible_profiles = profiles.visible.includes(include_list) - - if !prioritize_profiles_with_image - visible_profiles.all(:limit => get_limit, - :order => 'profiles.updated_at DESC' - ).sort_by{ rand } - elsif profiles.visible.with_image.count >= get_limit - visible_profiles.with_image.all(:limit => get_limit * 5, - :order => 'profiles.updated_at DESC' - ).sort_by{ rand } - else - visible_profiles.with_image.sort_by{ rand } + - visible_profiles.without_image.all(:limit => get_limit * 5, - :order => 'profiles.updated_at DESC' - ).sort_by{ rand } - end - end -end diff --git a/lib/institutions_users.rb b/lib/institutions_users.rb deleted file mode 100644 index e47da86..0000000 --- a/lib/institutions_users.rb +++ /dev/null @@ -1,4 +0,0 @@ -class InstitutionUser < ActiveRecord::Base - belongs_to :user - belongs_to :institution -end diff --git a/lib/juridical_nature.rb b/lib/juridical_nature.rb deleted file mode 100644 index 1bb17f8..0000000 --- a/lib/juridical_nature.rb +++ /dev/null @@ -1,15 +0,0 @@ -class JuridicalNature < ActiveRecord::Base - attr_accessible :name - - has_many :institutions - - validates_presence_of :name - validates_uniqueness_of :name - - def public_institutions - Institution.where( - :type=>"PublicInstitution", - :juridical_nature_id=>self.id - ) - end -end diff --git a/lib/private_institution.rb b/lib/private_institution.rb deleted file mode 100644 index db490d2..0000000 --- a/lib/private_institution.rb +++ /dev/null @@ -1,2 +0,0 @@ -class PrivateInstitution < Institution -end diff --git a/lib/public_institution.rb b/lib/public_institution.rb deleted file mode 100644 index 33d13eb..0000000 --- a/lib/public_institution.rb +++ /dev/null @@ -1,13 +0,0 @@ -class PublicInstitution < Institution - validates :governmental_power, :governmental_sphere, :juridical_nature, - :presence=>true - - validates :acronym, :allow_blank => true, :allow_nil => true, - :uniqueness=>true - - validates_format_of( - :cnpj, - :with => /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/, - :allow_nil => true, :allow_blank => true - ) -end diff --git a/po/gov_user.pot b/po/gov_user.pot deleted file mode 100644 index de87012..0000000 --- a/po/gov_user.pot +++ /dev/null @@ -1,356 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: 1.2-141-g2924904\n" -"POT-Creation-Date: 2015-09-11 17:06-0000\n" -"PO-Revision-Date: 2015-09-01 20:59-0000\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" - -#: plugins/gov_user/lib/ext/search_controller.rb:17 -msgid "Institution Catalog" -msgstr "" - -#: plugins/gov_user/lib/ext/user.rb:19 -msgid "Email must be different from secondary email." -msgstr "" - -#: plugins/gov_user/lib/ext/user.rb:40 -msgid "E-mail or secondary e-mail already taken." -msgstr "" - -#: plugins/gov_user/lib/ext/user.rb:50 -msgid "Invalid secondary email format." -msgstr "" - -#: plugins/gov_user/lib/ext/organization_rating.rb:16 -msgid "not found" -msgstr "" - -#: plugins/gov_user/lib/gov_user_plugin.rb:17 -msgid "Add features related to Brazilian government." -msgstr "" - -#: plugins/gov_user/lib/gov_user_plugin.rb:132 -#: plugins/gov_user/lib/gov_user_plugin.rb:163 -msgid "Create Institution" -msgstr "" - -#: plugins/gov_user/lib/gov_user_plugin.rb:287 -msgid "Institution Info" -msgstr "" - -#: plugins/gov_user/lib/gov_user_plugin.rb:312 -msgid "Institution" -msgstr "" - -#: plugins/gov_user/lib/institutions_block.rb:4 -#: plugins/gov_user/views/person_editor_extras.html.erb:11 -msgid "Institutions" -msgstr "" - -#: plugins/gov_user/lib/institutions_block.rb:12 -msgid "{#} institution" -msgid_plural "{#} institutions" -msgstr[0] "" -msgstr[1] "" - -#: plugins/gov_user/lib/institutions_block.rb:16 -msgid "This block displays the institutions in which the user is a member." -msgstr "" - -#: plugins/gov_user/lib/institutions_block.rb:24 -#: plugins/gov_user/lib/institutions_block.rb:30 -msgid "institutions|View all" -msgstr "" - -#: plugins/gov_user/lib/institution.rb:47 -msgid "invalid, only public and private institutions are allowed." -msgstr "" - -#: plugins/gov_user/lib/institution.rb:59 -#: plugins/gov_user/lib/institution.rb:73 -#: plugins/gov_user/lib/institution.rb:86 -msgid "can't be blank" -msgstr "" - -#: plugins/gov_user/lib/institution.rb:103 -msgid "invalid format" -msgstr "" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:18 -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:43 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:83 -msgid "Select a Governmental Sphere" -msgstr "" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:19 -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:44 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:90 -msgid "Select a Governmental Power" -msgstr "" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:20 -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:45 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:96 -msgid "Select a Juridical Nature" -msgstr "" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:21 -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:46 -msgid "Select a state" -msgstr "" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:168 -#: plugins/gov_user/controllers/gov_user_plugin_myprofile_controller.rb:26 -msgid "Could not find Governmental Power or Governmental Sphere" -msgstr "" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:214 -msgid "Institution successful created!" -msgstr "" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:219 -msgid "Institution could not be created!" -msgstr "" - -#: plugins/gov_user/test/unit/gov_user_person_test.rb:50 -#: plugins/gov_user/test/unit/gov_user_person_test.rb:56 -msgid "Name Should begin with a capital letter and no special characters" -msgstr "" - -#: plugins/gov_user/views/search/institutions.html.erb:3 -msgid "Type words about the %s you're looking for" -msgstr "" - -#: plugins/gov_user/views/ratings_extra_field.html.erb:2 -msgid "Organization name or Enterprise name" -msgstr "" - -#: plugins/gov_user/views/ratings_extra_field.html.erb:6 -#: plugins/gov_user/views/person_editor_extras.html.erb:21 -msgid "No institution found" -msgstr "" - -#: plugins/gov_user/views/incomplete_registration.html.erb:3 -msgid "Complete Profile" -msgstr "" - -#: plugins/gov_user/views/incomplete_registration.html.erb:6 -msgid "Complete your profile" -msgstr "" - -#: plugins/gov_user/views/incomplete_registration.html.erb:7 -msgid "Hide" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:1 -msgid "Edit Institution" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:5 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:5 -msgid "" -"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." -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:11 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:11 -msgid "\"Can`t create new Institution: #{flash[:errors].length} errors\"" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:24 -msgid "All fields with (*) are mandatory" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:31 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:37 -msgid "Public Institution" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:36 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:33 -msgid "Private Institution" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:43 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:44 -msgid "Institution name already exists" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:47 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:48 -msgid "Corporate Name" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:52 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:53 -msgid "Country" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:56 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:57 -msgid "State" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:66 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:66 -msgid "CNPJ" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:73 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:75 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:72 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:74 -msgid "Acronym" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:74 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:73 -msgid "Fantasy name" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:82 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:17 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:81 -msgid "Governmental Sphere:" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:89 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:16 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:88 -msgid "Governmental Power:" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:95 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:18 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:94 -msgid "Juridical Nature:" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:102 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:101 -msgid "SISP?" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:104 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:104 -msgid "Yes" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:106 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:109 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:106 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:108 -msgid "No" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:114 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:114 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:118 -msgid "Save" -msgstr "" - -#: plugins/gov_user/views/person_editor_extras.html.erb:2 -msgid "Secondary e-mail" -msgstr "" - -#: plugins/gov_user/views/person_editor_extras.html.erb:22 -msgid "Add new institution" -msgstr "" - -#: plugins/gov_user/views/person_editor_extras.html.erb:23 -msgid "Create new institution" -msgstr "" - -#: plugins/gov_user/views/person_editor_extras.html.erb:39 -msgid "Should begin with a capital letter and no special characters" -msgstr "" - -#: plugins/gov_user/views/person_editor_extras.html.erb:40 -msgid "Email should have the following format: name@host.br" -msgstr "" - -#: plugins/gov_user/views/person_editor_extras.html.erb:41 -msgid "Site should have a valid format: http://name.hosts" -msgstr "" - -#: plugins/gov_user/views/person_editor_extras.html.erb:42 -msgid "If you work in a public agency use your government e-Mail" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:3 -msgid "Institution Information" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:6 -msgid "Type:" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:7 -msgid "CNPJ:" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:8 -msgid "Last modification:" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:9 -msgid "Country:" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:10 -msgid "State:" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:11 -msgid "City:" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:13 -msgid "Fantasy Name:" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:15 -msgid "Acronym:" -msgstr "" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 -msgid "SISP:" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:1 -msgid "New Institution" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:16 -msgid "\"#{key_name.capitalize} #{value.join()}\"" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:115 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:119 -msgid "Cancel" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:121 -msgid "Could not send the form data to the server" -msgstr "" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:128 -msgid "Creating institution" -msgstr "" diff --git a/po/pt/gov_user.po b/po/pt/gov_user.po deleted file mode 100644 index 4a3a691..0000000 --- a/po/pt/gov_user.po +++ /dev/null @@ -1,370 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -msgid "" -msgstr "" -"Project-Id-Version: 1.2-143-g8dfded9\n" -"POT-Creation-Date: 2015-09-11 17:14-0000\n" -"PO-Revision-Date: 2015-09-01 19:55-0000\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" - -#: plugins/gov_user/test/unit/gov_user_person_test.rb:50 -#: plugins/gov_user/test/unit/gov_user_person_test.rb:56 -msgid "Name Should begin with a capital letter and no special characters" -msgstr "" -"Nome deve iniciar com letrar maiúscula e não deve conter carateres especiais" - -#: plugins/gov_user/controllers/gov_user_plugin_myprofile_controller.rb:26 -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:168 -msgid "Could not find Governmental Power or Governmental Sphere" -msgstr "Não foi possível encontrar o Poder ou Esfera Governamental" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:18 -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:43 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:83 -msgid "Select a Governmental Sphere" -msgstr "Selecione uma Esfera Governamental" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:19 -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:44 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:90 -msgid "Select a Governmental Power" -msgstr "Selecione um Poder Governamental" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:20 -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:45 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:96 -msgid "Select a Juridical Nature" -msgstr "Seleciona uma Natureza Jurídica" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:21 -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:46 -msgid "Select a state" -msgstr "Selecione um Estado" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:214 -msgid "Institution successful created!" -msgstr "Instituição criada com sucesso!" - -#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:219 -msgid "Institution could not be created!" -msgstr "Instituição não pode ser criada!" - -#: plugins/gov_user/lib/gov_user_plugin.rb:17 -msgid "Add features related to Brazilian government." -msgstr "Adicionar funcionlidade relacionada com o governo brasileiro." - -#: plugins/gov_user/lib/gov_user_plugin.rb:132 -#: plugins/gov_user/lib/gov_user_plugin.rb:163 -msgid "Create Institution" -msgstr "Criar Instituição" - -#: plugins/gov_user/lib/gov_user_plugin.rb:287 -msgid "Institution Info" -msgstr "Informações da Instituição" - -#: plugins/gov_user/lib/gov_user_plugin.rb:312 -msgid "Institution" -msgstr "Instituição" - -#: plugins/gov_user/lib/institution.rb:47 -msgid "invalid, only public and private institutions are allowed." -msgstr "Inválido, somente instituições públicas e privadas são permitidas." - -#: plugins/gov_user/lib/institution.rb:59 -#: plugins/gov_user/lib/institution.rb:73 -#: plugins/gov_user/lib/institution.rb:86 -msgid "can't be blank" -msgstr "não pode ficar em branco" - -#: plugins/gov_user/lib/institution.rb:103 -msgid "invalid format" -msgstr "formato inválido" - -#: plugins/gov_user/lib/ext/user.rb:19 -msgid "Email must be different from secondary email." -msgstr "Email deve ser diferente do email secundário" - -#: plugins/gov_user/lib/ext/user.rb:40 -msgid "E-mail or secondary e-mail already taken." -msgstr "Email ou email secundário já estão sendo utilizados." - -#: plugins/gov_user/lib/ext/user.rb:50 -msgid "Invalid secondary email format." -msgstr "Formato inválido do email sencundário" - -#: plugins/gov_user/lib/ext/search_controller.rb:17 -msgid "Institution Catalog" -msgstr "Catálogo de Instituições" - -#: plugins/gov_user/lib/ext/organization_rating.rb:16 -msgid "not found" -msgstr "não encontrada" - -#: plugins/gov_user/lib/institutions_block.rb:4 -#: plugins/gov_user/views/person_editor_extras.html.erb:11 -msgid "Institutions" -msgstr "Instituições" - -#: plugins/gov_user/lib/institutions_block.rb:12 -msgid "{#} institution" -msgid_plural "{#} institutions" -msgstr[0] "{#} instituição" -msgstr[1] "{#} instituições" - -#: plugins/gov_user/lib/institutions_block.rb:16 -msgid "This block displays the institutions in which the user is a member." -msgstr "Esse bloco mostra as instituições em que o usuário faz parte." - -#: plugins/gov_user/lib/institutions_block.rb:24 -#: plugins/gov_user/lib/institutions_block.rb:30 -msgid "institutions|View all" -msgstr "instituições|Ver todas" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:1 -msgid "Edit Institution" -msgstr "Editar Instituição" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:5 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:5 -msgid "" -"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." -msgstr "" -"Note que a criação de comunidades neste ambiente é restrita. Sua requisição " -"para criar essa nova comunidade será enviada para os administradores " -"%{environment} e será aprovada ou rejeitada de acordo com seus métodos e " -"critérios." - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:11 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:11 -msgid "\"Can`t create new Institution: #{flash[:errors].length} errors\"" -msgstr "" -"\"Não foi possível criar nova Instituição: #{flash[:errors].length} erros\"" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:24 -msgid "All fields with (*) are mandatory" -msgstr "Todos os campos com (*) são obrigatórios" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:31 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:37 -msgid "Public Institution" -msgstr "Instituição Pública" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:36 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:33 -msgid "Private Institution" -msgstr "Instituição Privada" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:43 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:44 -msgid "Institution name already exists" -msgstr "Nome de Instituição já existe" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:47 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:48 -msgid "Corporate Name" -msgstr "Nome da Coorporação" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:52 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:53 -msgid "Country" -msgstr "País" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:56 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:57 -msgid "State" -msgstr "Estado" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:66 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:66 -msgid "CNPJ" -msgstr "CNPJ" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:73 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:75 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:72 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:74 -msgid "Acronym" -msgstr "Sigla" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:74 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:73 -msgid "Fantasy name" -msgstr "Nome Fantasia" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:82 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:17 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:81 -msgid "Governmental Sphere:" -msgstr "Esfera Governamental:" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:89 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:16 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:88 -msgid "Governmental Power:" -msgstr "Poder Governamental:" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:95 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:18 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:94 -msgid "Juridical Nature:" -msgstr "Natureza Jurídica:" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:102 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:101 -msgid "SISP?" -msgstr "SISP?" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:104 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:104 -msgid "Yes" -msgstr "Sim" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:106 -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:109 -#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:106 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:108 -msgid "No" -msgstr "Não" - -#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:114 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:114 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:118 -msgid "Save" -msgstr "Salvar" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:3 -msgid "Institution Information" -msgstr "Informação da Instituição" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:6 -msgid "Type:" -msgstr "Tipo:" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:7 -msgid "CNPJ:" -msgstr "CNPJ:" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:8 -msgid "Last modification:" -msgstr "Última modificação:" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:9 -msgid "Country:" -msgstr "País:" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:10 -msgid "State:" -msgstr "Estado:" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:11 -msgid "City:" -msgstr "Cidade:" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:13 -msgid "Fantasy Name:" -msgstr "Nome Fantasia:" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:15 -msgid "Acronym:" -msgstr "Sigla:" - -#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 -msgid "SISP:" -msgstr "SISP:" - -#: plugins/gov_user/views/ratings_extra_field.html.erb:2 -msgid "Organization name or Enterprise name" -msgstr "Nome da organização ou empresa" - -#: plugins/gov_user/views/ratings_extra_field.html.erb:6 -#: plugins/gov_user/views/person_editor_extras.html.erb:21 -msgid "No institution found" -msgstr "Nenhuma instituição encontrada" - -#: plugins/gov_user/views/person_editor_extras.html.erb:2 -msgid "Secondary e-mail" -msgstr "Email secundário" - -#: plugins/gov_user/views/person_editor_extras.html.erb:22 -msgid "Add new institution" -msgstr "Adicionar nova instituição" - -#: plugins/gov_user/views/person_editor_extras.html.erb:23 -msgid "Create new institution" -msgstr "Criar nova instituição" - -#: plugins/gov_user/views/person_editor_extras.html.erb:39 -msgid "Should begin with a capital letter and no special characters" -msgstr "Deve começar com letra maíscula e não conter caracteres especiais" - -#: plugins/gov_user/views/person_editor_extras.html.erb:40 -msgid "Email should have the following format: name@host.br" -msgstr "Email deve ter o seguinte formato: name@host.br" - -#: plugins/gov_user/views/person_editor_extras.html.erb:41 -msgid "Site should have a valid format: http://name.hosts" -msgstr "Site deve ter um formato válido: http://name.hosts" - -#: plugins/gov_user/views/person_editor_extras.html.erb:42 -msgid "If you work in a public agency use your government e-Mail" -msgstr "Se você trabalha em uma agência pública use seu email governamental" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:1 -msgid "New Institution" -msgstr "Nova Instituição" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:16 -msgid "\"#{key_name.capitalize} #{value.join()}\"" -msgstr "\"#{key_name.capitalize} #{value.join()}\"" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:115 -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:119 -msgid "Cancel" -msgstr "Cancelar" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:121 -msgid "Could not send the form data to the server" -msgstr "Não foi possível enviar os dados do formulário para o servidor" - -#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:128 -msgid "Creating institution" -msgstr "Criar instituição" - -#: plugins/gov_user/views/search/institutions.html.erb:3 -msgid "Type words about the %s you're looking for" -msgstr "Escreve palavras sobre o %s que você está procurando" - -#: plugins/gov_user/views/incomplete_registration.html.erb:3 -msgid "Complete Profile" -msgstr "Complete o Perfil" - -#: plugins/gov_user/views/incomplete_registration.html.erb:6 -msgid "Complete your profile" -msgstr "Complete seu perfil" - -#: plugins/gov_user/views/incomplete_registration.html.erb:7 -msgid "Hide" -msgstr "Ocultar" - -#~ msgid "A plugin that does this and that." -#~ msgstr "Um plugin que faz isso e aquilo" - -#~ msgid "The governamental email must be the primary one." -#~ msgstr "O email governamental deve ser o principal" - -#~ msgid "Institution is obligatory if user has a government email." -#~ msgstr "Instituição é obrigatória se o usuário tem email governamental." diff --git a/public/app.js b/public/app.js deleted file mode 100644 index 7e98375..0000000 --- a/public/app.js +++ /dev/null @@ -1,11 +0,0 @@ -(function() { - 'use strict'; - - var $ = modulejs.require('jquery'); - var Initializer = modulejs.require('Initializer'); - - - $(document).ready(function() { - Initializer.init(); - }); -})(); diff --git a/public/initializer.js b/public/initializer.js deleted file mode 100644 index 395f20c..0000000 --- a/public/initializer.js +++ /dev/null @@ -1,33 +0,0 @@ -(function() { - 'use strict'; - - var dependencies = [ - 'ControlPanel', - 'CreateInstitution', - 'CompleteRegistration', - 'UserEditProfile', - 'NewCommunity', - 'GovUserCommentsExtraFields' - ]; - - - modulejs.define('Initializer', dependencies, function() { - var __dependencies = arguments; - - - function call_dependency(dependency) { - if( dependency.isCurrentPage() ) { - dependency.init(); - } - } - - - return { - init: function() { - for(var i=0, len = __dependencies.length; i < len; i++) { - call_dependency(__dependencies[i]); - } - } - }; - }); -})(); diff --git a/public/lib/noosfero-root.js b/public/lib/noosfero-root.js deleted file mode 100644 index cd3c8bf..0000000 --- a/public/lib/noosfero-root.js +++ /dev/null @@ -1,13 +0,0 @@ -modulejs.define('NoosferoRoot', function() { - 'use strict'; - - - function url_with_subdirectory(url) { - return noosfero_root() + url; - } - - - return { - urlWithSubDirectory: url_with_subdirectory - } -}); diff --git a/public/lib/select-element.js b/public/lib/select-element.js deleted file mode 100644 index 26880ae..0000000 --- a/public/lib/select-element.js +++ /dev/null @@ -1,35 +0,0 @@ -modulejs.define('SelectElement', function() { - 'use strict'; - - - function SelectElement(name, id) { - this.select = document.createElement("select"); - } - - - SelectElement.prototype.setAttr = function(attr, value) { - return this.select.setAttribute(attr, value); - }; - - - SelectElement.prototype.addOption = function(option) { - return this.select.add(option); - }; - - - SelectElement.prototype.getSelect = function() { - return this.select; - }; - - - SelectElement.generateOption = function(value, text) { - var option; - option = document.createElement("option"); - option.setAttribute("value", value); - option.text = text; - return option; - }; - - - return SelectElement; -}); diff --git a/public/lib/select-field-choices.js b/public/lib/select-field-choices.js deleted file mode 100644 index 095d4e1..0000000 --- a/public/lib/select-field-choices.js +++ /dev/null @@ -1,81 +0,0 @@ -modulejs.define('SelectFieldChoices', ['jquery', 'SelectElement'], function($, SelectElement) { - 'use strict'; - - - function SelectFieldChoices(state_id, city_id, state_url) { - this.state_id = state_id; - this.input_html = $(state_id).parent().html(); - this.old_value = $(state_id).val(); - this.city_parent_div = $(city_id).parent().parent().parent(); - this.state_url = state_url; - } - - - SelectFieldChoices.prototype.getCurrentStateElement = function() { - return $(this.state_id); - }; - - - SelectFieldChoices.prototype.replaceWith = function(html) { - var parent_div = this.getCurrentStateElement().parent(); - parent_div.html(html); - }; - - - SelectFieldChoices.prototype.generateSelect = function(state_list) { - var select_element, option; - - select_element = new SelectElement(); - select_element.setAttr("name", "profile_data[state]"); - select_element.setAttr("id", "state_field"); - select_element.setAttr("class", "type-select valid"); - - state_list.forEach(function(state) { - option = SelectElement.generateOption(state, state); - select_element.addOption(option); - }); - - return select_element.getSelect(); - }; - - - SelectFieldChoices.prototype.replaceStateWithSelectElement = function() { - var klass = this; - - $.get(this.state_url, function(response) { - var select_html; - - if (response.length > 0) { - select_html = klass.generateSelect(response); - klass.replaceWith(select_html); - - if (klass.old_value.length !== 0 && response.include(klass.old_value)) { - klass.getCurrentStateElement().val(klass.old_value); - } - } - }); - }; - - - SelectFieldChoices.prototype.replaceStateWithInputElement = function() { - this.replaceWith(this.input_html); - }; - - - SelectFieldChoices.prototype.hideCity = function() { - this.city_parent_div.addClass("mpog_hidden_field"); - }; - - - SelectFieldChoices.prototype.showCity = function() { - this.city_parent_div.removeClass("mpog_hidden_field"); - }; - - - SelectFieldChoices.prototype.actualFieldIsInput = function() { - return this.getCurrentStateElement().attr("type") === "text"; - }; - - - return SelectFieldChoices; -}); diff --git a/public/static/governmental_powers.txt b/public/static/governmental_powers.txt deleted file mode 100644 index d798c3a..0000000 --- a/public/static/governmental_powers.txt +++ /dev/null @@ -1,4 +0,0 @@ -Executivo -Legislativo -Judiciário -Não se aplica diff --git a/public/static/governmental_sphere.txt b/public/static/governmental_sphere.txt deleted file mode 100644 index ef7cfce..0000000 --- a/public/static/governmental_sphere.txt +++ /dev/null @@ -1,4 +0,0 @@ -Federal -Estadual -Distrital -Municipal diff --git a/public/static/juridical_nature.txt b/public/static/juridical_nature.txt deleted file mode 100644 index d66b9a7..0000000 --- a/public/static/juridical_nature.txt +++ /dev/null @@ -1,8 +0,0 @@ -Administração Direta -Autarquia -Empresa Pública -Fundação -Orgão Autônomo -Sociedade -Sociedade Civil -Sociedade de Economia Mista diff --git a/public/style.css b/public/style.css deleted file mode 100644 index c1fdab2..0000000 --- a/public/style.css +++ /dev/null @@ -1,26 +0,0 @@ -#complete_registration { - padding: 5px; - width: 100%; - background-color: #fff; -} - -#complete_registration a { - text-decoration: none; -} - -#complete_registration a:hover { - font-weight: bold; -} - -#complete_registration_percentage { - width: 100%; - height: 20px; - background: #fff; - border: solid 1px #000; -} - -.highlight-error { - outline: none; - border-color: #FF0000; - box-shadow: 0 0 10px #FF0000; -} diff --git a/public/vendor/jquery.js b/public/vendor/jquery.js deleted file mode 100644 index a3f4ebf..0000000 --- a/public/vendor/jquery.js +++ /dev/null @@ -1,3 +0,0 @@ -modulejs.define('jquery', function() { - return jQuery; -}); diff --git a/public/vendor/jquery.maskedinput.min.js b/public/vendor/jquery.maskedinput.min.js deleted file mode 100644 index 0d9ce6e..0000000 --- a/public/vendor/jquery.maskedinput.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - Masked Input plugin for jQuery - Copyright (c) 2007-2013 Josh Bush (digitalbush.com) - Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license) - Version: 1.3.1 -*/ -(function(e){function t(){var e=document.createElement("input"),t="onpaste";return e.setAttribute(t,""),"function"==typeof e[t]?"paste":"input"}var n,a=t()+".mask",r=navigator.userAgent,i=/iphone/i.test(r),o=/android/i.test(r);e.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},dataName:"rawMaskFn",placeholder:"_"},e.fn.extend({caret:function(e,t){var n;if(0!==this.length&&!this.is(":hidden"))return"number"==typeof e?(t="number"==typeof t?t:e,this.each(function(){this.setSelectionRange?this.setSelectionRange(e,t):this.createTextRange&&(n=this.createTextRange(),n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",e),n.select())})):(this[0].setSelectionRange?(e=this[0].selectionStart,t=this[0].selectionEnd):document.selection&&document.selection.createRange&&(n=document.selection.createRange(),e=0-n.duplicate().moveStart("character",-1e5),t=e+n.text.length),{begin:e,end:t})},unmask:function(){return this.trigger("unmask")},mask:function(t,r){var c,l,s,u,f,h;return!t&&this.length>0?(c=e(this[0]),c.data(e.mask.dataName)()):(r=e.extend({placeholder:e.mask.placeholder,completed:null},r),l=e.mask.definitions,s=[],u=h=t.length,f=null,e.each(t.split(""),function(e,t){"?"==t?(h--,u=e):l[t]?(s.push(RegExp(l[t])),null===f&&(f=s.length-1)):s.push(null)}),this.trigger("unmask").each(function(){function c(e){for(;h>++e&&!s[e];);return e}function d(e){for(;--e>=0&&!s[e];);return e}function m(e,t){var n,a;if(!(0>e)){for(n=e,a=c(t);h>n;n++)if(s[n]){if(!(h>a&&s[n].test(R[a])))break;R[n]=R[a],R[a]=r.placeholder,a=c(a)}b(),x.caret(Math.max(f,e))}}function p(e){var t,n,a,i;for(t=e,n=r.placeholder;h>t;t++)if(s[t]){if(a=c(t),i=R[t],R[t]=n,!(h>a&&s[a].test(i)))break;n=i}}function g(e){var t,n,a,r=e.which;8===r||46===r||i&&127===r?(t=x.caret(),n=t.begin,a=t.end,0===a-n&&(n=46!==r?d(n):a=c(n-1),a=46===r?c(a):a),k(n,a),m(n,a-1),e.preventDefault()):27==r&&(x.val(S),x.caret(0,y()),e.preventDefault())}function v(t){var n,a,i,l=t.which,u=x.caret();t.ctrlKey||t.altKey||t.metaKey||32>l||l&&(0!==u.end-u.begin&&(k(u.begin,u.end),m(u.begin,u.end-1)),n=c(u.begin-1),h>n&&(a=String.fromCharCode(l),s[n].test(a)&&(p(n),R[n]=a,b(),i=c(n),o?setTimeout(e.proxy(e.fn.caret,x,i),0):x.caret(i),r.completed&&i>=h&&r.completed.call(x))),t.preventDefault())}function k(e,t){var n;for(n=e;t>n&&h>n;n++)s[n]&&(R[n]=r.placeholder)}function b(){x.val(R.join(""))}function y(e){var t,n,a=x.val(),i=-1;for(t=0,pos=0;h>t;t++)if(s[t]){for(R[t]=r.placeholder;pos++a.length)break}else R[t]===a.charAt(pos)&&t!==u&&(pos++,i=t);return e?b():u>i+1?(x.val(""),k(0,h)):(b(),x.val(x.val().substring(0,i+1))),u?t:f}var x=e(this),R=e.map(t.split(""),function(e){return"?"!=e?l[e]?r.placeholder:e:void 0}),S=x.val();x.data(e.mask.dataName,function(){return e.map(R,function(e,t){return s[t]&&e!=r.placeholder?e:null}).join("")}),x.attr("readonly")||x.one("unmask",function(){x.unbind(".mask").removeData(e.mask.dataName)}).bind("focus.mask",function(){clearTimeout(n);var e;S=x.val(),e=y(),n=setTimeout(function(){b(),e==t.length?x.caret(0,e):x.caret(e)},10)}).bind("blur.mask",function(){y(),x.val()!=S&&x.change()}).bind("keydown.mask",g).bind("keypress.mask",v).bind(a,function(){setTimeout(function(){var e=y(!0);x.caret(e),r.completed&&e==x.val().length&&r.completed.call(x)},0)}),y()}))}})})(jQuery); \ No newline at end of file diff --git a/public/vendor/modulejs-1.5.0.min.js b/public/vendor/modulejs-1.5.0.min.js deleted file mode 100644 index 9905b63..0000000 --- a/public/vendor/modulejs-1.5.0.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/* modulejs 1.5.0 - http://larsjung.de/modulejs/ */ -!function(n){this.modulejs=n()}(function(){"use strict";function n(n){return function(r){return l.toString.call(r)==="[object "+n+"]"}}function r(n){return n===new Object(n)}function t(n,r){return l.hasOwnProperty.call(n,r)}function e(n,r,e){if(p&&n.forEach===p)n.forEach(r,e);else if(n.length===+n.length)for(var i=0,o=n.length;o>i;i+=1)r.call(e,n[i],i,n);else for(var u in n)t(n,u)&&r.call(e,n[u],u,n)}function i(n,r){for(var t=0,e=n.length;e>t;t+=1)if(n[t]===r)return!0;return!1}function o(n){var r={},i=[];return e(n,function(n){t(r,n)||(i.push(n),r[n]=1)}),i}function u(n,r,t){if(n){var e=new Error("[modulejs-"+r+"] "+t);throw e.code=r,e}}function c(n,r,a){if(u(!h(n),31,'id must be a string "'+n+'"'),!r&&t(b,n))return b[n];var f=y[n];u(!f,32,'id not defined "'+n+'"'),a=(a||[]).slice(0),a.push(n);var s=[];if(e(f.deps,function(n){u(i(a,n),33,"circular dependencies: "+a+" & "+n),r?(s=s.concat(c(n,r,a)),s.push(n)):s.push(c(n,r,a))}),r)return o(s);var d=f.fn.apply(void 0,s);return b[n]=d,d}function a(n,t,e){void 0===e&&(e=t,t=[]),u(!h(n),11,'id must be a string "'+n+'"'),u(y[n],12,'id already defined "'+n+'"'),u(!g(t),13,'dependencies for "'+n+'" must be an array "'+t+'"'),u(!r(e)&&!v(e),14,'arg for "'+n+'" must be object or function "'+e+'"'),y[n]={id:n,deps:t,fn:v(e)?e:function(){return e}}}function f(n){return c(n)}function s(){var n={};return e(y,function(r,e){n[e]={deps:r.deps.slice(0),reqs:c(e,!0),init:t(b,e)}}),e(y,function(r,t){var o=[];e(y,function(r,e){i(n[e].reqs,t)&&o.push(e)}),n[t].reqd=o}),n}function d(n){var r="\n";return e(s(),function(t,e){var i=n?t.reqd:t.reqs;r+=(t.init?"* ":" ")+e+" -> [ "+i.join(", ")+" ]\n"}),r}var l=Object.prototype,p=Array.prototype.forEach,h=n("String"),v=n("Function"),g=Array.isArray||n("Array"),y={},b={};return{define:a,require:f,state:s,log:d,_private:{isString:h,isFunction:v,isArray:g,isObject:r,has:t,each:e,contains:i,uniq:o,err:u,definitions:y,instances:b,resolve:c}}}); \ No newline at end of file diff --git a/public/views/complete-registration.js b/public/views/complete-registration.js deleted file mode 100644 index 81dd745..0000000 --- a/public/views/complete-registration.js +++ /dev/null @@ -1,60 +0,0 @@ -modulejs.define('CompleteRegistration', ['jquery', 'NoosferoRoot'], function($, NoosferoRoot) { - 'use strict'; - - - var AJAX_URL = { - hide_registration_incomplete_percentage: - NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/hide_registration_incomplete_percentage") - }; - - - function hide_incomplete_percentage(evt) { - evt.preventDefault(); - - jQuery.get(AJAX_URL.hide_registration_incomplete_percentage, {hide:true}, function(response){ - if( response === true ) { - jQuery("#complete_registration").fadeOut(); - } - }); - } - - - function show_complete_progressbar() { - var percentage = jQuery("#complete_registration_message span").html(); - var canvas_tag = document.getElementById("complete_registration_percentage"); - - if( canvas_tag !== null ) { - var context = canvas_tag.getContext("2d"); - - percentage = canvas_tag.width*(percentage/100.0); - - context.beginPath(); - context.rect(0, 0, percentage, canvas_tag.height); - context.fillStyle = '#00FF00'; - context.fill(); - } - } - - - function repositioning_bar_percentage() { - var complete_message = $("#complete_registration").remove(); - - $(".profile-info-options").before(complete_message); - } - - - return { - isCurrentPage: function() { - return $("#complete_registration").length === 1; - }, - - - init: function() { - repositioning_bar_percentage(); - - jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); - - show_complete_progressbar(); - } - } -}); diff --git a/public/views/control-panel.js b/public/views/control-panel.js deleted file mode 100644 index d89a588..0000000 --- a/public/views/control-panel.js +++ /dev/null @@ -1,32 +0,0 @@ -modulejs.define('ControlPanel', ['jquery'], function($) { - 'use strict'; - - 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_institution_on_control_panel(control_panel); - } - } - - - return { - isCurrentPage: function() { - return $("#profile-editor-index").length === 1; - }, - - - init: function() { - add_itens_on_controla_panel(); - } - } -}); diff --git a/public/views/create-institution.js b/public/views/create-institution.js deleted file mode 100644 index 354295c..0000000 --- a/public/views/create-institution.js +++ /dev/null @@ -1,406 +0,0 @@ -modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'], function($, NoosferoRoot, SelectElement) { - 'use strict'; - - var AJAX_URL = { - create_institution_modal: - NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/create_institution"), - new_institution: - NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/new_institution"), - institution_already_exists: - NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/institution_already_exists"), - get_institutions: - NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/get_institutions"), - auto_complete_city: - NoosferoRoot.urlWithSubDirectory("/account/search_cities") - }; - - - 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("

"+response.message+"

"); - $("#create_institution_errors").switchClass("show-field", "hide-field"); - - $(".institution_container").append(get_clone_institution_data(institution_id)); - add_selected_institution_to_list(institution_id, institution_name); - - $(".remove-institution").click(remove_institution); - } else { - var errors = create_error_list(response); - $("#create_institution_errors").switchClass("hide-field", "show-field").html("

"+response.message+"

"+errors); - - show_errors_in_each_field(response.errors); - } - } - - function create_error_list(response){ - var errors = "
    "; - var field_name; - - for(var error_key in response.errors) { - field_name = adjust_error_key(error_key); - - if(response.errors[error_key].length > 0){ - errors += "
  • "+field_name+": "+response.errors[error_key]+"
  • "; - } - } - - errors += "
"; - return errors; - } - - - function show_errors_in_each_field(errors) { - var error_keys = Object.keys(errors); - - // (field)|(field)|... - var verify_error = new RegExp("(\\[" + error_keys.join("\\])|(\\[") + "\\])" ); - - var fields_with_errors = $("#institution_dialog .formfield input").filter(function(index, field) { - $(field).removeClass("highlight-error"); - return verify_error.test(field.getAttribute("name")); - }); - - var selects_with_errors = $("#institution_dialog .formfield select").filter(function(index, field) { - $(field).removeClass("highlight-error"); - return verify_error.test(field.getAttribute("name")); - }); - - fields_with_errors.addClass("highlight-error"); - selects_with_errors.addClass("highlight-error"); - } - - - function adjust_error_key(error_key) { - var text = error_key.replace(/_/, " "); - text = text.charAt(0).toUpperCase() + text.slice(1); - - return text; - } - - - function save_institution(evt) { - evt.preventDefault(); - - open_loading($("#loading_message").val()); - $.ajax({ - url: AJAX_URL.new_institution, - data : get_post_data(), - type: "POST", - success: success_ajax_response, - error: function() { - close_loading(); - var error_message = $("#institution_error_message").val(); - $("#create_institution_errors").switchClass("hide-field", "show-field").html("

"+error_message+"

"); - } - }); - } - - function cancel_institution(evt){ - evt.preventDefault(); - $('#institution_dialog').dialog('close'); - } - - - function institution_already_exists(){ - if( this.value.length >= 3 ) { - $.get(AJAX_URL.institution_already_exists, {name:this.value}, function(response){ - if( response === true ) { - $("#already_exists_text").switchClass("hide-field", "show-field"); - } else { - $("#already_exists_text").switchClass("show-field", "hide-field"); - } - }); - } - } - - - function get_clone_institution_data(value) { - var user_institutions = $(".user_institutions").first().clone(); - user_institutions.val(value); - - return user_institutions; - } - - - function institution_autocomplete() { - $("#input_institution").autocomplete({ - source : function(request, response){ - $.ajax({ - type: "GET", - url: AJAX_URL.get_institutions, - data: {query: request.term}, - success: function(result){ - response(result); - - if( result.length === 0 ) { - $('#institution_empty_ajax_message').switchClass("hide-field", "show-field"); - } else { - $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); - } - }, - error: function(ajax, stat, errorThrown) { - console.log('Link not found : ' + errorThrown); - } - }); - }, - - minLength: 2, - - select : function (event, selected) { - $("#institution_selected").val(selected.item.id).attr("data-name", selected.item.label); - } - }); - } - - - function add_selected_institution_to_list(id, name) { - var selected_institution = "
  • "+name; - selected_institution += "
  • "; - - $(".institutions_added").append(selected_institution); - } - - - function add_new_institution(evt) { - evt.preventDefault(); - var selected = $("#institution_selected"); - var institution_already_added = $(".institutions_added li[data-institution='"+selected.val()+"']").length; - - if(selected.val().length > 0 && institution_already_added === 0) { - //field that send the institutions to the server - $(".institution_container").append(get_clone_institution_data(selected.val())); - - // Visualy add the selected institution to the list - add_selected_institution_to_list(selected.val(), selected.attr("data-name")); - - // clean the institution flag - selected.val("").attr("data-name", ""); - $("#input_institution").val(""); - - $(".remove-institution").click(remove_institution); - } - } - - - function remove_institution(evt) { - evt.preventDefault(); - var code = $(this).parent().attr("data-institution"); - - $(".user_institutions[value="+code+"]").remove(); - $(this).parent().remove(); - } - - - function add_mask_to_form_items() { - if ($.mask) { - $("#institutions_cnpj").mask("99.999.999/9999-99"); - } - } - - - function show_hide_cnpj_city(country) { - var cnpj = $("#institutions_cnpj").parent().parent(); - var city = $("#community_city").parent().parent(); - var state = $("#community_state").parent().parent(); - var inst_type = $("input[name='institutions[type]']:checked").val(); - institution_type_actions(inst_type); - - if( country === "-1" ) $("#community_country").val("BR"); - - if( country !== "BR" ) { - cnpj.hide(); - city.hide(); - state.hide(); - } else { - cnpj.show(); - city.show(); - state.show(); - } - } - - function institution_type_actions(type) { - var country = $("#community_country").val(); - if( type === "PublicInstitution" && country == "BR") { - show_public_institutions_fields(); - } else { - show_private_institutions_fields(); - } - } - - - function set_form_count_custom_data() { - var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); - var default_option = SelectElement.generateOption("BR", "Brazil"); - - - var inst_type = $("input[name='institutions[type]']:checked").val(); - var country = $("#community_country").val(); - - institution_type_actions(inst_type); - show_hide_cnpj_city(country); - - if( $('#community_country').find("option[value='']").length === 1 ) { - $('#community_country').find("option[value='']").remove(); - $('#community_country').prepend(divisor_option); - $('#community_country').prepend(default_option); - - if($("#edit_institution_page").val() === "false") { - $('#community_country').val("BR"); - show_hide_cnpj_city($('#community_country').val()); - } - } - } - - function autoCompleteCity() { - var country_selected = $('#community_country').val(); - - if(country_selected == "BR") { - $('#community_city').autocomplete({ - source : function(request, response){ - $.ajax({ - type: "GET", - url: AJAX_URL.auto_complete_city, - data: {city_name: request.term, state_name: $("#community_state").val()}, - success: function(result){ - response(result); - - // There are two autocompletes in this page, the last one is modal - // autocomplete just put it above the modal - $(".ui-autocomplete").last().css("z-index", 1000); - }, - error: function(ajax, stat, errorThrown) { - console.log('Link not found : ' + errorThrown); - } - }); - }, - - minLength: 3 - }); - } else { - if ($('#community_city').data('autocomplete')) { - $('#community_city').autocomplete("destroy"); - $('#community_city').removeData('autocomplete'); - } - } - } - - function set_events() { - $("#create_institution_link").click(open_create_institution_modal); - - $("input[name='institutions[type]']").click(function(){ - institution_type_actions(this.value); - }); - - $('#save_institution_button').click(save_institution); - $('#cancel_institution_button').click(cancel_institution); - - $("#community_name").keyup(institution_already_exists); - - $("#add_new_institution").click(add_new_institution); - - $(".remove-institution").click(remove_institution); - - $("#community_country").change(function(){ - show_hide_cnpj_city(this.value); - }); - - add_mask_to_form_items(); - - institution_autocomplete(); - - autoCompleteCity(); - $('#community_country').change(function(){ - autoCompleteCity(); - }); - } - - - return { - isCurrentPage: function() { - return $("#institution_form").length === 1; - }, - - - init: function() { - set_form_count_custom_data(); - set_events(); - }, - - institution_autocomplete: function(){ - institution_autocomplete(); - } - }; -}); diff --git a/public/views/gov-user-comments-extra-fields.js b/public/views/gov-user-comments-extra-fields.js deleted file mode 100644 index d302437..0000000 --- a/public/views/gov-user-comments-extra-fields.js +++ /dev/null @@ -1,26 +0,0 @@ -modulejs.define("GovUserCommentsExtraFields", ['jquery','CreateInstitution'], function($,CreateInstitution) { - - function set_events() { - CreateInstitution.institution_autocomplete(); - } - - - function prepend_to_additional_information() { - var institution_comments = $("#input_institution_comments").remove(); - - $(".comments-software-extra-fields").prepend(institution_comments); - } - - - return { - isCurrentPage: function() { - return $(".star-rate-form").length === 1; - }, - - init: function() { - prepend_to_additional_information(); - set_events(); - } - } - -}) diff --git a/public/views/new-community.js b/public/views/new-community.js deleted file mode 100644 index b665e8f..0000000 --- a/public/views/new-community.js +++ /dev/null @@ -1,28 +0,0 @@ -modulejs.define("NewCommunity", ['jquery'], function($) { - - function replace_mandatory_message() { - $(".required-field").first() - .replaceWith(" Os campos em destaque são obrigatórios. "); - } - - function remove_image_builder_text() { - $("label:contains('Image builder')").hide(); - } - - function hide_organization_template_fields(){ - $('#template-options').hide(); - } - - return { - - isCurrentPage: function() { - return true; - }, - - init: function() { - replace_mandatory_message(); - remove_image_builder_text(); - hide_organization_template_fields(); - } - } -}) diff --git a/public/views/user-edit-profile.js b/public/views/user-edit-profile.js deleted file mode 100644 index c92c987..0000000 --- a/public/views/user-edit-profile.js +++ /dev/null @@ -1,216 +0,0 @@ -modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoices', 'CreateInstitution'], function($, SelectElement, SelectFieldChoices, CreateInstitution) { - 'use strict'; - - function set_form_count_custom_data() { - var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); - var default_option = SelectElement.generateOption("BR", "Brazil"); - - $('#profile_data_country').find("option[value='']").remove(); - $('#profile_data_country').prepend(divisor_option); - $('#profile_data_country').prepend(default_option); - $('#profile_data_country').val("BR"); - } - - - function set_initial_form_custom_data(selectFieldChoices) { - set_form_count_custom_data(); - - $("#password-balloon").html($("#user_password_menssage").val()); - $("#profile_data_email").parent().append($("#email_public_message").remove()); - - if( $("#state_field").length !== 0 ) selectFieldChoices.replaceStateWithSelectElement(); - } - - - function show_state_if_country_is_brazil() { - var selectFieldChoices = new SelectFieldChoices("#state_field", "#city_field", "/plugin/gov_user/get_brazil_states"); - set_initial_form_custom_data(selectFieldChoices); - - $("#profile_data_country").change(function(){ - if( this.value === "-1" ) $(this).val("BR"); - - if( this.value === "BR" && selectFieldChoices.actualFieldIsInput() ) { - selectFieldChoices.replaceStateWithSelectElement(); - selectFieldChoices.showCity(); - } else if( this.value !== "BR" && !selectFieldChoices.actualFieldIsInput() ) { - selectFieldChoices.replaceStateWithInputElement(); - selectFieldChoices.hideCity(); - } - }); - } - - - function show_or_hide_phone_mask() { - if($("#profile_data_country").val() === "BR") { - if( (typeof $("#profile_data_cell_phone").data("rawMaskFn") === 'undefined') ) { - // $("#profile_data_cell_phone").mask("(99) 9999?9-9999"); - // $("#profile_data_comercial_phone").mask("(99) 9999?9-9999"); - // $("#profile_data_contact_phone").mask("(99) 9999?9-9999"); - } - } else { - // $("#profile_data_cell_phone").unmask(); - // $("#profile_data_comercial_phone").unmask(); - // $("#profile_data_contact_phone").unmask(); - } - } - - - function fix_phone_mask_format(id) { - $(id).blur(function() { - var last = $(this).val().substr( $(this).val().indexOf("-") + 1 ); - - if( last.length === 3 ) { - var move = $(this).val().substr( $(this).val().indexOf("-") - 1, 1 ); - var lastfour = move + last; - var first = $(this).val().substr( 0, 9 ); - - $(this).val( first + '-' + lastfour ); - } - }); - } - - - function show_plugin_error_message(field_selector, hidden_message_id ) { - var field = $(field_selector); - - field.removeClass("validated").addClass("invalid"); - - if(!$("." + hidden_message_id)[0]) { - var message = $("#" + hidden_message_id).val(); - field.parent().append("
    "+message+""); - } else { - $("." + hidden_message_id).show(); - } - } - - - function hide_plugin_error_message(field_selector, hidden_message_id) { - $(field_selector).removeClass("invalid").addClass("validated"); - $("." + hidden_message_id).hide(); - } - - - function add_blur_fields(field_selector, hidden_message_id, validation_function, allow_blank) { - $(field_selector).blur(function(){ - $(this).attr("class", ""); - - if( validation_function(this.value, !!allow_blank) ) { - show_plugin_error_message(field_selector, hidden_message_id); - } else { - hide_plugin_error_message(field_selector, hidden_message_id); - } - }); - } - - - function invalid_email_validation(value, allow_blank) { - if( allow_blank && value.trim().length === 0 ) { - return false; - } - - var correct_format_regex = new RegExp(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/); - - return !correct_format_regex.test(value); - } - - - function invalid_site_validation(value) { - var correct_format_regex = new RegExp(/(^|)(http[s]{0,1})\:\/\/(\w+[.])\w+/g); - - return !correct_format_regex.test(value); - } - - - function get_privacy_selector_parent_div(field_id, actual) { - if( actual === undefined ) actual = $(field_id); - - if( actual.is("form") || actual.length === 0 ) return null; // Not allow recursion over form - - if( actual.hasClass("field-with-privacy-selector") ) { - return actual; - } else { - return get_privacy_selector_parent_div(field_id, actual.parent()); - } - } - - - function try_to_remove(list, field) { - try { - list.push(field.remove()); - } catch(e) { - console.log("Cound not remove field"); - } - } - - - function get_edit_fields_in_insertion_order() { - var containers = []; - - try_to_remove(containers, get_privacy_selector_parent_div("#city_field")); - try_to_remove(containers, get_privacy_selector_parent_div("#state_field")); - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_country")); - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_birth_date")); - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_organization_website")); - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_personal_website")); - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_comercial_phone")); - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_contact_phone")); - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_cell_phone")); - try_to_remove(containers, $("#select_institution")); - try_to_remove(containers, $("#user_secondary_email").parent().parent()); - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_email")); - try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_name")); - try_to_remove(containers, $(".pseudoformlabel").parent().parent()); - try_to_remove(containers, $("h2")[0]); - - return containers; - } - - - function change_edit_fields_order() { - var form = $("#profile-data"); - - if( form.length !== 0 ) { - var containers = get_edit_fields_in_insertion_order(); - - containers.forEach(function(container){ - form.prepend(container); - }); - } - } - - - function set_fields_validations() { - $("#profile_data_country").blur(show_or_hide_phone_mask); - - // $("#profile_data_birth_date").mask("99/99/9999"); - - fix_phone_mask_format("#profile_data_cell_phone"); - fix_phone_mask_format("#profile_data_comercial_phone"); - fix_phone_mask_format("#profile_data_contact_phone"); - - add_blur_fields("#profile_data_email", "email_error", invalid_email_validation); - add_blur_fields("#user_secondary_email", "email_error", invalid_email_validation, true); - add_blur_fields("#profile_data_personal_website", "site_error", invalid_site_validation); - add_blur_fields("#profile_data_organization_website", "site_error", invalid_site_validation); - } - - - return { - isCurrentPage: function() { - return $('#profile_data_email').length === 1; - }, - - - init: function() { - change_edit_fields_order(); // To change the fields order, it MUST be the first function executed - - show_state_if_country_is_brazil(); - - show_or_hide_phone_mask(); - - set_fields_validations(); - - CreateInstitution.init(); - } - } -}); diff --git a/src/gov_user/.gitignore b/src/gov_user/.gitignore new file mode 100644 index 0000000..783cd5b --- /dev/null +++ b/src/gov_user/.gitignore @@ -0,0 +1,2 @@ +*.swp + diff --git a/src/gov_user/controllers/gov_user_plugin_controller.rb b/src/gov_user/controllers/gov_user_plugin_controller.rb new file mode 100644 index 0000000..80a41db --- /dev/null +++ b/src/gov_user/controllers/gov_user_plugin_controller.rb @@ -0,0 +1,251 @@ +#aqui deve ter so usuario e instituicao +class GovUserPluginController < ApplicationController + + def hide_registration_incomplete_percentage + response = false + + if request.xhr? && params[:hide] + session[:hide_incomplete_percentage] = true + response = session[:hide_incomplete_percentage] + end + + render :json=>response.to_json + end + + def create_institution + @show_sisp_field = environment.admins.include?(current_user.person) + @state_list = get_state_list() + @governmental_sphere = [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]} + @governmental_power = [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]} + @juridical_nature = [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]} + @state_options = [[_('Select a state'), '-1']] | @state_list.collect {|state| [state.name, state.name]} + + params[:community] ||= {} + params[:institutions] ||= {} + + if request.xhr? + render :layout=>false + else + redirect_to "/" + end + end + + def split_http_referer http_referer + split_list = [] + split_list = http_referer.split("/") + @url_token = split_list.last + return @url_token + end + + def create_institution_admin + @show_sisp_field = environment.admins.include?(current_user.person) + @state_list = get_state_list() + @governmental_sphere = [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]} + @governmental_power = [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]} + @juridical_nature = [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]} + @state_options = [[_('Select a state'), '-1']] | @state_list.collect {|state| [state.name, state.name]} + + @url_token = split_http_referer request.original_url() + + params[:community] ||= {} + params[:institutions] ||= {} + + end + + def new_institution + redirect_to "/" if params[:community].blank? || params[:institutions].blank? + + response_message = {} + + institution_template = Community["institution"] + add_template_in_params institution_template + + @institutions = private_create_institution + add_environment_admins_to_institution @institutions + + response_message = save_institution @institutions + + if request.xhr? #User create institution + render :json => response_message.to_json + else #Admin create institution + session[:notice] = response_message[:message] # consume the notice + + redirect_depending_on_institution_creation response_message + end + end + + def institution_already_exists + redirect_to "/" if !request.xhr? || params[:name].blank? + + already_exists = !Community.where(:name=>params[:name]).empty? + + render :json=>already_exists.to_json + end + + def get_institutions + redirect_to "/" if !request.xhr? || params[:query].blank? + + list = Institution.search_institution(params[:query]).map{ |institution| + {:value=>institution.name, :id=>institution.id} + } + + render :json => list.to_json + end + + def get_brazil_states + redirect_to "/" unless request.xhr? + + state_list = get_state_list() + render :json=>state_list.collect {|state| state.name }.to_json + 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 + case params[:field] + when "software_language" + return ProgrammingLanguage + else + return DatabaseDescription + end + end + + def get_state_list + NationalRegion.find( + :all, + :conditions=>["national_region_type_id = ?", 2], + :order=>"name" + ) + end + + def set_institution_type + institution_params = params[:institutions].except(:governmental_power, + :governmental_sphere, + :juridical_nature + ) + if params[:institutions][:type] == "PublicInstitution" + PublicInstitution::new institution_params + else + PrivateInstitution::new institution_params + end + end + + def set_public_institution_fields institution + inst_fields = params[:institutions] + + begin + gov_power = GovernmentalPower.find inst_fields[:governmental_power] + gov_sphere = GovernmentalSphere.find inst_fields[:governmental_sphere] + jur_nature = JuridicalNature.find inst_fields[:juridical_nature] + + institution.juridical_nature = jur_nature + institution.governmental_power = gov_power + institution.governmental_sphere = gov_sphere + rescue + institution.errors.add( + :governmental_fields, + _("Could not find Governmental Power or Governmental Sphere") + ) + end + end + + def private_create_institution + community = Community.new(params[:community]) + community.environment = environment + institution = set_institution_type + + institution.name = community[:name] + institution.community = community + + if institution.type == "PublicInstitution" + set_public_institution_fields institution + end + + institution.date_modification = DateTime.now + institution.save + institution + end + + def add_template_in_params institution_template + com_fields = params[:community] + if !institution_template.blank? && institution_template.is_template + com_fields[:template_id]= institution_template.id unless com_fields.blank? + end + end + + def add_environment_admins_to_institution institution + edit_page = params[:edit_institution_page] == false + if environment.admins.include?(current_user.person) && edit_page + environment.admins.each do |adm| + institution.community.add_admin(adm) + end + end + end + + def save_institution institution + inst_errors = institution.errors.messages + com_errors = institution.community.errors.messages + + set_errors institution + + if inst_errors.empty? && com_errors.empty? && institution.valid? && institution.save + { :success => true, + :message => _("Institution successful created!"), + :institution_data => {:name=>institution.name, :id=>institution.id} + } + else + { :success => false, + :message => _("Institution could not be created!"), + :errors => inst_errors.merge(com_errors) + } + end + end + + def redirect_depending_on_institution_creation response_message + if response_message[:success] + redirect_to :controller => "/admin_panel", :action => "index" + else + flash[:errors] = response_message[:errors] + + redirect_to :controller => "gov_user_plugin", :action => "create_institution_admin", :params => params + end + end + + def set_errors institution + institution.valid? if institution + institution.community.valid? if institution.community + + flash[:error_community_name] = institution.community.errors.include?(:name) ? "highlight-error" : "" + flash[:error_community_country] = institution.errors.include?(:country) ? "highlight-error" : "" + flash[:error_community_state] = institution.errors.include?(:state) ? "highlight-error" : "" + flash[:error_community_city] = institution.errors.include?(:city) ? "highlight-error" : "" + flash[:error_institution_corporate_name] = institution.errors.include?(:corporate_name) ? "highlight-error" : "" + flash[:error_institution_cnpj] = institution.errors.include?(:cnpj) ? "highlight-error" : "" + flash[:error_institution_governmental_sphere] = institution.errors.include?(:governmental_sphere) ? "highlight-error" : "" + flash[:error_institution_governmental_power] = institution.errors.include?(:governmental_power) ? "highlight-error" : "" + flash[:error_institution_juridical_nature] = institution.errors.include?(:juridical_nature) ? "highlight-error" : "" + flash[:error_institution_sisp] = institution.errors.include?(:sisp) ? "highlight-error" : "" + end + +end diff --git a/src/gov_user/controllers/gov_user_plugin_myprofile_controller.rb b/src/gov_user/controllers/gov_user_plugin_myprofile_controller.rb new file mode 100644 index 0000000..6b4d03e --- /dev/null +++ b/src/gov_user/controllers/gov_user_plugin_myprofile_controller.rb @@ -0,0 +1,50 @@ +class GovUserPluginMyprofileController < MyProfileController + append_view_path File.join(File.dirname(__FILE__) + '/../views') + + def index + end + + def edit_institution + @show_sisp_field = environment.admins.include?(current_user.person) + @state_list = NationalRegion.find( + :all, + :conditions => { :national_region_type_id => 2 }, + :order => 'name' + ) + @institution = @profile.institution + update_institution if request.post? + end + + private + + def update_institution + @institution.community.update_attributes(params[:community]) + @institution.update_attributes(params[:institutions].except(:governmental_power, :governmental_sphere, :juridical_nature)) + if @institution.type == "PublicInstitution" + begin + governmental_updates + rescue + @institution.errors.add(:governmental_fields, + _("Could not find Governmental Power or Governmental Sphere")) + end + end + if @institution.valid? + redirect_to :controller => 'profile_editor', :action => 'index', :profile => profile.identifier + else + flash[:errors] = @institution.errors.full_messages + end + end + + def governmental_updates + gov_power = GovernmentalPower.find params[:institutions][:governmental_power] + gov_sphere = GovernmentalSphere.find params[:institutions][:governmental_sphere] + jur_nature = JuridicalNature.find params[:institutions][:juridical_nature] + + @institution.juridical_nature = jur_nature + @institution.governmental_power = gov_power + @institution.governmental_sphere = gov_sphere + @institution.save + end + + +end diff --git a/src/gov_user/db/migrate/20140528193816_add_extra_fields_to_user.rb b/src/gov_user/db/migrate/20140528193816_add_extra_fields_to_user.rb new file mode 100644 index 0000000..087fc62 --- /dev/null +++ b/src/gov_user/db/migrate/20140528193816_add_extra_fields_to_user.rb @@ -0,0 +1,17 @@ +class AddExtraFieldsToUser < ActiveRecord::Migration + def self.up + change_table :users do |t| + t.string :secondary_email + t.references :institution + t.string :role + end + end + + def self.down + change_table :users do |t| + t.remove :secondary_email + t.remove_references :institution + t.remove :role + end + end +end diff --git a/src/gov_user/db/migrate/20140528193835_create_institutions_table.rb b/src/gov_user/db/migrate/20140528193835_create_institutions_table.rb new file mode 100644 index 0000000..294c791 --- /dev/null +++ b/src/gov_user/db/migrate/20140528193835_create_institutions_table.rb @@ -0,0 +1,13 @@ +class CreateInstitutionsTable < ActiveRecord::Migration + def self.up + create_table :institutions do |t| + t.string :name + + t.timestamps + end + end + + def self.down + drop_table :institutions + end +end diff --git a/src/gov_user/db/migrate/20140617125143_add_new_fields_institution.rb b/src/gov_user/db/migrate/20140617125143_add_new_fields_institution.rb new file mode 100644 index 0000000..70ecf88 --- /dev/null +++ b/src/gov_user/db/migrate/20140617125143_add_new_fields_institution.rb @@ -0,0 +1,27 @@ +class AddNewFieldsInstitution < ActiveRecord::Migration + def up + add_column :institutions, :acronym, :string + add_column :institutions, :unit_code, :integer + add_column :institutions, :parent_code, :integer + add_column :institutions, :unit_type, :string + add_column :institutions, :juridical_nature, :string + add_column :institutions, :sub_juridical_nature, :string + add_column :institutions, :normalization_level, :string + add_column :institutions, :version, :string + add_column :institutions, :cnpj, :string + add_column :institutions, :type, :string + end + + def down + remove_column :institutions, :acronym + remove_column :institutions, :unit_code + remove_column :institutions, :parent_code + remove_column :institutions, :unit_type + remove_column :institutions, :juridical_nature + remove_column :institutions, :sub_juridical_nature + remove_column :institutions, :normalization_level + remove_column :institutions, :version + remove_column :institutions, :cnpj + remove_column :institutions, :type + end +end diff --git a/src/gov_user/db/migrate/20140617132133_create_governmental_spheres.rb b/src/gov_user/db/migrate/20140617132133_create_governmental_spheres.rb new file mode 100644 index 0000000..22c1fc7 --- /dev/null +++ b/src/gov_user/db/migrate/20140617132133_create_governmental_spheres.rb @@ -0,0 +1,19 @@ +class CreateGovernmentalSpheres < ActiveRecord::Migration + def change + create_table :governmental_spheres do |t| + t.string :name + t.string :acronym + t.integer :unit_code + t.integer :parent_code + t.string :unit_type + t.string :juridical_nature + t.string :sub_juridical_nature + t.string :normalization_level + t.string :version + t.string :cnpj + t.string :type + + t.timestamps + end + end +end diff --git a/src/gov_user/db/migrate/20140617132451_create_governmental_powers.rb b/src/gov_user/db/migrate/20140617132451_create_governmental_powers.rb new file mode 100644 index 0000000..ce88ee7 --- /dev/null +++ b/src/gov_user/db/migrate/20140617132451_create_governmental_powers.rb @@ -0,0 +1,9 @@ +class CreateGovernmentalPowers < ActiveRecord::Migration + def change + create_table :governmental_powers do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/src/gov_user/db/migrate/20140617134556_add_references_to_institution.rb b/src/gov_user/db/migrate/20140617134556_add_references_to_institution.rb new file mode 100644 index 0000000..e5203e1 --- /dev/null +++ b/src/gov_user/db/migrate/20140617134556_add_references_to_institution.rb @@ -0,0 +1,15 @@ +class AddReferencesToInstitution < ActiveRecord::Migration + def up + change_table :institutions do |t| + t.references :governmental_power + t.references :governmental_sphere + end + end + + def down + change_table :institutions do |t| + t.remove_references :governmental_power + t.remove_references :governmental_sphere + end + end +end diff --git a/src/gov_user/db/migrate/20140630183326_add_relation_between_community_and_institution.rb b/src/gov_user/db/migrate/20140630183326_add_relation_between_community_and_institution.rb new file mode 100644 index 0000000..4dde5a9 --- /dev/null +++ b/src/gov_user/db/migrate/20140630183326_add_relation_between_community_and_institution.rb @@ -0,0 +1,13 @@ +class AddRelationBetweenCommunityAndInstitution < ActiveRecord::Migration + def up + change_table :institutions do |t| + t.references :community + end + end + + def down + change_table :institutions do |t| + t.remove_references :community + end + end +end diff --git a/src/gov_user/db/migrate/20140812143218_remove_field_role_from_user.rb b/src/gov_user/db/migrate/20140812143218_remove_field_role_from_user.rb new file mode 100644 index 0000000..e4d4fc6 --- /dev/null +++ b/src/gov_user/db/migrate/20140812143218_remove_field_role_from_user.rb @@ -0,0 +1,13 @@ +class RemoveFieldRoleFromUser < ActiveRecord::Migration + def up + change_table :users do |t| + t.remove :role + end + end + + def down + change_table :users do |t| + t.string :role + end + end +end diff --git a/src/gov_user/db/migrate/20140814125947_add_new_fields_to_public_institution.rb b/src/gov_user/db/migrate/20140814125947_add_new_fields_to_public_institution.rb new file mode 100644 index 0000000..232f50a --- /dev/null +++ b/src/gov_user/db/migrate/20140814125947_add_new_fields_to_public_institution.rb @@ -0,0 +1,11 @@ +class AddNewFieldsToPublicInstitution < ActiveRecord::Migration + def up + add_column :institutions, :sisp, :boolean, :default => false + remove_column :institutions, :juridical_nature + end + + def down + remove_column :institutions, :sisp + add_column :institutions, :juridical_nature, :string + end +end diff --git a/src/gov_user/db/migrate/20140814131606_create_juridical_natures_table.rb b/src/gov_user/db/migrate/20140814131606_create_juridical_natures_table.rb new file mode 100644 index 0000000..f2c9c18 --- /dev/null +++ b/src/gov_user/db/migrate/20140814131606_create_juridical_natures_table.rb @@ -0,0 +1,11 @@ +class CreateJuridicalNaturesTable < ActiveRecord::Migration + def up + create_table :juridical_natures do |t| + t.string :name + end + end + + def down + drop_table :juridical_natures + end +end diff --git a/src/gov_user/db/migrate/20140814134827_add_juridical_nature_reference_to_institutions_table.rb b/src/gov_user/db/migrate/20140814134827_add_juridical_nature_reference_to_institutions_table.rb new file mode 100644 index 0000000..03baff8 --- /dev/null +++ b/src/gov_user/db/migrate/20140814134827_add_juridical_nature_reference_to_institutions_table.rb @@ -0,0 +1,13 @@ +class AddJuridicalNatureReferenceToInstitutionsTable < ActiveRecord::Migration + def up + change_table :institutions do |t| + t.references :juridical_nature + end + end + + def down + change_table :institutions do |t| + t.remove_references :juridical_nature + end + end +end diff --git a/src/gov_user/db/migrate/20140815194530_register_institution_modification.rb b/src/gov_user/db/migrate/20140815194530_register_institution_modification.rb new file mode 100644 index 0000000..3183ec0 --- /dev/null +++ b/src/gov_user/db/migrate/20140815194530_register_institution_modification.rb @@ -0,0 +1,13 @@ +class RegisterInstitutionModification < ActiveRecord::Migration + def up + change_table :institutions do |t| + t.string :date_modification + end + end + + def down + change_table :institutions do |t| + t.remove :date_modification + end + end +end diff --git a/src/gov_user/db/migrate/20140818195821_remove_institution_from_user.rb b/src/gov_user/db/migrate/20140818195821_remove_institution_from_user.rb new file mode 100644 index 0000000..37486cd --- /dev/null +++ b/src/gov_user/db/migrate/20140818195821_remove_institution_from_user.rb @@ -0,0 +1,9 @@ +class RemoveInstitutionFromUser < ActiveRecord::Migration + def up + remove_column :users, :institution_id + end + + def down + add_column :users, :institution_id + end +end diff --git a/src/gov_user/db/migrate/20140818200738_create_institution_user_relation_table.rb b/src/gov_user/db/migrate/20140818200738_create_institution_user_relation_table.rb new file mode 100644 index 0000000..7068d72 --- /dev/null +++ b/src/gov_user/db/migrate/20140818200738_create_institution_user_relation_table.rb @@ -0,0 +1,12 @@ +class CreateInstitutionUserRelationTable < ActiveRecord::Migration + def up + create_table :institutions_users do |t| + t.belongs_to :user + t.belongs_to :institution + end + end + + def down + drop_table :institutions_users + end +end diff --git a/src/gov_user/db/migrate/20141103183013_add_corporate_name_to_institution.rb b/src/gov_user/db/migrate/20141103183013_add_corporate_name_to_institution.rb new file mode 100644 index 0000000..69d4a19 --- /dev/null +++ b/src/gov_user/db/migrate/20141103183013_add_corporate_name_to_institution.rb @@ -0,0 +1,9 @@ +class AddCorporateNameToInstitution < ActiveRecord::Migration + def up + add_column :institutions, :corporate_name, :string + end + + def down + remove_column :institutions, :corporate_name + end +end diff --git a/src/gov_user/db/migrate/20150910135510_add_siorg_code_to_institution.rb b/src/gov_user/db/migrate/20150910135510_add_siorg_code_to_institution.rb new file mode 100644 index 0000000..83cdec5 --- /dev/null +++ b/src/gov_user/db/migrate/20150910135510_add_siorg_code_to_institution.rb @@ -0,0 +1,9 @@ +class AddSiorgCodeToInstitution < ActiveRecord::Migration + def up + add_column :institutions, :siorg_code, :integer + end + + def down + remove_column :institutions, :siorg_code + end +end diff --git a/src/gov_user/db/migrate/20150910203559_add_institution_to_organization_rating.rb b/src/gov_user/db/migrate/20150910203559_add_institution_to_organization_rating.rb new file mode 100644 index 0000000..cf97528 --- /dev/null +++ b/src/gov_user/db/migrate/20150910203559_add_institution_to_organization_rating.rb @@ -0,0 +1,11 @@ +class AddInstitutionToOrganizationRating < ActiveRecord::Migration + def up + change_table :organization_ratings do |t| + t.belongs_to :institution + end + end + + def down + remove_column :organization_ratings, :institution_id + end +end \ No newline at end of file diff --git a/src/gov_user/db/seeds.rb b/src/gov_user/db/seeds.rb new file mode 100644 index 0000000..b9065f0 --- /dev/null +++ b/src/gov_user/db/seeds.rb @@ -0,0 +1,19 @@ +# encoding: UTF-8 +powers = ["Executivo", "Legislativo", "Judiciário", "Não se Aplica"] +spheres = ["Federal", "Estadual", "Distrital", "Municipal"] +jur_natures = ["Administração Direta", "Autarquia", "Empresa Pública", "Fundação", + "Orgão Autônomo", "Sociedade", "Sociedade Civil", + "Sociedade de Economia Mista" + ] + +powers.each do |power| + GovernmentalPower.create(:name => power) +end + +spheres.each do |sphere| + GovernmentalSphere.create(:name => sphere) +end + +jur_natures.each do |jur_nature| + JuridicalNature.create(:name => jur_nature) +end diff --git a/src/gov_user/features/institution_registration.feature b/src/gov_user/features/institution_registration.feature new file mode 100644 index 0000000..c1fbb4e --- /dev/null +++ b/src/gov_user/features/institution_registration.feature @@ -0,0 +1,32 @@ +Feature: Institution Field + As a user + I want to sign up resgistring my institution + So others users can use it + + Background: + Given "GovUserPlugin" plugin is enabled + And I am logged in as mpog_admin + And I go to /admin/plugins + And I check "GovUserPlugin" + 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:" diff --git a/src/gov_user/features/steps_definitions/gov_user_steps.rb b/src/gov_user/features/steps_definitions/gov_user_steps.rb new file mode 100644 index 0000000..97cf5e2 --- /dev/null +++ b/src/gov_user/features/steps_definitions/gov_user_steps.rb @@ -0,0 +1,90 @@ +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 +sleep 1 +# Basicaly it, search for the input field, type something, wait for ajax end select an item +page.driver.browser.execute_script %Q{ + var search_query = "#{input_field_selector}.ui-autocomplete-input"; + var input = jQuery(search_query).first(); + + input.trigger('click'); + input.val('#{typed}'); + input.trigger('keydown'); + + window.setTimeout(function(){ + search_query = ".ui-menu-item a:contains('#{should_select}')"; + var typed = jQuery(search_query).first(); + + typed.trigger('mouseenter').trigger('click'); + console.log(jQuery('#license_info_id')); + }, 1000); + } + 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 /^I sleep for (\d+) seconds$/ do |time| + sleep time.to_i +end + +Given /^I am logged in as mpog_admin$/ do + visit('/account/logout') + + user = User.new(:login => 'admin_user', :password => '123456', :password_confirmation => '123456', :email => 'admin_user@example.com') + person = Person.new :name=>"Mpog Admin", :identifier=>"mpog-admin" + user.person = person + user.save! + + user.activate + e = Environment.default + e.add_admin(user.person) + + visit('/account/login') + fill_in("Username", :with => user.login) + fill_in("Password", :with => '123456') + click_button("Log in") +end + diff --git a/src/gov_user/features/user_profile_edition.feature b/src/gov_user/features/user_profile_edition.feature new file mode 100644 index 0000000..be7ecfa --- /dev/null +++ b/src/gov_user/features/user_profile_edition.feature @@ -0,0 +1,77 @@ +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 "GovUserPlugin" plugin is enabled + And the following users + | login | name | + | joao | Joao Silva | + And I am logged in as admin + And I go to /admin/plugins + And I check "GovUserPlugin" + 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 | + + Scenario: Go to control panel when clicked on 'Complete your profile' link + Given I am logged in as "joao" + And I am on joao's control panel + When I follow "Complete your profile" + Then I should see "Profile settings for " + And I should see "Personal information" + + @selenium + Scenario: Verify text information to use governmental e-mail + Given I am logged in as "joao" + And I am on joao's control panel + When I follow "Edit Profile" + Then I should see "If you work in a public agency use your government e-Mail" + + @selenium + Scenario: Add more then one instituion on profile editor + Given I am logged in as "joao" + And I am on joao's control panel + When 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 am logged in as "joao" + And I am on joao's control panel + When 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 am logged in as "joao" + And I am on joao's control panel + When I follow "Edit Profile" + And 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 am logged in as "joao" + And I am on joao's control panel + When 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/src/gov_user/lib/ext/communities_block.rb b/src/gov_user/lib/ext/communities_block.rb new file mode 100644 index 0000000..4a5fcaa --- /dev/null +++ b/src/gov_user/lib/ext/communities_block.rb @@ -0,0 +1,45 @@ +require_dependency 'communities_block' + +class CommunitiesBlock + + def profile_list + result = get_visible_profiles + result.slice(0..get_limit-1) + end + + def profile_count + profile_list.count + end + + private + + def get_visible_profiles + visible_profiles = profiles.visible.includes( + [:image,:domains,:preferred_domain,:environment] + ) + + delete_communities = [] + valid_communities_string = Community.get_valid_communities_string + Community.all.each{|community| delete_communities << community.id unless eval(valid_communities_string)} + + visible_profiles = visible_profiles.where(["profiles.id NOT IN (?)", delete_communities]) unless delete_communities.empty? + + if !prioritize_profiles_with_image + return visible_profiles.all( + :limit => get_limit, + :order => 'profiles.updated_at DESC' + ).sort_by {rand} + elsif profiles.visible.with_image.count >= get_limit + return visible_profiles.with_image.all( + :limit => get_limit * 5, + :order => 'profiles.updated_at DESC' + ).sort_by {rand} + else + visible_profiles = visible_profiles.with_image.sort_by {rand} + + visible_profiles.without_image.all( + :limit => get_limit * 5, :order => 'profiles.updated_at DESC' + ).sort_by {rand} + return visible_profiles + end + end +end diff --git a/src/gov_user/lib/ext/community.rb b/src/gov_user/lib/ext/community.rb new file mode 100644 index 0000000..d274660 --- /dev/null +++ b/src/gov_user/lib/ext/community.rb @@ -0,0 +1,25 @@ +require_dependency 'community' + +class Community + has_one :institution, :dependent=>:destroy + + def institution? + return !institution.nil? + end + + def remove_of_community_search_institution? + return institution? + end + + def self.get_valid_communities_string + remove_of_communities_methods = Community.instance_methods.select{|m| m =~ /remove_of_community_search/} + valid_communities_string = "!(" + remove_of_communities_methods.each do |method| + valid_communities_string += "community.send('#{method}') || " + end + valid_communities_string = valid_communities_string[0..-5] + valid_communities_string += ")" + + valid_communities_string + end +end diff --git a/src/gov_user/lib/ext/organization_rating.rb b/src/gov_user/lib/ext/organization_rating.rb new file mode 100644 index 0000000..fb2b59e --- /dev/null +++ b/src/gov_user/lib/ext/organization_rating.rb @@ -0,0 +1,20 @@ +require_dependency "organization_rating" + +OrganizationRating.class_eval do + + belongs_to :institution + + attr_accessible :institution, :institution_id + + validate :verify_institution + + private + + def verify_institution + if self.institution != nil + institution = Institution.find_by_id self.institution.id + self.errors.add :institution, _("not found") unless institution + end + end + +end diff --git a/src/gov_user/lib/ext/person.rb b/src/gov_user/lib/ext/person.rb new file mode 100644 index 0000000..0260a99 --- /dev/null +++ b/src/gov_user/lib/ext/person.rb @@ -0,0 +1,35 @@ +# encoding: utf-8 + +require_dependency 'person' + +class Person + + settings_items :percentage_incomplete, :type => :string, :default => "" + + attr_accessible :percentage_incomplete + + delegate :login, :to => :user, :prefix => true + + def institution? + false + end + + def secondary_email + self.user.secondary_email unless self.user.nil? + end + + def secondary_email= value + self.user.secondary_email = value unless self.user.nil? + end + + def institutions + institutions = [] + unless self.user.institutions.nil? + self.user.institutions.each do |institution| + institutions << institution.name + end + end + institutions + end + +end diff --git a/src/gov_user/lib/ext/search_controller.rb b/src/gov_user/lib/ext/search_controller.rb new file mode 100644 index 0000000..45a0523 --- /dev/null +++ b/src/gov_user/lib/ext/search_controller.rb @@ -0,0 +1,42 @@ +require_dependency 'search_controller' + +class SearchController + + def communities + delete_communities = [] + valid_communities_string = Community.get_valid_communities_string + Community.all.each{|community| delete_communities << community.id unless eval(valid_communities_string)} + + @scope = visible_profiles(Community) + @scope = @scope.where(["id NOT IN (?)", delete_communities]) unless delete_communities.empty? + + full_text_search + end + + def institutions + @titles[:institutions] = _("Institution Catalog") + results = filter_communities_list{|community| community.institution?} + results = results.paginate(:per_page => 24, :page => params[:page]) + @searches[@asset] = {:results => results} + @search = results + end + + def filter_communities_list + unfiltered_list = visible_profiles(Community) + + unless params[:query].nil? + unfiltered_list = unfiltered_list.select do |com| + com.name.downcase =~ /#{params[:query].downcase}/ + end + end + + communities_list = [] + unfiltered_list.each do |profile| + if profile.class == Community && !profile.is_template? && yield(profile) + communities_list << profile + end + end + + communities_list + end +end diff --git a/src/gov_user/lib/ext/search_helper.rb b/src/gov_user/lib/ext/search_helper.rb new file mode 100644 index 0000000..aae5940 --- /dev/null +++ b/src/gov_user/lib/ext/search_helper.rb @@ -0,0 +1,8 @@ +require_dependency 'search_helper' + +module SearchHelper + + COMMON_PROFILE_LIST_BLOCK ||= [] + COMMON_PROFILE_LIST_BLOCK << :institutions + +end diff --git a/src/gov_user/lib/ext/user.rb b/src/gov_user/lib/ext/user.rb new file mode 100644 index 0000000..ec5f7ce --- /dev/null +++ b/src/gov_user/lib/ext/user.rb @@ -0,0 +1,60 @@ +require_dependency 'user' + +class User + + GOV_SUFFIX = /^.*@[gov.br|jus.br|leg.br|mp.br]+$/ + + has_and_belongs_to_many :institutions + + validate :email_different_secondary?, :email_has_already_been_used?, + :secondary_email_format + + scope :primary_or_secondary_email_already_used?, lambda { |email| + where("email=? OR secondary_email=?", email, email) + } + + def email_different_secondary? + self.errors.add( + :base, + _("Email must be different from secondary email.") + ) if self.email == self.secondary_email + end + + def email_has_already_been_used? + user_already_saved = User.find(:first, + :conditions => ["email = ?", self.email]) + + if user_already_saved.nil? + primary_email_hasnt_been_used = + User.primary_or_secondary_email_already_used?(self.email).empty? + + if !self.secondary_email.nil? and self.secondary_email.empty? + self.secondary_email = nil + end + + secondary_email_hasnt_been_used = + User.primary_or_secondary_email_already_used?(self.secondary_email). + empty? + + if !primary_email_hasnt_been_used or !secondary_email_hasnt_been_used + self.errors.add(:base, _("E-mail or secondary e-mail already taken.")) + end + end + end + + def secondary_email_format + if !self.secondary_email.nil? and self.secondary_email.length > 0 + test = /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/ + + unless test.match(self.secondary_email) + self.errors.add(:base, _("Invalid secondary email format.")) + end + end + end + + private + + def valid_format?(value, string_format) + !value.nil? && value.length > 0 && !string_format.match(value).nil? + end +end diff --git a/src/gov_user/lib/gov_user_plugin.rb b/src/gov_user/lib/gov_user_plugin.rb new file mode 100644 index 0000000..5cd63dc --- /dev/null +++ b/src/gov_user/lib/gov_user_plugin.rb @@ -0,0 +1,332 @@ +class GovUserPlugin < Noosfero::Plugin + include ActionView::Helpers::TagHelper + include ActionView::Helpers::FormTagHelper + include ActionView::Helpers::FormOptionsHelper + include ActionView::Helpers::JavaScriptHelper + include ActionView::Helpers::AssetTagHelper + include FormsHelper + include ActionView::Helpers + include ActionDispatch::Routing + include Rails.application.routes.url_helpers + + def self.plugin_name + "GovUserPlugin" + end + + def self.plugin_description + _("Add features related to Brazilian government.") + end + + def stylesheet? + true + end + + # Hotspot to insert html without an especific hotspot on view. + def body_beginning + return if context.session[:user].nil? or context.session[:hide_incomplete_percentage] == true + + person = context.environment.people.where(:user_id=>context.session[:user]).first + + if context.profile && context.profile.person? and !person.nil? + @person = person + @percentege = calc_percentage_registration(person) + + if @percentege >= 0 and @percentege < 100 + expanded_template('incomplete_registration.html.erb') + end + end + end + + def profile_editor_transaction_extras + single_hash_transactions = { :user => 'user', + :instituton => 'instituton' + } + + single_hash_transactions.each do |model, transaction| + call_model_transaction(model, transaction) + end + end + + def profile_editor_controller_filters + block = proc do + if request.post? && params[:institution] + is_admin = environment.admins.include?(current_user.person) + + unless is_admin + institution = profile.user.institutions + + if !params[:institution].blank? && params[:institution].class == Hash && !params[:institution][:sisp].nil? + if params[:institution][:sisp] != institution.sisp + params[:institution][:sisp] = institution.sisp + end + end + end + end + end + + [{ + :type => 'before_filter', + :method_name => 'validate_institution_sisp_field_access', + :options => { :only => :edit }, + :block => block + }] + end + + def profile_tabs + if context.profile.community? + return profile_tabs_institution if context.profile.institution? + end + end + + def control_panel_buttons + if context.profile.institution? + return institution_info_button + end + end + + def self.extra_blocks + { + InstitutionsBlock => { :type => [Environment, Person] } + } + end + + def custom_user_registration_attributes(user) + return if context.params[:user][:institution_ids].nil? + context.params[:user][:institution_ids].delete('') + + update_user_institutions(user) + + user.institutions.each do |institution| + community = institution.community + community.add_member user.person + end + end + + def profile_editor_extras + profile = context.profile + + if profile.person? + expanded_template('person_editor_extras.html.erb') + end + end + + + def calc_percentage_registration(person) + required_list = profile_required_list + empty_fields = profile_required_empty_list person + count = required_list[:person_fields].count + + required_list[:user_fields].count + percentege = 100 - ((empty_fields.count * 100) / count) + person.percentage_incomplete = percentege + person.save(validate: false) + percentege + end + + def stylesheet? + true + end + + def admin_panel_links + [ + { + :title => _('Create Institution'), + :url => { + :controller => 'gov_user_plugin', + :action => 'create_institution_admin' + } + } + ] + end + + + def js_files + %w( + vendor/modulejs-1.5.0.min.js + vendor/jquery.js + lib/noosfero-root.js + lib/select-element.js + lib/select-field-choices.js + views/complete-registration.js + views/control-panel.js + views/create-institution.js + views/new-community.js + views/user-edit-profile.js + views/gov-user-comments-extra-fields.js + initializer.js + app.js + ) + end + + def admin_panel_links + [ + { + :title => _('Create Institution'), + :url => { + :controller => 'gov_user_plugin', + :action => 'create_institution_admin' + } + } + ] + end + + protected + + def profile_required_list + fields = {} + fields[:person_fields] = %w(cell_phone + contact_phone + comercial_phone + country + city + state + organization_website + image + identifier + name) + + fields[:user_fields] = %w(secondary_email email) + fields + end + + def profile_required_empty_list(person) + empty_fields = [] + required_list = profile_required_list + + required_list[:person_fields].each do |field| + empty_fields << field.sub('_',' ') if person.send(field).blank? + end + required_list[:user_fields].each do |field| + empty_fields << field.sub('_',' ') if person.user.send(field).blank? + end + empty_fields + end + + + protected + + def user_transaction + user_editor_institution_actions + + User.transaction do + context.profile.user.update_attributes!(context.params[:user]) + end + end + + def institution_transaction + institution.date_modification = DateTime.now + institution.save + institution_models = %w(governmental_power governmental_sphere + juridical_nature) + + institution_models.each do |model| + call_institution_transaction(model) + end + + if context.params.has_key?(:institution) + Institution.transaction do + context.profile. + institution. + update_attributes!(context.params[:institution]) + end + end + end + + def organization_ratings_plugin_comments_extra_fields + Proc::new do render :file => 'ratings_extra_field' end + end + + def organization_ratings_plugin_extra_fields_show_data user_rating + gov_user_self = self + + Proc::new { + if logged_in? + is_admin = environment.admins.include?(current_user.person) + is_admin ||= user_rating.organization.admins.include?(current_user.person) + + if is_admin and gov_user_self.context.profile.software? + render :file => 'organization_ratings_extra_fields_show_institution', + :locals => {:user_rating => user_rating} + end + end + } + end + + private + + def call_model_transaction(model,name) + send(name + '_transaction') if context.params.key?(model.to_sym) + end + + def call_institution_transaction(model) + context.profile.institution.send(model + '_id = ', + context.params[model.to_sym]) + context.profile.institution.save! + end + + # Add and remove the user from it's institutions communities + def user_editor_institution_actions + user = context.profile.user + + old_communities = [] + context.profile.user.institutions.each do |institution| + old_communities << institution.community + end + + new_communities = [] + unless context.params[:user][:institution_ids].nil? + context.params[:user][:institution_ids].delete('') + + context.params[:user][:institution_ids].each do |id| + new_communities << Institution.find(id).community + end + end + + manage_user_institutions(user, old_communities, new_communities) + end + + def institution_info_button + { + :title => _('Institution Info'), + :icon => 'edit-profile-group control-panel-instituton-link', + :url => { + :controller => 'gov_user_plugin_myprofile', + :action => 'edit_institution' + } + } + end + + def manage_user_institutions(user, old_communities, new_communities) + leave_communities = (old_communities - new_communities) + enter_communities = (new_communities - old_communities) + + leave_communities.each do |community| + community.remove_member(user.person) + user.institutions.delete(community.institution) + end + + enter_communities.each do |community| + community.add_member(user.person) + user.institutions << community.institution + end + end + + def profile_tabs_institution + { :title => _('Institution'), + :id => 'intitution-fields', + :content => Proc::new do render :partial => 'profile/institution_tab' end, + :start => true + } + end + + def update_user_institutions(user) + context.params[:user][:institution_ids].each do |institution_id| + institution = Institution.find institution_id + user.institutions << institution + + if institution.community.admins.blank? + institution.community.add_admin(user.person) + end + end + user.save unless user.institution_ids.empty? + end +end diff --git a/src/gov_user/lib/governmental_power.rb b/src/gov_user/lib/governmental_power.rb new file mode 100644 index 0000000..cb7ca36 --- /dev/null +++ b/src/gov_user/lib/governmental_power.rb @@ -0,0 +1,13 @@ +class GovernmentalPower < ActiveRecord::Base + attr_accessible :name + + validates :name, :presence=>true, :uniqueness=>true + has_many :institutions + + def public_institutions + Institution.where( + :type=>"PublicInstitution", + :governmental_power_id=>self.id + ) + end +end diff --git a/src/gov_user/lib/governmental_sphere.rb b/src/gov_user/lib/governmental_sphere.rb new file mode 100644 index 0000000..aef8f8f --- /dev/null +++ b/src/gov_user/lib/governmental_sphere.rb @@ -0,0 +1,7 @@ +class GovernmentalSphere < ActiveRecord::Base + attr_accessible :name + + validates :name, :presence=>true, :uniqueness=>true + + has_many :institutions +end diff --git a/src/gov_user/lib/institution.rb b/src/gov_user/lib/institution.rb new file mode 100644 index 0000000..ee5e870 --- /dev/null +++ b/src/gov_user/lib/institution.rb @@ -0,0 +1,107 @@ +class Institution < ActiveRecord::Base + has_many :comments + + SEARCH_FILTERS = { + :order => %w[], + :display => %w[compact] + } + + def self.default_search_display + 'compact' + end + + belongs_to :governmental_power + belongs_to :governmental_sphere + belongs_to :juridical_nature + + has_and_belongs_to_many :users + + attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type, + :sub_juridical_nature, :normalization_level, + :version, :cnpj, :type, :governmental_power, + :governmental_sphere, :sisp, :juridical_nature, + :corporate_name, :siorg_code, :community + + validates :name, :presence=>true, :uniqueness=>true + + before_save :verify_institution_type + + belongs_to :community + + scope :search_institution, lambda{ |value| + where("name ilike ? OR acronym ilike ?", "%#{value}%", "%#{value}%" ) + } + + validate :validate_country, :validate_state, :validate_city, + :verify_institution_type, :validate_format_cnpj + + + protected + + def verify_institution_type + valid_institutions_type = ["PublicInstitution", "PrivateInstitution"] + + unless valid_institutions_type.include? self.type + self.errors.add( + :type, + _("invalid, only public and private institutions are allowed.") + ) + + return false + end + + return true + end + + def validate_country + unless self.community.blank? + if self.community.country.blank? && self.errors[:country].blank? + self.errors.add(:country, _("can't be blank")) + return false + end + end + + return true + end + + def validate_state + unless self.community.blank? + if self.community.country == "BR" && + (self.community.state.blank? || self.community.state == "-1") && + self.errors[:state].blank? + + self.errors.add(:state, _("can't be blank")) + return false + end + end + + return true + end + + def validate_city + unless self.community.blank? + if self.community.country == "BR" && self.community.city.blank? && + self.errors[:city].blank? + + self.errors.add(:city, _("can't be blank")) + return false + end + end + + return true + end + + def validate_format_cnpj + return true if self.community.blank? && self.community.country != "BR" + return true if self.cnpj.blank? + + format = /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/ + + if !self.cnpj.blank? && format.match(self.cnpj) + return true + else + self.errors.add(:cnpj, _("invalid format")) + return false + end + end +end diff --git a/src/gov_user/lib/institutions_block.rb b/src/gov_user/lib/institutions_block.rb new file mode 100644 index 0000000..8ef8f59 --- /dev/null +++ b/src/gov_user/lib/institutions_block.rb @@ -0,0 +1,71 @@ +class InstitutionsBlock < CommunitiesBlock + + def self.description + _('Institutions') + end + + def profile_count + profile_list.count + end + + def default_title + n_('{#} institution', '{#} institutions', profile_count) + end + + def help + _('This block displays the institutions in which the user is a member.') + end + + def footer + owner = self.owner + case owner + when Profile + lambda do |context| + link_to s_('institutions|View all'), :profile => owner.identifier, + :controller => 'profile', :action => 'communities', + :type => 'Institution' + end + when Environment + lambda do |context| + link_to s_('institutions|View all'), :controller => 'search', + :action => 'communities', :type => 'Institution' + end + else + '' + end + end + + def profile_list + result = get_visible_profiles + + result = result.select { |p| p.class == Community && p.institution? } + + result.slice(0..get_limit-1) + end + + def profiles + owner.communities + end + + private + + def get_visible_profiles + include_list = [:image,:domains,:preferred_domain,:environment] + visible_profiles = profiles.visible.includes(include_list) + + if !prioritize_profiles_with_image + visible_profiles.all(:limit => get_limit, + :order => 'profiles.updated_at DESC' + ).sort_by{ rand } + elsif profiles.visible.with_image.count >= get_limit + visible_profiles.with_image.all(:limit => get_limit * 5, + :order => 'profiles.updated_at DESC' + ).sort_by{ rand } + else + visible_profiles.with_image.sort_by{ rand } + + visible_profiles.without_image.all(:limit => get_limit * 5, + :order => 'profiles.updated_at DESC' + ).sort_by{ rand } + end + end +end diff --git a/src/gov_user/lib/institutions_users.rb b/src/gov_user/lib/institutions_users.rb new file mode 100644 index 0000000..e47da86 --- /dev/null +++ b/src/gov_user/lib/institutions_users.rb @@ -0,0 +1,4 @@ +class InstitutionUser < ActiveRecord::Base + belongs_to :user + belongs_to :institution +end diff --git a/src/gov_user/lib/juridical_nature.rb b/src/gov_user/lib/juridical_nature.rb new file mode 100644 index 0000000..1bb17f8 --- /dev/null +++ b/src/gov_user/lib/juridical_nature.rb @@ -0,0 +1,15 @@ +class JuridicalNature < ActiveRecord::Base + attr_accessible :name + + has_many :institutions + + validates_presence_of :name + validates_uniqueness_of :name + + def public_institutions + Institution.where( + :type=>"PublicInstitution", + :juridical_nature_id=>self.id + ) + end +end diff --git a/src/gov_user/lib/private_institution.rb b/src/gov_user/lib/private_institution.rb new file mode 100644 index 0000000..db490d2 --- /dev/null +++ b/src/gov_user/lib/private_institution.rb @@ -0,0 +1,2 @@ +class PrivateInstitution < Institution +end diff --git a/src/gov_user/lib/public_institution.rb b/src/gov_user/lib/public_institution.rb new file mode 100644 index 0000000..33d13eb --- /dev/null +++ b/src/gov_user/lib/public_institution.rb @@ -0,0 +1,13 @@ +class PublicInstitution < Institution + validates :governmental_power, :governmental_sphere, :juridical_nature, + :presence=>true + + validates :acronym, :allow_blank => true, :allow_nil => true, + :uniqueness=>true + + validates_format_of( + :cnpj, + :with => /^\d{2}\.\d{3}\.\d{3}\/\d{4}\-\d{2}$/, + :allow_nil => true, :allow_blank => true + ) +end diff --git a/src/gov_user/po/gov_user.pot b/src/gov_user/po/gov_user.pot new file mode 100644 index 0000000..de87012 --- /dev/null +++ b/src/gov_user/po/gov_user.pot @@ -0,0 +1,356 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: 1.2-141-g2924904\n" +"POT-Creation-Date: 2015-09-11 17:06-0000\n" +"PO-Revision-Date: 2015-09-01 20:59-0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" + +#: plugins/gov_user/lib/ext/search_controller.rb:17 +msgid "Institution Catalog" +msgstr "" + +#: plugins/gov_user/lib/ext/user.rb:19 +msgid "Email must be different from secondary email." +msgstr "" + +#: plugins/gov_user/lib/ext/user.rb:40 +msgid "E-mail or secondary e-mail already taken." +msgstr "" + +#: plugins/gov_user/lib/ext/user.rb:50 +msgid "Invalid secondary email format." +msgstr "" + +#: plugins/gov_user/lib/ext/organization_rating.rb:16 +msgid "not found" +msgstr "" + +#: plugins/gov_user/lib/gov_user_plugin.rb:17 +msgid "Add features related to Brazilian government." +msgstr "" + +#: plugins/gov_user/lib/gov_user_plugin.rb:132 +#: plugins/gov_user/lib/gov_user_plugin.rb:163 +msgid "Create Institution" +msgstr "" + +#: plugins/gov_user/lib/gov_user_plugin.rb:287 +msgid "Institution Info" +msgstr "" + +#: plugins/gov_user/lib/gov_user_plugin.rb:312 +msgid "Institution" +msgstr "" + +#: plugins/gov_user/lib/institutions_block.rb:4 +#: plugins/gov_user/views/person_editor_extras.html.erb:11 +msgid "Institutions" +msgstr "" + +#: plugins/gov_user/lib/institutions_block.rb:12 +msgid "{#} institution" +msgid_plural "{#} institutions" +msgstr[0] "" +msgstr[1] "" + +#: plugins/gov_user/lib/institutions_block.rb:16 +msgid "This block displays the institutions in which the user is a member." +msgstr "" + +#: plugins/gov_user/lib/institutions_block.rb:24 +#: plugins/gov_user/lib/institutions_block.rb:30 +msgid "institutions|View all" +msgstr "" + +#: plugins/gov_user/lib/institution.rb:47 +msgid "invalid, only public and private institutions are allowed." +msgstr "" + +#: plugins/gov_user/lib/institution.rb:59 +#: plugins/gov_user/lib/institution.rb:73 +#: plugins/gov_user/lib/institution.rb:86 +msgid "can't be blank" +msgstr "" + +#: plugins/gov_user/lib/institution.rb:103 +msgid "invalid format" +msgstr "" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:18 +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:43 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:83 +msgid "Select a Governmental Sphere" +msgstr "" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:19 +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:44 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:90 +msgid "Select a Governmental Power" +msgstr "" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:20 +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:45 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:96 +msgid "Select a Juridical Nature" +msgstr "" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:21 +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:46 +msgid "Select a state" +msgstr "" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:168 +#: plugins/gov_user/controllers/gov_user_plugin_myprofile_controller.rb:26 +msgid "Could not find Governmental Power or Governmental Sphere" +msgstr "" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:214 +msgid "Institution successful created!" +msgstr "" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:219 +msgid "Institution could not be created!" +msgstr "" + +#: plugins/gov_user/test/unit/gov_user_person_test.rb:50 +#: plugins/gov_user/test/unit/gov_user_person_test.rb:56 +msgid "Name Should begin with a capital letter and no special characters" +msgstr "" + +#: plugins/gov_user/views/search/institutions.html.erb:3 +msgid "Type words about the %s you're looking for" +msgstr "" + +#: plugins/gov_user/views/ratings_extra_field.html.erb:2 +msgid "Organization name or Enterprise name" +msgstr "" + +#: plugins/gov_user/views/ratings_extra_field.html.erb:6 +#: plugins/gov_user/views/person_editor_extras.html.erb:21 +msgid "No institution found" +msgstr "" + +#: plugins/gov_user/views/incomplete_registration.html.erb:3 +msgid "Complete Profile" +msgstr "" + +#: plugins/gov_user/views/incomplete_registration.html.erb:6 +msgid "Complete your profile" +msgstr "" + +#: plugins/gov_user/views/incomplete_registration.html.erb:7 +msgid "Hide" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:1 +msgid "Edit Institution" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:5 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:5 +msgid "" +"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." +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:11 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:11 +msgid "\"Can`t create new Institution: #{flash[:errors].length} errors\"" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:24 +msgid "All fields with (*) are mandatory" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:31 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:37 +msgid "Public Institution" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:36 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:33 +msgid "Private Institution" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:43 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:44 +msgid "Institution name already exists" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:47 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:48 +msgid "Corporate Name" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:52 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:53 +msgid "Country" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:56 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:57 +msgid "State" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:66 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:66 +msgid "CNPJ" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:73 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:75 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:72 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:74 +msgid "Acronym" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:74 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:73 +msgid "Fantasy name" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:82 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:17 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:81 +msgid "Governmental Sphere:" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:89 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:16 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:88 +msgid "Governmental Power:" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:95 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:18 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:94 +msgid "Juridical Nature:" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:102 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:101 +msgid "SISP?" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:104 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:104 +msgid "Yes" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:106 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:109 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:106 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:108 +msgid "No" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:114 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:114 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:118 +msgid "Save" +msgstr "" + +#: plugins/gov_user/views/person_editor_extras.html.erb:2 +msgid "Secondary e-mail" +msgstr "" + +#: plugins/gov_user/views/person_editor_extras.html.erb:22 +msgid "Add new institution" +msgstr "" + +#: plugins/gov_user/views/person_editor_extras.html.erb:23 +msgid "Create new institution" +msgstr "" + +#: plugins/gov_user/views/person_editor_extras.html.erb:39 +msgid "Should begin with a capital letter and no special characters" +msgstr "" + +#: plugins/gov_user/views/person_editor_extras.html.erb:40 +msgid "Email should have the following format: name@host.br" +msgstr "" + +#: plugins/gov_user/views/person_editor_extras.html.erb:41 +msgid "Site should have a valid format: http://name.hosts" +msgstr "" + +#: plugins/gov_user/views/person_editor_extras.html.erb:42 +msgid "If you work in a public agency use your government e-Mail" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:3 +msgid "Institution Information" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:6 +msgid "Type:" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:7 +msgid "CNPJ:" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:8 +msgid "Last modification:" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:9 +msgid "Country:" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:10 +msgid "State:" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:11 +msgid "City:" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:13 +msgid "Fantasy Name:" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:15 +msgid "Acronym:" +msgstr "" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 +msgid "SISP:" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:1 +msgid "New Institution" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:16 +msgid "\"#{key_name.capitalize} #{value.join()}\"" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:115 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:119 +msgid "Cancel" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:121 +msgid "Could not send the form data to the server" +msgstr "" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:128 +msgid "Creating institution" +msgstr "" diff --git a/src/gov_user/po/pt/gov_user.po b/src/gov_user/po/pt/gov_user.po new file mode 100644 index 0000000..4a3a691 --- /dev/null +++ b/src/gov_user/po/pt/gov_user.po @@ -0,0 +1,370 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: 1.2-143-g8dfded9\n" +"POT-Creation-Date: 2015-09-11 17:14-0000\n" +"PO-Revision-Date: 2015-09-01 19:55-0000\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" + +#: plugins/gov_user/test/unit/gov_user_person_test.rb:50 +#: plugins/gov_user/test/unit/gov_user_person_test.rb:56 +msgid "Name Should begin with a capital letter and no special characters" +msgstr "" +"Nome deve iniciar com letrar maiúscula e não deve conter carateres especiais" + +#: plugins/gov_user/controllers/gov_user_plugin_myprofile_controller.rb:26 +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:168 +msgid "Could not find Governmental Power or Governmental Sphere" +msgstr "Não foi possível encontrar o Poder ou Esfera Governamental" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:18 +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:43 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:83 +msgid "Select a Governmental Sphere" +msgstr "Selecione uma Esfera Governamental" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:19 +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:44 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:90 +msgid "Select a Governmental Power" +msgstr "Selecione um Poder Governamental" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:20 +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:45 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:96 +msgid "Select a Juridical Nature" +msgstr "Seleciona uma Natureza Jurídica" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:21 +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:46 +msgid "Select a state" +msgstr "Selecione um Estado" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:214 +msgid "Institution successful created!" +msgstr "Instituição criada com sucesso!" + +#: plugins/gov_user/controllers/gov_user_plugin_controller.rb:219 +msgid "Institution could not be created!" +msgstr "Instituição não pode ser criada!" + +#: plugins/gov_user/lib/gov_user_plugin.rb:17 +msgid "Add features related to Brazilian government." +msgstr "Adicionar funcionlidade relacionada com o governo brasileiro." + +#: plugins/gov_user/lib/gov_user_plugin.rb:132 +#: plugins/gov_user/lib/gov_user_plugin.rb:163 +msgid "Create Institution" +msgstr "Criar Instituição" + +#: plugins/gov_user/lib/gov_user_plugin.rb:287 +msgid "Institution Info" +msgstr "Informações da Instituição" + +#: plugins/gov_user/lib/gov_user_plugin.rb:312 +msgid "Institution" +msgstr "Instituição" + +#: plugins/gov_user/lib/institution.rb:47 +msgid "invalid, only public and private institutions are allowed." +msgstr "Inválido, somente instituições públicas e privadas são permitidas." + +#: plugins/gov_user/lib/institution.rb:59 +#: plugins/gov_user/lib/institution.rb:73 +#: plugins/gov_user/lib/institution.rb:86 +msgid "can't be blank" +msgstr "não pode ficar em branco" + +#: plugins/gov_user/lib/institution.rb:103 +msgid "invalid format" +msgstr "formato inválido" + +#: plugins/gov_user/lib/ext/user.rb:19 +msgid "Email must be different from secondary email." +msgstr "Email deve ser diferente do email secundário" + +#: plugins/gov_user/lib/ext/user.rb:40 +msgid "E-mail or secondary e-mail already taken." +msgstr "Email ou email secundário já estão sendo utilizados." + +#: plugins/gov_user/lib/ext/user.rb:50 +msgid "Invalid secondary email format." +msgstr "Formato inválido do email sencundário" + +#: plugins/gov_user/lib/ext/search_controller.rb:17 +msgid "Institution Catalog" +msgstr "Catálogo de Instituições" + +#: plugins/gov_user/lib/ext/organization_rating.rb:16 +msgid "not found" +msgstr "não encontrada" + +#: plugins/gov_user/lib/institutions_block.rb:4 +#: plugins/gov_user/views/person_editor_extras.html.erb:11 +msgid "Institutions" +msgstr "Instituições" + +#: plugins/gov_user/lib/institutions_block.rb:12 +msgid "{#} institution" +msgid_plural "{#} institutions" +msgstr[0] "{#} instituição" +msgstr[1] "{#} instituições" + +#: plugins/gov_user/lib/institutions_block.rb:16 +msgid "This block displays the institutions in which the user is a member." +msgstr "Esse bloco mostra as instituições em que o usuário faz parte." + +#: plugins/gov_user/lib/institutions_block.rb:24 +#: plugins/gov_user/lib/institutions_block.rb:30 +msgid "institutions|View all" +msgstr "instituições|Ver todas" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:1 +msgid "Edit Institution" +msgstr "Editar Instituição" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:5 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:5 +msgid "" +"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." +msgstr "" +"Note que a criação de comunidades neste ambiente é restrita. Sua requisição " +"para criar essa nova comunidade será enviada para os administradores " +"%{environment} e será aprovada ou rejeitada de acordo com seus métodos e " +"critérios." + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:11 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:11 +msgid "\"Can`t create new Institution: #{flash[:errors].length} errors\"" +msgstr "" +"\"Não foi possível criar nova Instituição: #{flash[:errors].length} erros\"" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:24 +msgid "All fields with (*) are mandatory" +msgstr "Todos os campos com (*) são obrigatórios" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:31 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:37 +msgid "Public Institution" +msgstr "Instituição Pública" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:36 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:33 +msgid "Private Institution" +msgstr "Instituição Privada" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:43 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:44 +msgid "Institution name already exists" +msgstr "Nome de Instituição já existe" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:47 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:48 +msgid "Corporate Name" +msgstr "Nome da Coorporação" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:52 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:53 +msgid "Country" +msgstr "País" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:56 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:57 +msgid "State" +msgstr "Estado" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:66 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:66 +msgid "CNPJ" +msgstr "CNPJ" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:73 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:75 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:72 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:74 +msgid "Acronym" +msgstr "Sigla" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:74 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:73 +msgid "Fantasy name" +msgstr "Nome Fantasia" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:82 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:17 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:81 +msgid "Governmental Sphere:" +msgstr "Esfera Governamental:" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:89 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:16 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:88 +msgid "Governmental Power:" +msgstr "Poder Governamental:" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:95 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:18 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:94 +msgid "Juridical Nature:" +msgstr "Natureza Jurídica:" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:102 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:101 +msgid "SISP?" +msgstr "SISP?" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:104 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:104 +msgid "Yes" +msgstr "Sim" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:106 +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:109 +#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:106 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:108 +msgid "No" +msgstr "Não" + +#: plugins/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb:114 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:114 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:118 +msgid "Save" +msgstr "Salvar" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:3 +msgid "Institution Information" +msgstr "Informação da Instituição" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:6 +msgid "Type:" +msgstr "Tipo:" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:7 +msgid "CNPJ:" +msgstr "CNPJ:" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:8 +msgid "Last modification:" +msgstr "Última modificação:" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:9 +msgid "Country:" +msgstr "País:" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:10 +msgid "State:" +msgstr "Estado:" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:11 +msgid "City:" +msgstr "Cidade:" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:13 +msgid "Fantasy Name:" +msgstr "Nome Fantasia:" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:15 +msgid "Acronym:" +msgstr "Sigla:" + +#: plugins/gov_user/views/profile/_institution_tab.html.erb:19 +msgid "SISP:" +msgstr "SISP:" + +#: plugins/gov_user/views/ratings_extra_field.html.erb:2 +msgid "Organization name or Enterprise name" +msgstr "Nome da organização ou empresa" + +#: plugins/gov_user/views/ratings_extra_field.html.erb:6 +#: plugins/gov_user/views/person_editor_extras.html.erb:21 +msgid "No institution found" +msgstr "Nenhuma instituição encontrada" + +#: plugins/gov_user/views/person_editor_extras.html.erb:2 +msgid "Secondary e-mail" +msgstr "Email secundário" + +#: plugins/gov_user/views/person_editor_extras.html.erb:22 +msgid "Add new institution" +msgstr "Adicionar nova instituição" + +#: plugins/gov_user/views/person_editor_extras.html.erb:23 +msgid "Create new institution" +msgstr "Criar nova instituição" + +#: plugins/gov_user/views/person_editor_extras.html.erb:39 +msgid "Should begin with a capital letter and no special characters" +msgstr "Deve começar com letra maíscula e não conter caracteres especiais" + +#: plugins/gov_user/views/person_editor_extras.html.erb:40 +msgid "Email should have the following format: name@host.br" +msgstr "Email deve ter o seguinte formato: name@host.br" + +#: plugins/gov_user/views/person_editor_extras.html.erb:41 +msgid "Site should have a valid format: http://name.hosts" +msgstr "Site deve ter um formato válido: http://name.hosts" + +#: plugins/gov_user/views/person_editor_extras.html.erb:42 +msgid "If you work in a public agency use your government e-Mail" +msgstr "Se você trabalha em uma agência pública use seu email governamental" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:1 +msgid "New Institution" +msgstr "Nova Instituição" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:16 +msgid "\"#{key_name.capitalize} #{value.join()}\"" +msgstr "\"#{key_name.capitalize} #{value.join()}\"" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:115 +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:119 +msgid "Cancel" +msgstr "Cancelar" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:121 +msgid "Could not send the form data to the server" +msgstr "Não foi possível enviar os dados do formulário para o servidor" + +#: plugins/gov_user/views/gov_user_plugin/_institution.html.erb:128 +msgid "Creating institution" +msgstr "Criar instituição" + +#: plugins/gov_user/views/search/institutions.html.erb:3 +msgid "Type words about the %s you're looking for" +msgstr "Escreve palavras sobre o %s que você está procurando" + +#: plugins/gov_user/views/incomplete_registration.html.erb:3 +msgid "Complete Profile" +msgstr "Complete o Perfil" + +#: plugins/gov_user/views/incomplete_registration.html.erb:6 +msgid "Complete your profile" +msgstr "Complete seu perfil" + +#: plugins/gov_user/views/incomplete_registration.html.erb:7 +msgid "Hide" +msgstr "Ocultar" + +#~ msgid "A plugin that does this and that." +#~ msgstr "Um plugin que faz isso e aquilo" + +#~ msgid "The governamental email must be the primary one." +#~ msgstr "O email governamental deve ser o principal" + +#~ msgid "Institution is obligatory if user has a government email." +#~ msgstr "Instituição é obrigatória se o usuário tem email governamental." diff --git a/src/gov_user/public/app.js b/src/gov_user/public/app.js new file mode 100644 index 0000000..7e98375 --- /dev/null +++ b/src/gov_user/public/app.js @@ -0,0 +1,11 @@ +(function() { + 'use strict'; + + var $ = modulejs.require('jquery'); + var Initializer = modulejs.require('Initializer'); + + + $(document).ready(function() { + Initializer.init(); + }); +})(); diff --git a/src/gov_user/public/initializer.js b/src/gov_user/public/initializer.js new file mode 100644 index 0000000..395f20c --- /dev/null +++ b/src/gov_user/public/initializer.js @@ -0,0 +1,33 @@ +(function() { + 'use strict'; + + var dependencies = [ + 'ControlPanel', + 'CreateInstitution', + 'CompleteRegistration', + 'UserEditProfile', + 'NewCommunity', + 'GovUserCommentsExtraFields' + ]; + + + modulejs.define('Initializer', dependencies, function() { + var __dependencies = arguments; + + + function call_dependency(dependency) { + if( dependency.isCurrentPage() ) { + dependency.init(); + } + } + + + return { + init: function() { + for(var i=0, len = __dependencies.length; i < len; i++) { + call_dependency(__dependencies[i]); + } + } + }; + }); +})(); diff --git a/src/gov_user/public/lib/noosfero-root.js b/src/gov_user/public/lib/noosfero-root.js new file mode 100644 index 0000000..cd3c8bf --- /dev/null +++ b/src/gov_user/public/lib/noosfero-root.js @@ -0,0 +1,13 @@ +modulejs.define('NoosferoRoot', function() { + 'use strict'; + + + function url_with_subdirectory(url) { + return noosfero_root() + url; + } + + + return { + urlWithSubDirectory: url_with_subdirectory + } +}); diff --git a/src/gov_user/public/lib/select-element.js b/src/gov_user/public/lib/select-element.js new file mode 100644 index 0000000..26880ae --- /dev/null +++ b/src/gov_user/public/lib/select-element.js @@ -0,0 +1,35 @@ +modulejs.define('SelectElement', function() { + 'use strict'; + + + function SelectElement(name, id) { + this.select = document.createElement("select"); + } + + + SelectElement.prototype.setAttr = function(attr, value) { + return this.select.setAttribute(attr, value); + }; + + + SelectElement.prototype.addOption = function(option) { + return this.select.add(option); + }; + + + SelectElement.prototype.getSelect = function() { + return this.select; + }; + + + SelectElement.generateOption = function(value, text) { + var option; + option = document.createElement("option"); + option.setAttribute("value", value); + option.text = text; + return option; + }; + + + return SelectElement; +}); diff --git a/src/gov_user/public/lib/select-field-choices.js b/src/gov_user/public/lib/select-field-choices.js new file mode 100644 index 0000000..095d4e1 --- /dev/null +++ b/src/gov_user/public/lib/select-field-choices.js @@ -0,0 +1,81 @@ +modulejs.define('SelectFieldChoices', ['jquery', 'SelectElement'], function($, SelectElement) { + 'use strict'; + + + function SelectFieldChoices(state_id, city_id, state_url) { + this.state_id = state_id; + this.input_html = $(state_id).parent().html(); + this.old_value = $(state_id).val(); + this.city_parent_div = $(city_id).parent().parent().parent(); + this.state_url = state_url; + } + + + SelectFieldChoices.prototype.getCurrentStateElement = function() { + return $(this.state_id); + }; + + + SelectFieldChoices.prototype.replaceWith = function(html) { + var parent_div = this.getCurrentStateElement().parent(); + parent_div.html(html); + }; + + + SelectFieldChoices.prototype.generateSelect = function(state_list) { + var select_element, option; + + select_element = new SelectElement(); + select_element.setAttr("name", "profile_data[state]"); + select_element.setAttr("id", "state_field"); + select_element.setAttr("class", "type-select valid"); + + state_list.forEach(function(state) { + option = SelectElement.generateOption(state, state); + select_element.addOption(option); + }); + + return select_element.getSelect(); + }; + + + SelectFieldChoices.prototype.replaceStateWithSelectElement = function() { + var klass = this; + + $.get(this.state_url, function(response) { + var select_html; + + if (response.length > 0) { + select_html = klass.generateSelect(response); + klass.replaceWith(select_html); + + if (klass.old_value.length !== 0 && response.include(klass.old_value)) { + klass.getCurrentStateElement().val(klass.old_value); + } + } + }); + }; + + + SelectFieldChoices.prototype.replaceStateWithInputElement = function() { + this.replaceWith(this.input_html); + }; + + + SelectFieldChoices.prototype.hideCity = function() { + this.city_parent_div.addClass("mpog_hidden_field"); + }; + + + SelectFieldChoices.prototype.showCity = function() { + this.city_parent_div.removeClass("mpog_hidden_field"); + }; + + + SelectFieldChoices.prototype.actualFieldIsInput = function() { + return this.getCurrentStateElement().attr("type") === "text"; + }; + + + return SelectFieldChoices; +}); diff --git a/src/gov_user/public/static/governmental_powers.txt b/src/gov_user/public/static/governmental_powers.txt new file mode 100644 index 0000000..d798c3a --- /dev/null +++ b/src/gov_user/public/static/governmental_powers.txt @@ -0,0 +1,4 @@ +Executivo +Legislativo +Judiciário +Não se aplica diff --git a/src/gov_user/public/static/governmental_sphere.txt b/src/gov_user/public/static/governmental_sphere.txt new file mode 100644 index 0000000..ef7cfce --- /dev/null +++ b/src/gov_user/public/static/governmental_sphere.txt @@ -0,0 +1,4 @@ +Federal +Estadual +Distrital +Municipal diff --git a/src/gov_user/public/static/juridical_nature.txt b/src/gov_user/public/static/juridical_nature.txt new file mode 100644 index 0000000..d66b9a7 --- /dev/null +++ b/src/gov_user/public/static/juridical_nature.txt @@ -0,0 +1,8 @@ +Administração Direta +Autarquia +Empresa Pública +Fundação +Orgão Autônomo +Sociedade +Sociedade Civil +Sociedade de Economia Mista diff --git a/src/gov_user/public/style.css b/src/gov_user/public/style.css new file mode 100644 index 0000000..c1fdab2 --- /dev/null +++ b/src/gov_user/public/style.css @@ -0,0 +1,26 @@ +#complete_registration { + padding: 5px; + width: 100%; + background-color: #fff; +} + +#complete_registration a { + text-decoration: none; +} + +#complete_registration a:hover { + font-weight: bold; +} + +#complete_registration_percentage { + width: 100%; + height: 20px; + background: #fff; + border: solid 1px #000; +} + +.highlight-error { + outline: none; + border-color: #FF0000; + box-shadow: 0 0 10px #FF0000; +} diff --git a/src/gov_user/public/vendor/jquery.js b/src/gov_user/public/vendor/jquery.js new file mode 100644 index 0000000..a3f4ebf --- /dev/null +++ b/src/gov_user/public/vendor/jquery.js @@ -0,0 +1,3 @@ +modulejs.define('jquery', function() { + return jQuery; +}); diff --git a/src/gov_user/public/vendor/jquery.maskedinput.min.js b/src/gov_user/public/vendor/jquery.maskedinput.min.js new file mode 100644 index 0000000..0d9ce6e --- /dev/null +++ b/src/gov_user/public/vendor/jquery.maskedinput.min.js @@ -0,0 +1,7 @@ +/* + Masked Input plugin for jQuery + Copyright (c) 2007-2013 Josh Bush (digitalbush.com) + Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license) + Version: 1.3.1 +*/ +(function(e){function t(){var e=document.createElement("input"),t="onpaste";return e.setAttribute(t,""),"function"==typeof e[t]?"paste":"input"}var n,a=t()+".mask",r=navigator.userAgent,i=/iphone/i.test(r),o=/android/i.test(r);e.mask={definitions:{9:"[0-9]",a:"[A-Za-z]","*":"[A-Za-z0-9]"},dataName:"rawMaskFn",placeholder:"_"},e.fn.extend({caret:function(e,t){var n;if(0!==this.length&&!this.is(":hidden"))return"number"==typeof e?(t="number"==typeof t?t:e,this.each(function(){this.setSelectionRange?this.setSelectionRange(e,t):this.createTextRange&&(n=this.createTextRange(),n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",e),n.select())})):(this[0].setSelectionRange?(e=this[0].selectionStart,t=this[0].selectionEnd):document.selection&&document.selection.createRange&&(n=document.selection.createRange(),e=0-n.duplicate().moveStart("character",-1e5),t=e+n.text.length),{begin:e,end:t})},unmask:function(){return this.trigger("unmask")},mask:function(t,r){var c,l,s,u,f,h;return!t&&this.length>0?(c=e(this[0]),c.data(e.mask.dataName)()):(r=e.extend({placeholder:e.mask.placeholder,completed:null},r),l=e.mask.definitions,s=[],u=h=t.length,f=null,e.each(t.split(""),function(e,t){"?"==t?(h--,u=e):l[t]?(s.push(RegExp(l[t])),null===f&&(f=s.length-1)):s.push(null)}),this.trigger("unmask").each(function(){function c(e){for(;h>++e&&!s[e];);return e}function d(e){for(;--e>=0&&!s[e];);return e}function m(e,t){var n,a;if(!(0>e)){for(n=e,a=c(t);h>n;n++)if(s[n]){if(!(h>a&&s[n].test(R[a])))break;R[n]=R[a],R[a]=r.placeholder,a=c(a)}b(),x.caret(Math.max(f,e))}}function p(e){var t,n,a,i;for(t=e,n=r.placeholder;h>t;t++)if(s[t]){if(a=c(t),i=R[t],R[t]=n,!(h>a&&s[a].test(i)))break;n=i}}function g(e){var t,n,a,r=e.which;8===r||46===r||i&&127===r?(t=x.caret(),n=t.begin,a=t.end,0===a-n&&(n=46!==r?d(n):a=c(n-1),a=46===r?c(a):a),k(n,a),m(n,a-1),e.preventDefault()):27==r&&(x.val(S),x.caret(0,y()),e.preventDefault())}function v(t){var n,a,i,l=t.which,u=x.caret();t.ctrlKey||t.altKey||t.metaKey||32>l||l&&(0!==u.end-u.begin&&(k(u.begin,u.end),m(u.begin,u.end-1)),n=c(u.begin-1),h>n&&(a=String.fromCharCode(l),s[n].test(a)&&(p(n),R[n]=a,b(),i=c(n),o?setTimeout(e.proxy(e.fn.caret,x,i),0):x.caret(i),r.completed&&i>=h&&r.completed.call(x))),t.preventDefault())}function k(e,t){var n;for(n=e;t>n&&h>n;n++)s[n]&&(R[n]=r.placeholder)}function b(){x.val(R.join(""))}function y(e){var t,n,a=x.val(),i=-1;for(t=0,pos=0;h>t;t++)if(s[t]){for(R[t]=r.placeholder;pos++a.length)break}else R[t]===a.charAt(pos)&&t!==u&&(pos++,i=t);return e?b():u>i+1?(x.val(""),k(0,h)):(b(),x.val(x.val().substring(0,i+1))),u?t:f}var x=e(this),R=e.map(t.split(""),function(e){return"?"!=e?l[e]?r.placeholder:e:void 0}),S=x.val();x.data(e.mask.dataName,function(){return e.map(R,function(e,t){return s[t]&&e!=r.placeholder?e:null}).join("")}),x.attr("readonly")||x.one("unmask",function(){x.unbind(".mask").removeData(e.mask.dataName)}).bind("focus.mask",function(){clearTimeout(n);var e;S=x.val(),e=y(),n=setTimeout(function(){b(),e==t.length?x.caret(0,e):x.caret(e)},10)}).bind("blur.mask",function(){y(),x.val()!=S&&x.change()}).bind("keydown.mask",g).bind("keypress.mask",v).bind(a,function(){setTimeout(function(){var e=y(!0);x.caret(e),r.completed&&e==x.val().length&&r.completed.call(x)},0)}),y()}))}})})(jQuery); \ No newline at end of file diff --git a/src/gov_user/public/vendor/modulejs-1.5.0.min.js b/src/gov_user/public/vendor/modulejs-1.5.0.min.js new file mode 100644 index 0000000..9905b63 --- /dev/null +++ b/src/gov_user/public/vendor/modulejs-1.5.0.min.js @@ -0,0 +1,2 @@ +/* modulejs 1.5.0 - http://larsjung.de/modulejs/ */ +!function(n){this.modulejs=n()}(function(){"use strict";function n(n){return function(r){return l.toString.call(r)==="[object "+n+"]"}}function r(n){return n===new Object(n)}function t(n,r){return l.hasOwnProperty.call(n,r)}function e(n,r,e){if(p&&n.forEach===p)n.forEach(r,e);else if(n.length===+n.length)for(var i=0,o=n.length;o>i;i+=1)r.call(e,n[i],i,n);else for(var u in n)t(n,u)&&r.call(e,n[u],u,n)}function i(n,r){for(var t=0,e=n.length;e>t;t+=1)if(n[t]===r)return!0;return!1}function o(n){var r={},i=[];return e(n,function(n){t(r,n)||(i.push(n),r[n]=1)}),i}function u(n,r,t){if(n){var e=new Error("[modulejs-"+r+"] "+t);throw e.code=r,e}}function c(n,r,a){if(u(!h(n),31,'id must be a string "'+n+'"'),!r&&t(b,n))return b[n];var f=y[n];u(!f,32,'id not defined "'+n+'"'),a=(a||[]).slice(0),a.push(n);var s=[];if(e(f.deps,function(n){u(i(a,n),33,"circular dependencies: "+a+" & "+n),r?(s=s.concat(c(n,r,a)),s.push(n)):s.push(c(n,r,a))}),r)return o(s);var d=f.fn.apply(void 0,s);return b[n]=d,d}function a(n,t,e){void 0===e&&(e=t,t=[]),u(!h(n),11,'id must be a string "'+n+'"'),u(y[n],12,'id already defined "'+n+'"'),u(!g(t),13,'dependencies for "'+n+'" must be an array "'+t+'"'),u(!r(e)&&!v(e),14,'arg for "'+n+'" must be object or function "'+e+'"'),y[n]={id:n,deps:t,fn:v(e)?e:function(){return e}}}function f(n){return c(n)}function s(){var n={};return e(y,function(r,e){n[e]={deps:r.deps.slice(0),reqs:c(e,!0),init:t(b,e)}}),e(y,function(r,t){var o=[];e(y,function(r,e){i(n[e].reqs,t)&&o.push(e)}),n[t].reqd=o}),n}function d(n){var r="\n";return e(s(),function(t,e){var i=n?t.reqd:t.reqs;r+=(t.init?"* ":" ")+e+" -> [ "+i.join(", ")+" ]\n"}),r}var l=Object.prototype,p=Array.prototype.forEach,h=n("String"),v=n("Function"),g=Array.isArray||n("Array"),y={},b={};return{define:a,require:f,state:s,log:d,_private:{isString:h,isFunction:v,isArray:g,isObject:r,has:t,each:e,contains:i,uniq:o,err:u,definitions:y,instances:b,resolve:c}}}); \ No newline at end of file diff --git a/src/gov_user/public/views/complete-registration.js b/src/gov_user/public/views/complete-registration.js new file mode 100644 index 0000000..81dd745 --- /dev/null +++ b/src/gov_user/public/views/complete-registration.js @@ -0,0 +1,60 @@ +modulejs.define('CompleteRegistration', ['jquery', 'NoosferoRoot'], function($, NoosferoRoot) { + 'use strict'; + + + var AJAX_URL = { + hide_registration_incomplete_percentage: + NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/hide_registration_incomplete_percentage") + }; + + + function hide_incomplete_percentage(evt) { + evt.preventDefault(); + + jQuery.get(AJAX_URL.hide_registration_incomplete_percentage, {hide:true}, function(response){ + if( response === true ) { + jQuery("#complete_registration").fadeOut(); + } + }); + } + + + function show_complete_progressbar() { + var percentage = jQuery("#complete_registration_message span").html(); + var canvas_tag = document.getElementById("complete_registration_percentage"); + + if( canvas_tag !== null ) { + var context = canvas_tag.getContext("2d"); + + percentage = canvas_tag.width*(percentage/100.0); + + context.beginPath(); + context.rect(0, 0, percentage, canvas_tag.height); + context.fillStyle = '#00FF00'; + context.fill(); + } + } + + + function repositioning_bar_percentage() { + var complete_message = $("#complete_registration").remove(); + + $(".profile-info-options").before(complete_message); + } + + + return { + isCurrentPage: function() { + return $("#complete_registration").length === 1; + }, + + + init: function() { + repositioning_bar_percentage(); + + jQuery(".hide-incomplete-percentage").click(hide_incomplete_percentage); + + show_complete_progressbar(); + } + } +}); diff --git a/src/gov_user/public/views/control-panel.js b/src/gov_user/public/views/control-panel.js new file mode 100644 index 0000000..d89a588 --- /dev/null +++ b/src/gov_user/public/views/control-panel.js @@ -0,0 +1,32 @@ +modulejs.define('ControlPanel', ['jquery'], function($) { + 'use strict'; + + 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_institution_on_control_panel(control_panel); + } + } + + + return { + isCurrentPage: function() { + return $("#profile-editor-index").length === 1; + }, + + + init: function() { + add_itens_on_controla_panel(); + } + } +}); diff --git a/src/gov_user/public/views/create-institution.js b/src/gov_user/public/views/create-institution.js new file mode 100644 index 0000000..354295c --- /dev/null +++ b/src/gov_user/public/views/create-institution.js @@ -0,0 +1,406 @@ +modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'], function($, NoosferoRoot, SelectElement) { + 'use strict'; + + var AJAX_URL = { + create_institution_modal: + NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/create_institution"), + new_institution: + NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/new_institution"), + institution_already_exists: + NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/institution_already_exists"), + get_institutions: + NoosferoRoot.urlWithSubDirectory("/plugin/gov_user/get_institutions"), + auto_complete_city: + NoosferoRoot.urlWithSubDirectory("/account/search_cities") + }; + + + 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("

    "+response.message+"

    "); + $("#create_institution_errors").switchClass("show-field", "hide-field"); + + $(".institution_container").append(get_clone_institution_data(institution_id)); + add_selected_institution_to_list(institution_id, institution_name); + + $(".remove-institution").click(remove_institution); + } else { + var errors = create_error_list(response); + $("#create_institution_errors").switchClass("hide-field", "show-field").html("

    "+response.message+"

    "+errors); + + show_errors_in_each_field(response.errors); + } + } + + function create_error_list(response){ + var errors = "
      "; + var field_name; + + for(var error_key in response.errors) { + field_name = adjust_error_key(error_key); + + if(response.errors[error_key].length > 0){ + errors += "
    • "+field_name+": "+response.errors[error_key]+"
    • "; + } + } + + errors += "
    "; + return errors; + } + + + function show_errors_in_each_field(errors) { + var error_keys = Object.keys(errors); + + // (field)|(field)|... + var verify_error = new RegExp("(\\[" + error_keys.join("\\])|(\\[") + "\\])" ); + + var fields_with_errors = $("#institution_dialog .formfield input").filter(function(index, field) { + $(field).removeClass("highlight-error"); + return verify_error.test(field.getAttribute("name")); + }); + + var selects_with_errors = $("#institution_dialog .formfield select").filter(function(index, field) { + $(field).removeClass("highlight-error"); + return verify_error.test(field.getAttribute("name")); + }); + + fields_with_errors.addClass("highlight-error"); + selects_with_errors.addClass("highlight-error"); + } + + + function adjust_error_key(error_key) { + var text = error_key.replace(/_/, " "); + text = text.charAt(0).toUpperCase() + text.slice(1); + + return text; + } + + + function save_institution(evt) { + evt.preventDefault(); + + open_loading($("#loading_message").val()); + $.ajax({ + url: AJAX_URL.new_institution, + data : get_post_data(), + type: "POST", + success: success_ajax_response, + error: function() { + close_loading(); + var error_message = $("#institution_error_message").val(); + $("#create_institution_errors").switchClass("hide-field", "show-field").html("

    "+error_message+"

    "); + } + }); + } + + function cancel_institution(evt){ + evt.preventDefault(); + $('#institution_dialog').dialog('close'); + } + + + function institution_already_exists(){ + if( this.value.length >= 3 ) { + $.get(AJAX_URL.institution_already_exists, {name:this.value}, function(response){ + if( response === true ) { + $("#already_exists_text").switchClass("hide-field", "show-field"); + } else { + $("#already_exists_text").switchClass("show-field", "hide-field"); + } + }); + } + } + + + function get_clone_institution_data(value) { + var user_institutions = $(".user_institutions").first().clone(); + user_institutions.val(value); + + return user_institutions; + } + + + function institution_autocomplete() { + $("#input_institution").autocomplete({ + source : function(request, response){ + $.ajax({ + type: "GET", + url: AJAX_URL.get_institutions, + data: {query: request.term}, + success: function(result){ + response(result); + + if( result.length === 0 ) { + $('#institution_empty_ajax_message').switchClass("hide-field", "show-field"); + } else { + $('#institution_empty_ajax_message').switchClass("show-field", "hide-field"); + } + }, + error: function(ajax, stat, errorThrown) { + console.log('Link not found : ' + errorThrown); + } + }); + }, + + minLength: 2, + + select : function (event, selected) { + $("#institution_selected").val(selected.item.id).attr("data-name", selected.item.label); + } + }); + } + + + function add_selected_institution_to_list(id, name) { + var selected_institution = "
  • "+name; + selected_institution += "
  • "; + + $(".institutions_added").append(selected_institution); + } + + + function add_new_institution(evt) { + evt.preventDefault(); + var selected = $("#institution_selected"); + var institution_already_added = $(".institutions_added li[data-institution='"+selected.val()+"']").length; + + if(selected.val().length > 0 && institution_already_added === 0) { + //field that send the institutions to the server + $(".institution_container").append(get_clone_institution_data(selected.val())); + + // Visualy add the selected institution to the list + add_selected_institution_to_list(selected.val(), selected.attr("data-name")); + + // clean the institution flag + selected.val("").attr("data-name", ""); + $("#input_institution").val(""); + + $(".remove-institution").click(remove_institution); + } + } + + + function remove_institution(evt) { + evt.preventDefault(); + var code = $(this).parent().attr("data-institution"); + + $(".user_institutions[value="+code+"]").remove(); + $(this).parent().remove(); + } + + + function add_mask_to_form_items() { + if ($.mask) { + $("#institutions_cnpj").mask("99.999.999/9999-99"); + } + } + + + function show_hide_cnpj_city(country) { + var cnpj = $("#institutions_cnpj").parent().parent(); + var city = $("#community_city").parent().parent(); + var state = $("#community_state").parent().parent(); + var inst_type = $("input[name='institutions[type]']:checked").val(); + institution_type_actions(inst_type); + + if( country === "-1" ) $("#community_country").val("BR"); + + if( country !== "BR" ) { + cnpj.hide(); + city.hide(); + state.hide(); + } else { + cnpj.show(); + city.show(); + state.show(); + } + } + + function institution_type_actions(type) { + var country = $("#community_country").val(); + if( type === "PublicInstitution" && country == "BR") { + show_public_institutions_fields(); + } else { + show_private_institutions_fields(); + } + } + + + function set_form_count_custom_data() { + var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); + var default_option = SelectElement.generateOption("BR", "Brazil"); + + + var inst_type = $("input[name='institutions[type]']:checked").val(); + var country = $("#community_country").val(); + + institution_type_actions(inst_type); + show_hide_cnpj_city(country); + + if( $('#community_country').find("option[value='']").length === 1 ) { + $('#community_country').find("option[value='']").remove(); + $('#community_country').prepend(divisor_option); + $('#community_country').prepend(default_option); + + if($("#edit_institution_page").val() === "false") { + $('#community_country').val("BR"); + show_hide_cnpj_city($('#community_country').val()); + } + } + } + + function autoCompleteCity() { + var country_selected = $('#community_country').val(); + + if(country_selected == "BR") { + $('#community_city').autocomplete({ + source : function(request, response){ + $.ajax({ + type: "GET", + url: AJAX_URL.auto_complete_city, + data: {city_name: request.term, state_name: $("#community_state").val()}, + success: function(result){ + response(result); + + // There are two autocompletes in this page, the last one is modal + // autocomplete just put it above the modal + $(".ui-autocomplete").last().css("z-index", 1000); + }, + error: function(ajax, stat, errorThrown) { + console.log('Link not found : ' + errorThrown); + } + }); + }, + + minLength: 3 + }); + } else { + if ($('#community_city').data('autocomplete')) { + $('#community_city').autocomplete("destroy"); + $('#community_city').removeData('autocomplete'); + } + } + } + + function set_events() { + $("#create_institution_link").click(open_create_institution_modal); + + $("input[name='institutions[type]']").click(function(){ + institution_type_actions(this.value); + }); + + $('#save_institution_button').click(save_institution); + $('#cancel_institution_button').click(cancel_institution); + + $("#community_name").keyup(institution_already_exists); + + $("#add_new_institution").click(add_new_institution); + + $(".remove-institution").click(remove_institution); + + $("#community_country").change(function(){ + show_hide_cnpj_city(this.value); + }); + + add_mask_to_form_items(); + + institution_autocomplete(); + + autoCompleteCity(); + $('#community_country').change(function(){ + autoCompleteCity(); + }); + } + + + return { + isCurrentPage: function() { + return $("#institution_form").length === 1; + }, + + + init: function() { + set_form_count_custom_data(); + set_events(); + }, + + institution_autocomplete: function(){ + institution_autocomplete(); + } + }; +}); diff --git a/src/gov_user/public/views/gov-user-comments-extra-fields.js b/src/gov_user/public/views/gov-user-comments-extra-fields.js new file mode 100644 index 0000000..d302437 --- /dev/null +++ b/src/gov_user/public/views/gov-user-comments-extra-fields.js @@ -0,0 +1,26 @@ +modulejs.define("GovUserCommentsExtraFields", ['jquery','CreateInstitution'], function($,CreateInstitution) { + + function set_events() { + CreateInstitution.institution_autocomplete(); + } + + + function prepend_to_additional_information() { + var institution_comments = $("#input_institution_comments").remove(); + + $(".comments-software-extra-fields").prepend(institution_comments); + } + + + return { + isCurrentPage: function() { + return $(".star-rate-form").length === 1; + }, + + init: function() { + prepend_to_additional_information(); + set_events(); + } + } + +}) diff --git a/src/gov_user/public/views/new-community.js b/src/gov_user/public/views/new-community.js new file mode 100644 index 0000000..b665e8f --- /dev/null +++ b/src/gov_user/public/views/new-community.js @@ -0,0 +1,28 @@ +modulejs.define("NewCommunity", ['jquery'], function($) { + + function replace_mandatory_message() { + $(".required-field").first() + .replaceWith(" Os campos em destaque são obrigatórios. "); + } + + function remove_image_builder_text() { + $("label:contains('Image builder')").hide(); + } + + function hide_organization_template_fields(){ + $('#template-options').hide(); + } + + return { + + isCurrentPage: function() { + return true; + }, + + init: function() { + replace_mandatory_message(); + remove_image_builder_text(); + hide_organization_template_fields(); + } + } +}) diff --git a/src/gov_user/public/views/user-edit-profile.js b/src/gov_user/public/views/user-edit-profile.js new file mode 100644 index 0000000..c92c987 --- /dev/null +++ b/src/gov_user/public/views/user-edit-profile.js @@ -0,0 +1,216 @@ +modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoices', 'CreateInstitution'], function($, SelectElement, SelectFieldChoices, CreateInstitution) { + 'use strict'; + + function set_form_count_custom_data() { + var divisor_option = SelectElement.generateOption("-1", "--------------------------------"); + var default_option = SelectElement.generateOption("BR", "Brazil"); + + $('#profile_data_country').find("option[value='']").remove(); + $('#profile_data_country').prepend(divisor_option); + $('#profile_data_country').prepend(default_option); + $('#profile_data_country').val("BR"); + } + + + function set_initial_form_custom_data(selectFieldChoices) { + set_form_count_custom_data(); + + $("#password-balloon").html($("#user_password_menssage").val()); + $("#profile_data_email").parent().append($("#email_public_message").remove()); + + if( $("#state_field").length !== 0 ) selectFieldChoices.replaceStateWithSelectElement(); + } + + + function show_state_if_country_is_brazil() { + var selectFieldChoices = new SelectFieldChoices("#state_field", "#city_field", "/plugin/gov_user/get_brazil_states"); + set_initial_form_custom_data(selectFieldChoices); + + $("#profile_data_country").change(function(){ + if( this.value === "-1" ) $(this).val("BR"); + + if( this.value === "BR" && selectFieldChoices.actualFieldIsInput() ) { + selectFieldChoices.replaceStateWithSelectElement(); + selectFieldChoices.showCity(); + } else if( this.value !== "BR" && !selectFieldChoices.actualFieldIsInput() ) { + selectFieldChoices.replaceStateWithInputElement(); + selectFieldChoices.hideCity(); + } + }); + } + + + function show_or_hide_phone_mask() { + if($("#profile_data_country").val() === "BR") { + if( (typeof $("#profile_data_cell_phone").data("rawMaskFn") === 'undefined') ) { + // $("#profile_data_cell_phone").mask("(99) 9999?9-9999"); + // $("#profile_data_comercial_phone").mask("(99) 9999?9-9999"); + // $("#profile_data_contact_phone").mask("(99) 9999?9-9999"); + } + } else { + // $("#profile_data_cell_phone").unmask(); + // $("#profile_data_comercial_phone").unmask(); + // $("#profile_data_contact_phone").unmask(); + } + } + + + function fix_phone_mask_format(id) { + $(id).blur(function() { + var last = $(this).val().substr( $(this).val().indexOf("-") + 1 ); + + if( last.length === 3 ) { + var move = $(this).val().substr( $(this).val().indexOf("-") - 1, 1 ); + var lastfour = move + last; + var first = $(this).val().substr( 0, 9 ); + + $(this).val( first + '-' + lastfour ); + } + }); + } + + + function show_plugin_error_message(field_selector, hidden_message_id ) { + var field = $(field_selector); + + field.removeClass("validated").addClass("invalid"); + + if(!$("." + hidden_message_id)[0]) { + var message = $("#" + hidden_message_id).val(); + field.parent().append("
    "+message+""); + } else { + $("." + hidden_message_id).show(); + } + } + + + function hide_plugin_error_message(field_selector, hidden_message_id) { + $(field_selector).removeClass("invalid").addClass("validated"); + $("." + hidden_message_id).hide(); + } + + + function add_blur_fields(field_selector, hidden_message_id, validation_function, allow_blank) { + $(field_selector).blur(function(){ + $(this).attr("class", ""); + + if( validation_function(this.value, !!allow_blank) ) { + show_plugin_error_message(field_selector, hidden_message_id); + } else { + hide_plugin_error_message(field_selector, hidden_message_id); + } + }); + } + + + function invalid_email_validation(value, allow_blank) { + if( allow_blank && value.trim().length === 0 ) { + return false; + } + + var correct_format_regex = new RegExp(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/); + + return !correct_format_regex.test(value); + } + + + function invalid_site_validation(value) { + var correct_format_regex = new RegExp(/(^|)(http[s]{0,1})\:\/\/(\w+[.])\w+/g); + + return !correct_format_regex.test(value); + } + + + function get_privacy_selector_parent_div(field_id, actual) { + if( actual === undefined ) actual = $(field_id); + + if( actual.is("form") || actual.length === 0 ) return null; // Not allow recursion over form + + if( actual.hasClass("field-with-privacy-selector") ) { + return actual; + } else { + return get_privacy_selector_parent_div(field_id, actual.parent()); + } + } + + + function try_to_remove(list, field) { + try { + list.push(field.remove()); + } catch(e) { + console.log("Cound not remove field"); + } + } + + + function get_edit_fields_in_insertion_order() { + var containers = []; + + try_to_remove(containers, get_privacy_selector_parent_div("#city_field")); + try_to_remove(containers, get_privacy_selector_parent_div("#state_field")); + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_country")); + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_birth_date")); + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_organization_website")); + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_personal_website")); + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_comercial_phone")); + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_contact_phone")); + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_cell_phone")); + try_to_remove(containers, $("#select_institution")); + try_to_remove(containers, $("#user_secondary_email").parent().parent()); + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_email")); + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_name")); + try_to_remove(containers, $(".pseudoformlabel").parent().parent()); + try_to_remove(containers, $("h2")[0]); + + return containers; + } + + + function change_edit_fields_order() { + var form = $("#profile-data"); + + if( form.length !== 0 ) { + var containers = get_edit_fields_in_insertion_order(); + + containers.forEach(function(container){ + form.prepend(container); + }); + } + } + + + function set_fields_validations() { + $("#profile_data_country").blur(show_or_hide_phone_mask); + + // $("#profile_data_birth_date").mask("99/99/9999"); + + fix_phone_mask_format("#profile_data_cell_phone"); + fix_phone_mask_format("#profile_data_comercial_phone"); + fix_phone_mask_format("#profile_data_contact_phone"); + + add_blur_fields("#profile_data_email", "email_error", invalid_email_validation); + add_blur_fields("#user_secondary_email", "email_error", invalid_email_validation, true); + add_blur_fields("#profile_data_personal_website", "site_error", invalid_site_validation); + add_blur_fields("#profile_data_organization_website", "site_error", invalid_site_validation); + } + + + return { + isCurrentPage: function() { + return $('#profile_data_email').length === 1; + }, + + + init: function() { + change_edit_fields_order(); // To change the fields order, it MUST be the first function executed + + show_state_if_country_is_brazil(); + + show_or_hide_phone_mask(); + + set_fields_validations(); + + CreateInstitution.init(); + } + } +}); diff --git a/src/gov_user/test/functional/gov_user_plugin_controller_test.rb b/src/gov_user/test/functional/gov_user_plugin_controller_test.rb new file mode 100644 index 0000000..48b4fc4 --- /dev/null +++ b/src/gov_user/test/functional/gov_user_plugin_controller_test.rb @@ -0,0 +1,236 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/institution_test_helper' +require File.dirname(__FILE__) + '/../../controllers/gov_user_plugin_controller' + +class GovUserPluginController; def rescue_action(e) raise e end; end +class GovUserPluginControllerTest < ActionController::TestCase + + + def setup + @admin = create_user("adminuser").person + @admin.stubs(:has_permission?).returns("true") + @controller.stubs(:current_user).returns(@admin.user) + + @environment = Environment.default + @environment.enabled_plugins = ['SoftwareCommunitiesPlugin'] + @environment.add_admin(@admin) + @environment.save + + @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") + @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + @juridical_nature = JuridicalNature.create(:name => "Autarquia") + @response = ActionController::TestResponse.new + + @institution_list = [] + @institution_list << InstitutionTestHelper.create_public_institution( + "Ministerio Publico da Uniao", + "MPU", + "BR", + "DF", + "Gama", + @juridical_nature, + @gov_power, + @gov_sphere, + "12.345.678/9012-45" + ) + @institution_list << InstitutionTestHelper.create_public_institution( + "Tribunal Regional da Uniao", + "TRU", + "BR", + "DF", + "Brasilia", + @juridical_nature, + @gov_power, + @gov_sphere, + "12.345.678/9012-90" + ) + + end + + should "Search for institution with acronym" do + xhr :get, :get_institutions, :query=>"TRU" + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert_equal "Tribunal Regional da Uniao", json_response[0]["value"] + end + + should "Search for institution with name" do + xhr :get, :get_institutions, :query=>"Minis" + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert_equal "Ministerio Publico da Uniao", json_response[0]["value"] + end + + should "search with name or acronym and return a list with institutions" do + xhr :get, :get_institutions, :query=>"uni" + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert_equal "Ministerio Publico da Uniao", json_response[0]["value"] + assert_equal "Tribunal Regional da Uniao", json_response[1]["value"] + end + + should "method create_institution return the html for modal" do + @controller.stubs(:current_user).returns(@admin.user) + xhr :get, :create_institution + assert_template 'create_institution' + end + + should "create new institution with ajax without acronym" do + @controller.stubs(:verify_recaptcha).returns(true) + + fields = InstitutionTestHelper.generate_form_fields( + "foo bar", + "BR", + "DF", + "Brasilia", + "12.234.567/8900-10", + "PublicInstitution" + ) + fields[:institutions][:governmental_power] = @gov_power.id + fields[:institutions][:governmental_sphere] = @gov_sphere.id + fields[:institutions][:juridical_nature] = @juridical_nature.id + + xhr :get, :new_institution, fields + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert json_response["success"] + end + + should "create a institution without cnpj" do + @controller.stubs(:verify_recaptcha).returns(true) + + fields = InstitutionTestHelper.generate_form_fields( + "Some Private Institution", + "BR", + "DF", + "Brasilia", + "", + "PrivateInstitution" + ) + fields[:institutions][:acronym] = "SPI" + + xhr :get, :new_institution, fields + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert json_response["success"] + end + + should "verify if institution name already exists" do + xhr :get, :institution_already_exists, :name=>"Ministerio Publico da Uniao" + assert_equal "true", @response.body + + xhr :get, :institution_already_exists, :name=>"Another name here" + assert_equal "false", @response.body + end + + should "hide registration incomplete message" do + xhr :get, :hide_registration_incomplete_percentage, :hide=>true + assert_equal "true", @response.body + end + + should "not hide registration incomplete message" do + xhr :get, :hide_registration_incomplete_percentage, :hide=>false + assert_equal "false", @response.body + end + + should "Create new institution with method post" do + @controller.stubs(:verify_recaptcha).returns(true) + + fields = InstitutionTestHelper.generate_form_fields( + "Some Private Institution", + "BR", + "DF", + "Brasilia", + "12.345.567/8900-10", + "PrivateInstitution" + ) + fields[:institutions][:acronym] = "SPI" + + post :new_institution, fields + + assert_redirected_to(controller: "admin_panel", action: "index") + end + + should "not create new institution with method post without cnpj" do + @controller.stubs(:verify_recaptcha).returns(true) + + fields = InstitutionTestHelper.generate_form_fields( + "Some Private Institution", + "BR", + "DF", + "Brasilia", + "56.366.790/0001-88", + "PrivateInstitution" + ) + + post :new_institution, fields + + assert_redirected_to(controller: "admin_panel", action: "index") + end + + should "Create foreign institution without city, state and cnpj by post" do + @controller.stubs(:verify_recaptcha).returns(true) + + fields = InstitutionTestHelper.generate_form_fields( + "Foreign institution", + "AZ", + "", + "", + "", + "PrivateInstitution" + ) + fields[:institutions][:acronym] = "FI" + + post :new_institution, fields + + assert_redirected_to(controller: "admin_panel", action: "index") + end + + should "Create foreign institution without city, state and cnpj by ajax" do + @controller.stubs(:verify_recaptcha).returns(true) + + fields = InstitutionTestHelper.generate_form_fields( + "Foreign institution", + "AZ", + "", + "", + "", + "PrivateInstitution" + ) + fields[:institutions][:acronym] = "FI" + + xhr :post, :new_institution, fields + + json_response = ActiveSupport::JSON.decode(@response.body) + + assert json_response["success"] + end + + should "add environment admins to institution when created via admin panel" do + @controller.stubs(:verify_recaptcha).returns(true) + admin2 = create_user("another_admin").person + admin2.stubs(:has_permission?).returns("true") + @environment.add_admin(admin2) + @environment.save + + fields = InstitutionTestHelper.generate_form_fields( + "Private Institution", + "BR", + "DF", + "Brasilia", + "12.323.557/8900-10", + "PrivateInstitution" + ) + fields[:institutions][:acronym] = "PI" + fields[:edit_institution_page] = false + post :new_institution, fields + + assert(Institution.last.community.admins.include?(admin2) ) + end + +end diff --git a/src/gov_user/test/functional/gov_user_plugin_myprofile_controller.rb b/src/gov_user/test/functional/gov_user_plugin_myprofile_controller.rb new file mode 100644 index 0000000..61c48b1 --- /dev/null +++ b/src/gov_user/test/functional/gov_user_plugin_myprofile_controller.rb @@ -0,0 +1,105 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/institution_test_helper' +require( +File.dirname(__FILE__) + +'/../../controllers/gov_user_plugin_myprofile_controller' +) + +class GovUserPluginMyprofileController; def rescue_action(e) raise e end; +end + +class GovUserPluginMyprofileControllerTest < ActionController::TestCase + def setup + @controller = GovUserPluginMyprofileController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + @person = create_user('person').person + @offer = create_user('Angela Silva') + @offer_1 = create_user('Ana de Souza') + @offer_2 = create_user('Angelo Roberto') + + login_as(@person.user_login) + @environment = Environment.default + @environment.enable_plugin('GovUserPlugin') + @environment.save! + end + should "user edit its community institution" do + govPower = GovernmentalPower.create(:name=>"Some Gov Power") + govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + juridical_nature = JuridicalNature.create(:name => "Autarquia") + + institution = InstitutionTestHelper.create_public_institution( + "Ministerio Publico da Uniao", + "MPU", + "BR", + "DF", + "Gama", + juridical_nature, + govPower, + govSphere, + "12.345.678/9012-45" + ) + + identifier = institution.community.identifier + + fields = InstitutionTestHelper.generate_form_fields( + "institution new name", + "BR", + "DF", + "Gama", + "12.345.678/9012-45", + "PrivateInstitution" + ) + + post( + :edit_institution, + :profile=>institution.community.identifier, + :community=>fields[:community], + :institutions=>fields[:institutions] + ) + + institution = Community[identifier].institution + assert_not_equal "Ministerio Publico da Uniao", institution.community.name + end + + should "not user edit its community institution with wrong values" do + govPower = GovernmentalPower.create(:name=>"Some Gov Power") + govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + juridical_nature = JuridicalNature.create(:name => "Autarquia") + + institution = InstitutionTestHelper.create_public_institution( + "Ministerio Publico da Uniao", + "MPU", + "BR", + "DF", + "Gama", + juridical_nature, + govPower, + govSphere, + "12.345.678/9012-45" + ) + + identifier = institution.community.identifier + + fields = InstitutionTestHelper.generate_form_fields( + "", + "BR", + "DF", + "Gama", + "6465465465", + "PrivateInstitution" + ) + + post( + :edit_institution, + :profile=>institution.community.identifier, + :community=>fields[:community], + :institutions=>fields[:institutions] + ) + + institution = Community[identifier].institution + assert_equal "Ministerio Publico da Uniao", institution.community.name + assert_equal "12.345.678/9012-45", institution.cnpj + end + +end diff --git a/src/gov_user/test/functional/profile_editor_controller_test.rb b/src/gov_user/test/functional/profile_editor_controller_test.rb new file mode 100644 index 0000000..52de533 --- /dev/null +++ b/src/gov_user/test/functional/profile_editor_controller_test.rb @@ -0,0 +1,112 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/institution_test_helper' +require( +File.dirname(__FILE__) + +'/../../../../app/controllers/my_profile/profile_editor_controller' +) + +class ProfileEditorController; def rescue_action(e) raise e end; end + +class ProfileEditorControllerTest < ActionController::TestCase + + def setup + @controller = ProfileEditorController.new + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + @profile = create_user('default_user').person + + Environment.default.affiliate( + @profile, + [Environment::Roles.admin(Environment.default.id)] + + Profile::Roles.all_roles(Environment.default.id) + ) + + @environment = Environment.default + @environment.enabled_plugins = ['GovUserPlugin'] + admin = create_user("adminuser").person + admin.stubs(:has_permission?).returns("true") + login_as('adminuser') + @environment.add_admin(admin) + @environment.save + + @govPower = GovernmentalPower.create(:name=>"Some Gov Power") + @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + @juridical_nature = JuridicalNature.create(:name => "Autarquia") + + @institution_list = [] + @institution_list << InstitutionTestHelper.create_public_institution( + "Ministerio Publico da Uniao", + "MPU", + "BR", + "DF", + "Gama", + @juridical_nature, + @govPower, + @govSphere, + "12.345.678/9012-45" + ) + + @institution_list << InstitutionTestHelper.create_public_institution( + "Tribunal Regional da Uniao", + "TRU", + "BR", + "DF", + "Brasilia", + @juridical_nature, + @govPower, + @govSphere, + "12.345.678/9012-90" + ) + end + + should "add new institution for user into edit profile" do + user = create_basic_user + + params_user = Hash.new + params_user[:institution_ids] = [] + + @institution_list.each do |institution| + params_user[:institution_ids] << institution.id + end + + post :edit, :profile => User.last.person.identifier, :user => params_user + + assert_equal @institution_list.count, User.last.institutions.count + end + + should "remove institutions for user into edit profile" do + user = create_basic_user + + @institution_list.each do |institution| + user.institutions << institution + end + user.save! + + params_user = Hash.new + params_user[:institution_ids] = [] + + assert_equal @institution_list.count, User.last.institutions.count + + post :edit, :profile => User.last.person.identifier, :user => params_user + + assert_equal 0, User.last.institutions.count + end + + protected + + def create_basic_user + user = fast_create(User) + user.person = fast_create(Person) + user.person.user = user + user.save! + user.person.save! + user + end + + def create_community name + community = fast_create(Community) + community.name = name + community.save + community + end +end diff --git a/src/gov_user/test/functional/search_controller_test.rb b/src/gov_user/test/functional/search_controller_test.rb new file mode 100644 index 0000000..ab45f06 --- /dev/null +++ b/src/gov_user/test/functional/search_controller_test.rb @@ -0,0 +1,57 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' +require( +File.dirname(__FILE__) + +'/../../../../app/controllers/public/search_controller' +) + +class SearchController; def rescue_action(e) raise e end; end + +class SearchControllerTest < ActionController::TestCase + include PluginTestHelper + + def setup + @environment = Environment.default + @environment.enabled_plugins = ['SoftwareCommunitiesPlugin'] + @environment.save + + @controller = SearchController.new + @request = ActionController::TestRequest.new + @request.stubs(:ssl?).returns(:false) + @response = ActionController::TestResponse.new + end + + should "communities searches don't have institution" do + community = create_community("New Community") + institution = create_private_institution( + "New Private Institution", + "NPI" , + "Brazil", + "DF", + "Gama", + "66.544.314/0001-63" + ) + + get :communities, :query => "New" + + assert_includes assigns(:searches)[:communities][:results], community + assert_not_includes assigns(:searches)[:communities][:results], institution.community + end + + should "institutions_search don't have community" do + community = create_community("New Community") + institution = create_private_institution( + "New Private Institution", + "NPI" , + "Brazil", + "DF", + "Gama", + "66.544.314/0001-63" + ) + + get :institutions, :query => "New" + + assert_includes assigns(:searches)[:institutions][:results], institution.community + assert_not_includes assigns(:searches)[:institutions][:results], community + end +end diff --git a/src/gov_user/test/helpers/institution_test_helper.rb b/src/gov_user/test/helpers/institution_test_helper.rb new file mode 100644 index 0000000..1f4df2f --- /dev/null +++ b/src/gov_user/test/helpers/institution_test_helper.rb @@ -0,0 +1,59 @@ +module InstitutionTestHelper + + def self.generate_form_fields name, country, state, city, cnpj, type + fields = { + :community => { + :name => name, + :country => country, + :state => state, + :city => city + }, + :institutions => { + :cnpj=> cnpj, + :type => type, + :acronym => "", + :governmental_power => "", + :governmental_sphere => "", + :juridical_nature => "", + :corporate_name => "coporate default" + } + } + fields + end + + def self.create_public_institution name, acronym, country, state, city, juridical_nature, gov_p, gov_s, cnpj + institution = PublicInstitution.new + institution.community = institution_community(name, country, state, city) + institution.name = name + institution.juridical_nature = juridical_nature + institution.acronym = acronym + institution.governmental_power = gov_p + institution.governmental_sphere = gov_s + institution.cnpj = cnpj + institution.corporate_name = "corporate default" + institution.save + institution + end + + def self.create_private_institution name, acronym, country, state, city, cnpj + institution = PrivateInstitution.new + institution.community = institution_community(name, country, state, city) + institution.name = name + institution.acronym = acronym + institution.cnpj = cnpj + institution.corporate_name = "corporate default" + institution.save + + institution + end + + def self.institution_community name, country, state, city + institution_community = Community::new + institution_community.name = name + institution_community.country = country + institution_community.state = state + institution_community.city = city + institution_community.save + institution_community + end +end \ No newline at end of file diff --git a/src/gov_user/test/helpers/plugin_test_helper.rb b/src/gov_user/test/helpers/plugin_test_helper.rb new file mode 100644 index 0000000..741cb2f --- /dev/null +++ b/src/gov_user/test/helpers/plugin_test_helper.rb @@ -0,0 +1,77 @@ +require File.dirname(__FILE__) + '/../helpers/institution_test_helper' + +module PluginTestHelper + + def create_person name, email, password, password_confirmation, secondary_email, state="state", city="city" + user = create_user( + name.to_slug, + email, + password, + password_confirmation, + secondary_email + ) + person = Person::new + + user.person = person + person.user = user + + person.name = name + person.identifier = name.to_slug + person.state = state + person.city = city + + user.save + person.save + + person + end + + def create_user login, email, password, password_confirmation, secondary_email + user = User.new + + user.login = login + user.email = email + user.password = password + user.password_confirmation = password_confirmation + user.secondary_email = secondary_email + + user + end + + def create_public_institution *params + InstitutionTestHelper.create_public_institution *params + end + + def create_community name + community = fast_create(Community) + community.name = name + community.save + community + end + + + def create_private_institution name, acronym, country, state, city, cnpj + InstitutionTestHelper.create_private_institution( + name, + acronym, + country, + state, + city, + cnpj + ) + end + + def create_public_institution *params + InstitutionTestHelper.create_public_institution *params + end + + def create_community_institution name, country, state, city + community = fast_create(Community) + community.name = name + community.country = country + community.state = state + community.city = city + community.save + community + end +end diff --git a/src/gov_user/test/unit/gov_user_person_test.rb b/src/gov_user/test/unit/gov_user_person_test.rb new file mode 100644 index 0000000..0c58478 --- /dev/null +++ b/src/gov_user/test/unit/gov_user_person_test.rb @@ -0,0 +1,58 @@ +# encoding: utf-8 + +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase + include PluginTestHelper + + def setup + @plugin = GovUserPlugin.new + + @user = fast_create(User) + @person = create_person( + "My Name", + "user@email.com", + "123456", + "123456", + "user2@email.com", + "Any State", + "Some City" + ) + end + + def teardown + @plugin = nil + end + + should 'be a noosfero plugin' do + assert_kind_of Noosfero::Plugin, @plugin + end + + should 'save person with a valid full name' do + p = Person::new :name=>"S1mpl3 0f N4m3", :identifier=>"simple-name" + p.user = fast_create(:user) + + assert_equal true, p.save + end + + should 'save person with a valid full name with accents' do + name = 'Jônatàs dâ Sîlvã Jösé' + identifier = "jonatas-jose-da-silva" + p = Person::new :name=>name, :identifier=>identifier + p.user = fast_create(:user) + + assert_equal true, p.save + end + + should 'not save person whose name has not capital letter' do + p = Person::new :name=>"simple name" + assert !p.save, _("Name Should begin with a capital letter and no special characters") + end + + should 'not save person whose name has special characters' do + p = Person::new :name=>"Simple N@me" + + assert !p.save , _("Name Should begin with a capital letter and no special characters") + end +end diff --git a/src/gov_user/test/unit/governmental_power_test.rb b/src/gov_user/test/unit/governmental_power_test.rb new file mode 100644 index 0000000..5f777e6 --- /dev/null +++ b/src/gov_user/test/unit/governmental_power_test.rb @@ -0,0 +1,33 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/institution_test_helper' + +class GovernmentalPowerTest < ActiveSupport::TestCase + + def setup + @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + @juridical_nature = JuridicalNature.create(:name => "Autarquia") + end + + def teardown + Institution.destroy_all + end + + should "get public institutions" do + inst_name = "Ministerio Publico da Uniao" + inst_cnpj = "12.345.678/9012-45" + gov_power = GovernmentalPower.create(:name=>"Some gov power") + InstitutionTestHelper.create_public_institution( + inst_name, + "MPU", + "BR", + "DF", + "Gama", + @juridical_nature, + gov_power, + @gov_sphere, + inst_cnpj + ) + + assert_equal gov_power.public_institutions.count, PublicInstitution.count + end +end \ No newline at end of file diff --git a/src/gov_user/test/unit/institution_test.rb b/src/gov_user/test/unit/institution_test.rb new file mode 100644 index 0000000..c4c77e5 --- /dev/null +++ b/src/gov_user/test/unit/institution_test.rb @@ -0,0 +1,63 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class InstitutionTest < ActiveSupport::TestCase + include PluginTestHelper + def setup + @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") + @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + @juridical_nature = JuridicalNature.create(:name => "Autarquia") + + @institution = create_public_institution( + "Ministerio Publico da Uniao", + "MPU", + "BR", + "DF", + "Gama", + @juridical_nature, + @gov_power, + @gov_sphere, + "11.222.333/4444-55" + ) + end + + def teardown + GovernmentalPower.destroy_all + GovernmentalSphere.destroy_all + JuridicalNature.destroy_all + @institution = nil + end + should "not save institutions without name" do + @institution.name = nil + assert_equal false, @institution.save + assert_equal true, @institution.errors.full_messages.include?("Name can't be blank") + end + + should "not save if institution has invalid type" do + invalid_msg = "Type invalid, only public and private institutions are allowed." + @institution.type = "Other type" + assert_equal false, @institution.save + assert_equal true, @institution.errors.full_messages.include?(invalid_msg) + end + + should "not save without country" do + @institution.community.country = nil + assert_equal false, @institution.save + assert_equal true, @institution.errors.full_messages.include?("Country can't be blank") + end + + should "not save without state" do + @institution.community.state = nil + + assert_equal false, @institution.save + assert_equal true, @institution.errors.full_messages.include?("State can't be blank") + end + + should "not save without city" do + @institution.community.city = nil + @institution.community.state = "DF" + + assert_equal false, @institution.save + assert_equal true, @institution.errors.full_messages.include?("City can't be blank") + end +end diff --git a/src/gov_user/test/unit/institutions_block_test.rb b/src/gov_user/test/unit/institutions_block_test.rb new file mode 100644 index 0000000..bcab723 --- /dev/null +++ b/src/gov_user/test/unit/institutions_block_test.rb @@ -0,0 +1,51 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class InstitutionsBlockTest < ActiveSupport::TestCase + include PluginTestHelper + should 'inherit from Block' do + assert_kind_of Block, InstitutionsBlock.new + end + + should 'declare its default title' do + InstitutionsBlock.any_instance.stubs(:profile_count).returns(0) + assert_not_equal Block.new.default_title, InstitutionsBlock.new.default_title + end + + should 'describe itself' do + assert_not_equal Block.description, InstitutionsBlock.description + end + + should 'give empty footer on unsupported owner type' do + block = InstitutionsBlock.new + block.expects(:owner).returns(1) + assert_equal '', block.footer + end + + should 'list institutions' do + user = create_person("Jose_Augusto", + "jose_augusto@email.com", + "aaaaaaa", + "aaaaaaa", + 'jose@secondary.com', + "DF", + "Gama" + ) + + institution = create_private_institution( + "inst name", + "IN", + "country", + "state", + "city", + "00.111.222/3333-44" + ) + institution.community.add_member(user) + + block = InstitutionsBlock.new + block.expects(:owner).at_least_once.returns(user) + + assert_equivalent [institution.community], block.profiles + end + +end diff --git a/src/gov_user/test/unit/juridical_nature_test.rb b/src/gov_user/test/unit/juridical_nature_test.rb new file mode 100644 index 0000000..80d34c6 --- /dev/null +++ b/src/gov_user/test/unit/juridical_nature_test.rb @@ -0,0 +1,23 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class JuridicalNatureTest < ActiveSupport::TestCase + + include PluginTestHelper + + def setup + @govPower = GovernmentalPower.create(:name=>"Some Gov Power") + @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + end + + def teardown + Institution.destroy_all + end + + should "get public institutions" do + juridical_nature = JuridicalNature.create(:name => "Autarquia") + create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", juridical_nature, @govPower, @govSphere, "22.333.444/5555-66") + create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", juridical_nature, @govPower, @govSphere, "22.333.444/5555-77") + assert juridical_nature.public_institutions.count == PublicInstitution.count + end +end diff --git a/src/gov_user/test/unit/organization_rating_test.rb b/src/gov_user/test/unit/organization_rating_test.rb new file mode 100644 index 0000000..748355f --- /dev/null +++ b/src/gov_user/test/unit/organization_rating_test.rb @@ -0,0 +1,44 @@ +require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' +require File.expand_path(File.dirname(__FILE__)) + '/../helpers/plugin_test_helper' + +class OrganizationRatingTest < ActiveSupport::TestCase + include PluginTestHelper + + def setup + @environment = Environment.default + @environment.enabled_plugins = ['SoftwareCommunitiesPlugin'] + @environment.save + end + + should "validate institution if there is an institution_id" do + person = fast_create(Person) + community = fast_create(Community) + private_institution = build_private_institution "huehue", "hue", "11.222.333/4444-55" + + community_rating = OrganizationRating.new(:person => person, :value => 3, :organization => community, :institution => private_institution) + assert_equal false, community_rating.valid? + + assert_equal true, community_rating.errors[:institution].include?("not found") + + private_institution.save + community_rating.institution = private_institution + + assert_equal true, community_rating.valid? + assert_equal false, community_rating.errors[:institution].include?("not found") + end + + private + + def build_private_institution name, corporate_name, cnpj, country="AR" + community = Community.new :name => name + community.country = country + + institution = PrivateInstitution.new :name=> name + institution.corporate_name = corporate_name + institution.cnpj = cnpj + institution.community = community + + institution + end +end + diff --git a/src/gov_user/test/unit/person_test.rb b/src/gov_user/test/unit/person_test.rb new file mode 100644 index 0000000..dd6c628 --- /dev/null +++ b/src/gov_user/test/unit/person_test.rb @@ -0,0 +1,43 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase + include PluginTestHelper + def setup + @plugin = GovUserPlugin.new + + @user = fast_create(User) + @person = create_person( + "My Name", + "user@email.com", + "123456", + "123456", + "user@secondaryemail.com", + "Any State", + "Some City" + ) + end + + should 'calculate the percentege of person incomplete fields' do + @person.cell_phone = "76888919" + @person.contact_phone = "987654321" + + assert_equal(67, @plugin.calc_percentage_registration(@person)) + + @person.comercial_phone = "11223344" + @person.country = "I dont know" + @person.state = "I dont know" + @person.city = "I dont know" + @person.organization_website = "www.whatever.com" + @person.image = Image::new :uploaded_data=>fixture_file_upload('/files/rails.png', 'image/png') + @person.save + + assert_equal(100, @plugin.calc_percentage_registration(@person)) + end + + should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do + @user.secondary_email = "test_email@com.br" + @user.email = "test_email@net.br" + assert @user.save + end +end diff --git a/src/gov_user/test/unit/private_institution_test.rb b/src/gov_user/test/unit/private_institution_test.rb new file mode 100644 index 0000000..8f01e95 --- /dev/null +++ b/src/gov_user/test/unit/private_institution_test.rb @@ -0,0 +1,34 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class PrivateInstitutionTest < ActiveSupport::TestCase + include PluginTestHelper + def setup + @institution = create_private_institution( + "Simple Private Institution", + "SPI", + "BR", + "DF", + "Gama", + "00.000.000/0001-00" + ) + end + + def teardown + @institution = nil + Institution.destroy_all + end + + should "save without a cnpj" do + @institution.cnpj = nil + + assert @institution.save + end + + should "save without fantasy name" do + @institution.acronym = nil + @institution.community.save + + assert @institution.save + end +end diff --git a/src/gov_user/test/unit/public_institution_test.rb b/src/gov_user/test/unit/public_institution_test.rb new file mode 100644 index 0000000..9f37965 --- /dev/null +++ b/src/gov_user/test/unit/public_institution_test.rb @@ -0,0 +1,68 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class PublicInstitutionTest < ActiveSupport::TestCase + include PluginTestHelper + def setup + @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") + @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") + @juridical_nature = JuridicalNature.create(:name => "Autarquia") + + @institution = create_public_institution( + "Ministerio Publico da Uniao", + "MPU", + "BR", + "DF", + "Gama", + @juridical_nature, + @gov_power, + @gov_sphere, + "11.222.333/4444-55" + ) + end + + def teardown + GovernmentalPower.destroy_all + GovernmentalSphere.destroy_all + JuridicalNature.destroy_all + Institution.destroy_all + @gov_power = nil + @gov_sphere = nil + @juridical_nature = nil + @institution = nil + end + + should "save without a cnpj" do + @institution.cnpj = nil + assert @institution.save + end + + should "save institution without an acronym" do + @institution.acronym = nil + assert @institution.save + end + + should "Not save institution without a governmental_power" do + invalid_msg = "Governmental power can't be blank" + @institution.governmental_power = nil + + assert !@institution.save + assert @institution.errors.full_messages.include? invalid_msg + end + + should "Not save institution without a governmental_sphere" do + invalid_msg = "Governmental sphere can't be blank" + @institution.governmental_sphere = nil + + assert !@institution.save + assert @institution.errors.full_messages.include? invalid_msg + end + + should "not save institution without juridical nature" do + invalid_msg = "Juridical nature can't be blank" + @institution.juridical_nature = nil + + assert !@institution.save + assert @institution.errors.full_messages.include? invalid_msg + end +end diff --git a/src/gov_user/test/unit/user_test.rb b/src/gov_user/test/unit/user_test.rb new file mode 100644 index 0000000..c2b15c6 --- /dev/null +++ b/src/gov_user/test/unit/user_test.rb @@ -0,0 +1,99 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' + +class UserTest < ActiveSupport::TestCase + include PluginTestHelper + + should 'not save user whose both email and secondary email are the same' do + user = fast_create(User) + user.email = "test@email.com" + user.secondary_email = "test@email.com" + + assert !user.save + end + + should 'not save user whose email and secondary email have been taken' do + user1 = create_default_user + user2 = fast_create(User) + + user2.email = "primary@email.com" + user2.secondary_email = "secondary@email.com" + assert !user2.save + end + + should 'not save user whose email has already been used' do + user1 = create_default_user + user2 = fast_create(User) + + user2.email = "primary@email.com" + user2.secondary_email = "noosfero@email.com" + assert !user2.save + end + + should 'not save user whose email has been taken another in users secondary email' do + user1 = create_default_user + user2 = fast_create(User) + + user2.login = "another-login" + user2.email = "secondary@email.com" + user2.secondary_email = "noosfero@email.com" + assert !user2.save + end + + should 'not save user whose secondary email has been taken used in another users email' do + user1 = create_default_user + user2 = fast_create(User) + + user2.login = "another-login" + user2.email = "noosfero@email.com" + user2.secondary_email = "primary@email.com" + assert !user2.save + end + + should 'not save user whose secondary email has already been used in another users secondary email' do + user1 = create_default_user + user2 = fast_create(User) + + user2.login = "another-login" + user2.email = "noosfero@email.com" + user2.secondary_email = "secondary@email.com" + assert !user2.save + end + + should 'not save user whose secondary email is in the wrong format' do + user = fast_create(User) + user.email = "test@email.com" + user.secondary_email = "notarightformat.com" + + assert !user.save + + user.secondary_email = "not@arightformatcom" + + assert !user.save + end + + should 'save more than one user without secondary email' do + user = fast_create(User) + user.email = "test@email.com" + user.secondary_email = "" + user.save + + user2 = fast_create(User) + user2.email = "test2@email.com" + user2.secondary_email = "" + assert user2.save + end + + private + + def create_default_user + user = fast_create(User) + user.login = "a-login" + user.email = "primary@email.com" + user.secondary_email = "secondary@email.com" + user.save + + return user + end + +end diff --git a/src/gov_user/views/gov_user_plugin/_institution.html.erb b/src/gov_user/views/gov_user_plugin/_institution.html.erb new file mode 100644 index 0000000..e2aa5b0 --- /dev/null +++ b/src/gov_user/views/gov_user_plugin/_institution.html.erb @@ -0,0 +1,128 @@ +

    <%= _('New 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") %>

    +
      + <% flash[:errors].each do |key, value| %> + <% key_name = key.to_s.gsub("_", " ") %> + <% if value.length > 0 %> +
    • <%= _("#{key_name.capitalize} #{value.join()}") %>
    • + <% end %> + <% end %> +
    +
    +<% end %> + +
    + +
    + <%= labelled_form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %> + <%= required_fields_message %> + <%= hidden_field_tag "edit_institution_page", false %> + <%= fields_for :institutions do |inst| %> + +
    + + + +
    +
    + + <%= required f.text_field(:name, :class => flash[:error_community_name], :value => params[:community][:name]) %> + <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %> + + +
    + <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %> + <%= inst.text_field(:corporate_name, :value => params[:institutions][:corporate_name], :size => 55) %> +
    +
    + + <%= required select_country(_('Country'), 'community', 'country', {:class => "type-select #{flash[:error_community_country]}", :id => "community_country"}) %> + + +
    + + <%= f.select(:state, @state_options, {:selected => params[:community][:state]}, {:class => flash[:error_community_state]}) %> +
    +
    + + <%= required f.text_field(:city, :class => flash[:error_community_city], :value => params[:community][:city]) %> + + +
    + <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> + <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field", :value => params[:institutions][:cnpj]) %> +
    + + +
    + <%= hidden_field_tag "acronym_translate", _("Acronym") %> + <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %> + <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %> + <%= inst.text_field(:acronym, :value => params[:institutions][:acronym]) %> +
    +
    + + +
    + <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> + <%= inst.select(:governmental_sphere, @governmental_sphere, :selected=>params[:institutions][:governmental_sphere], :class => flash[:error_institution_governmental_sphere])%> +
    +
    + + +
    + <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> + <%= inst.select(:governmental_power, @governmental_power, :selected=>params[:institutions][:governmental_sphere], :class => flash[:error_institution_governmental_power])%> +
    +
    + +
    + <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %> + <%= inst.select(:juridical_nature, @juridical_nature, :selected=>params[:institutions][:juridical_nature], :class => flash[:error_institution_juridical_nature])%> +
    +
    + + +
    + <%= _("SISP?") %> + <% if @show_sisp_field %> + <%= inst.radio_button(:sisp, true, :class => "#{flash[:error_institution_sisp]}" ) %> + <%= inst.label :sisp ,_("Yes"), :value => true %> + <%= inst.radio_button(:sisp, false, :checked=>"checked", :class => "#{flash[:error_institution_sisp]}") %> + <%= inst.label :sisp ,_("No"), :value => false %> + <% else %> + <%= inst.label("sisp", _("No")) %> + <% end %> +
    +
    + + <% if @url_token == "create_institution_admin" %> + <%= submit_button :save, _('Save') %> + <%= button(:cancel, _("Cancel"), {:controller => "admin_panel", :action => 'index'}) %> + <%else%> +
    + <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %> + <%= link_to(_('Cancel'), '#', :id=>"cancel_institution_button", :class=>'button with-text icon-cancel') %> +
    + <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %> + <%end%> + + <% end %> + + <% end %> +
    +<%= hidden_field_tag :loading_message, _("Creating institution") %> diff --git a/src/gov_user/views/gov_user_plugin/create_institution.html.erb b/src/gov_user/views/gov_user_plugin/create_institution.html.erb new file mode 100644 index 0000000..037140f --- /dev/null +++ b/src/gov_user/views/gov_user_plugin/create_institution.html.erb @@ -0,0 +1 @@ +<%= render :partial => "institution" %> diff --git a/src/gov_user/views/gov_user_plugin/create_institution_admin.html.erb b/src/gov_user/views/gov_user_plugin/create_institution_admin.html.erb new file mode 100644 index 0000000..037140f --- /dev/null +++ b/src/gov_user/views/gov_user_plugin/create_institution_admin.html.erb @@ -0,0 +1 @@ +<%= render :partial => "institution" %> diff --git a/src/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb b/src/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb new file mode 100644 index 0000000..7b0f936 --- /dev/null +++ b/src/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb @@ -0,0 +1,114 @@ +

    <%= _('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].blank? %> +
    +

    <%= _("Can`t create new Institution: #{flash[:errors].length} errors") %>

    +
      + <% flash[:errors].each do |error| %> +
    • <%= error %>
    • + <% end %> +
    +
    +<% end %> + +
    + +
    + <%= labelled_form_for :community,:html => { :multipart => true, :id=>"institution_form" } do |f| %> + <%= hidden_field_tag "edit_institution_page", true %> + <%= fields_for :institutions do |inst| %> + +
    + + + +
    +
    + + <%= required f.text_field(:name, :value => @institution.community.name) %> + <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %> + + +
    + <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %> + <%= required inst.text_field(:corporate_name, :value => @institution.corporate_name) %> +
    +
    + + <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}, :selected => @institution.community.country) %> + + +
    + + <%= f.select(:state, @state_list.collect {|state| [state.name, state.name]}, :selected => @institution.community.state) %> +
    +
    + + <%= required f.text_field(:city, :value => @institution.community.city) %> + + + +
    + <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> + <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field", :value => @institution.cnpj) %> +
    +
    + + +
    + <%= hidden_field_tag "acronym_translate", _("Acronym") %> + <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %> + <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %> + <%= inst.text_field(:acronym, :value => @institution.acronym) %> +
    +
    + + +
    + <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> + <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>@institution.governmental_power_id})%> +
    +
    + + +
    + <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> + <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=> @institution.governmental_sphere_id})%> +
    +
    + +
    + <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %> + <%= inst.select(:juridical_nature, [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]}, {:selected=> @institution.juridical_nature_id})%> +
    +
    + + +
    + <%= _("SISP?") %> + <% if @show_sisp_field %> + <%= inst.label("sisp" ,_("Yes")) %> + <%= inst.radio_button(:sisp, true, :checked=>(@institution.sisp ? true : false)) %> + <%= inst.label("sisp" ,_("No")) %> + <%= inst.radio_button(:sisp, false, :checked=>(@institution.sisp ? false : true)) %> + <% else %> + <%= inst.label("sisp", _("No")) %> + <% end %> +
    +
    + + <%= submit_button :save, _('Save') %> + <% end %> +<% end %> + diff --git a/src/gov_user/views/incomplete_registration.html.erb b/src/gov_user/views/incomplete_registration.html.erb new file mode 100644 index 0000000..d1dceba --- /dev/null +++ b/src/gov_user/views/incomplete_registration.html.erb @@ -0,0 +1,11 @@ +
    +
    +
    <%= _("Complete Profile")+": #{@percentege}%" %>
    + +
    + <%= link_to _("Complete your profile"), "#{Noosfero.root}/myprofile/#{@person.identifier}/profile_editor/edit" %> | + <%= link_to _("Hide"), "#", :class=>"hide-incomplete-percentage" %> +
    +
    +
    +
    diff --git a/src/gov_user/views/organization_ratings_extra_fields_show_institution.html.erb b/src/gov_user/views/organization_ratings_extra_fields_show_institution.html.erb new file mode 100644 index 0000000..7cc4709 --- /dev/null +++ b/src/gov_user/views/organization_ratings_extra_fields_show_institution.html.erb @@ -0,0 +1,8 @@ +<% if user_rating.institution %> +
    +
    + Institution : <%= user_rating.institution.name unless user_rating.institution.nil? %> +
    +
    +<% end %> + diff --git a/src/gov_user/views/person_editor_extras.html.erb b/src/gov_user/views/person_editor_extras.html.erb new file mode 100644 index 0000000..a3a11fc --- /dev/null +++ b/src/gov_user/views/person_editor_extras.html.erb @@ -0,0 +1,42 @@ +
    + <%= label_tag "user[secondary_email]", _('Secondary e-mail')+":", :class=>"formlabel" %> + +
    + <%= text_field_tag "user[secondary_email]", context.profile.user.secondary_email %> +
    +
    + + +
    + <%= label_tag "user[institution_ids]", _('Institutions'), :class=>"formlabel" %> + +
    + <%= text_field_tag(:institution, "", :id=>"input_institution") %> + + <% context.profile.user.institutions.each do |institution| %> + <%= hidden_field_tag("user[institution_ids][]", institution.id, :class => 'user_institutions') %> + <% end %> +
    + + <%= content_tag(:div, _("No institution found"), :id=>"institution_empty_ajax_message", :class=>"errorExplanation hide-field") %> + <%= link_to(_("Add new institution"), "#", :class=>'button with-text icon-add', :id => 'add_new_institution') %> + <%= link_to(_("Create new institution"), "#", :id=>"create_institution_link", :class=>'button with-text icon-add') %> + <%= content_tag(:div, "", :id=>"institution_dialog") %> + + <%= hidden_field_tag("user[institution_ids][]", "", :class => 'user_institutions') %> + <%= hidden_field_tag("institution_selected", "") %> + +
      + <% context.profile.user.institutions.each do |institution| %> +
    • + <%= institution.name %> + <%= link_to("", "#", :class => "button without-text icon-remove remove-institution") %> +
    • + <% end %> +
    +
    + +<%= 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/src/gov_user/views/profile/_institution_tab.html.erb b/src/gov_user/views/profile/_institution_tab.html.erb new file mode 100644 index 0000000..6c2f7fb --- /dev/null +++ b/src/gov_user/views/profile/_institution_tab.html.erb @@ -0,0 +1,21 @@ + + + + + + <%= display_mpog_field(_('Type:'), profile.institution, :type, true) %> + <%= display_mpog_field(_('CNPJ:'), profile.institution, :cnpj, true) %> + <%= display_mpog_field(_('Last modification:'), profile.institution, :date_modification, true) %> + <%= display_mpog_field(_('Country:'), profile.institution.community, :country, true) %> + <%= display_mpog_field(_('State:'), profile.institution.community, :state, true) %> + <%= display_mpog_field(_('City:'), profile.institution.community, :city, true) %> + <% if profile.institution.type == "PrivateInstitution"%> + <%= display_mpog_field(_('Fantasy Name:'), profile.institution, :acronym, true) %> + <% else %> + <%= display_mpog_field(_('Acronym:'), profile.institution, :acronym, true) %> + <%= display_mpog_field(_('Governmental Power:'), profile.institution.governmental_power, :name, true) %> + <%= display_mpog_field(_('Governmental Sphere:'), profile.institution.governmental_sphere, :name, true) %> + <%= display_mpog_field(_('Juridical Nature:'), profile.institution.juridical_nature, :name, true) %> + <%= content_tag('tr', content_tag('td', _("SISP:")) + content_tag('td', profile.institution.sisp ? _("Yes") : _("No"))) %> + <% end %> +
    <%= _('Institution Information')%>
    diff --git a/src/gov_user/views/profile/_profile_tab.html.erb b/src/gov_user/views/profile/_profile_tab.html.erb new file mode 100644 index 0000000..4fc67b0 --- /dev/null +++ b/src/gov_user/views/profile/_profile_tab.html.erb @@ -0,0 +1,3 @@ + + <%= display_mpog_profile_information %> +
    diff --git a/src/gov_user/views/ratings_extra_field.html.erb b/src/gov_user/views/ratings_extra_field.html.erb new file mode 100644 index 0000000..6f835d1 --- /dev/null +++ b/src/gov_user/views/ratings_extra_field.html.erb @@ -0,0 +1,10 @@ +
    + <%= label_tag "input_institution", _("Organization name or Enterprise name")%> + + + + <%= content_tag(:div, _("No institution found"), + :id=>"institution_empty_ajax_message", + :class=>"errorExplanation hide-field") %> + <%= hidden_field_tag "organization_rating[institution_id]", "", id: "institution_selected" %> +
    diff --git a/src/gov_user/views/search/institutions.html.erb b/src/gov_user/views/search/institutions.html.erb new file mode 100644 index 0000000..1b33ed2 --- /dev/null +++ b/src/gov_user/views/search/institutions.html.erb @@ -0,0 +1,16 @@ +<%= 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/test/functional/gov_user_plugin_controller_test.rb b/test/functional/gov_user_plugin_controller_test.rb deleted file mode 100644 index 48b4fc4..0000000 --- a/test/functional/gov_user_plugin_controller_test.rb +++ /dev/null @@ -1,236 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/institution_test_helper' -require File.dirname(__FILE__) + '/../../controllers/gov_user_plugin_controller' - -class GovUserPluginController; def rescue_action(e) raise e end; end -class GovUserPluginControllerTest < ActionController::TestCase - - - def setup - @admin = create_user("adminuser").person - @admin.stubs(:has_permission?).returns("true") - @controller.stubs(:current_user).returns(@admin.user) - - @environment = Environment.default - @environment.enabled_plugins = ['SoftwareCommunitiesPlugin'] - @environment.add_admin(@admin) - @environment.save - - @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") - @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") - @juridical_nature = JuridicalNature.create(:name => "Autarquia") - @response = ActionController::TestResponse.new - - @institution_list = [] - @institution_list << InstitutionTestHelper.create_public_institution( - "Ministerio Publico da Uniao", - "MPU", - "BR", - "DF", - "Gama", - @juridical_nature, - @gov_power, - @gov_sphere, - "12.345.678/9012-45" - ) - @institution_list << InstitutionTestHelper.create_public_institution( - "Tribunal Regional da Uniao", - "TRU", - "BR", - "DF", - "Brasilia", - @juridical_nature, - @gov_power, - @gov_sphere, - "12.345.678/9012-90" - ) - - end - - should "Search for institution with acronym" do - xhr :get, :get_institutions, :query=>"TRU" - - json_response = ActiveSupport::JSON.decode(@response.body) - - assert_equal "Tribunal Regional da Uniao", json_response[0]["value"] - end - - should "Search for institution with name" do - xhr :get, :get_institutions, :query=>"Minis" - - json_response = ActiveSupport::JSON.decode(@response.body) - - assert_equal "Ministerio Publico da Uniao", json_response[0]["value"] - end - - should "search with name or acronym and return a list with institutions" do - xhr :get, :get_institutions, :query=>"uni" - - json_response = ActiveSupport::JSON.decode(@response.body) - - assert_equal "Ministerio Publico da Uniao", json_response[0]["value"] - assert_equal "Tribunal Regional da Uniao", json_response[1]["value"] - end - - should "method create_institution return the html for modal" do - @controller.stubs(:current_user).returns(@admin.user) - xhr :get, :create_institution - assert_template 'create_institution' - end - - should "create new institution with ajax without acronym" do - @controller.stubs(:verify_recaptcha).returns(true) - - fields = InstitutionTestHelper.generate_form_fields( - "foo bar", - "BR", - "DF", - "Brasilia", - "12.234.567/8900-10", - "PublicInstitution" - ) - fields[:institutions][:governmental_power] = @gov_power.id - fields[:institutions][:governmental_sphere] = @gov_sphere.id - fields[:institutions][:juridical_nature] = @juridical_nature.id - - xhr :get, :new_institution, fields - - json_response = ActiveSupport::JSON.decode(@response.body) - - assert json_response["success"] - end - - should "create a institution without cnpj" do - @controller.stubs(:verify_recaptcha).returns(true) - - fields = InstitutionTestHelper.generate_form_fields( - "Some Private Institution", - "BR", - "DF", - "Brasilia", - "", - "PrivateInstitution" - ) - fields[:institutions][:acronym] = "SPI" - - xhr :get, :new_institution, fields - - json_response = ActiveSupport::JSON.decode(@response.body) - - assert json_response["success"] - end - - should "verify if institution name already exists" do - xhr :get, :institution_already_exists, :name=>"Ministerio Publico da Uniao" - assert_equal "true", @response.body - - xhr :get, :institution_already_exists, :name=>"Another name here" - assert_equal "false", @response.body - end - - should "hide registration incomplete message" do - xhr :get, :hide_registration_incomplete_percentage, :hide=>true - assert_equal "true", @response.body - end - - should "not hide registration incomplete message" do - xhr :get, :hide_registration_incomplete_percentage, :hide=>false - assert_equal "false", @response.body - end - - should "Create new institution with method post" do - @controller.stubs(:verify_recaptcha).returns(true) - - fields = InstitutionTestHelper.generate_form_fields( - "Some Private Institution", - "BR", - "DF", - "Brasilia", - "12.345.567/8900-10", - "PrivateInstitution" - ) - fields[:institutions][:acronym] = "SPI" - - post :new_institution, fields - - assert_redirected_to(controller: "admin_panel", action: "index") - end - - should "not create new institution with method post without cnpj" do - @controller.stubs(:verify_recaptcha).returns(true) - - fields = InstitutionTestHelper.generate_form_fields( - "Some Private Institution", - "BR", - "DF", - "Brasilia", - "56.366.790/0001-88", - "PrivateInstitution" - ) - - post :new_institution, fields - - assert_redirected_to(controller: "admin_panel", action: "index") - end - - should "Create foreign institution without city, state and cnpj by post" do - @controller.stubs(:verify_recaptcha).returns(true) - - fields = InstitutionTestHelper.generate_form_fields( - "Foreign institution", - "AZ", - "", - "", - "", - "PrivateInstitution" - ) - fields[:institutions][:acronym] = "FI" - - post :new_institution, fields - - assert_redirected_to(controller: "admin_panel", action: "index") - end - - should "Create foreign institution without city, state and cnpj by ajax" do - @controller.stubs(:verify_recaptcha).returns(true) - - fields = InstitutionTestHelper.generate_form_fields( - "Foreign institution", - "AZ", - "", - "", - "", - "PrivateInstitution" - ) - fields[:institutions][:acronym] = "FI" - - xhr :post, :new_institution, fields - - json_response = ActiveSupport::JSON.decode(@response.body) - - assert json_response["success"] - end - - should "add environment admins to institution when created via admin panel" do - @controller.stubs(:verify_recaptcha).returns(true) - admin2 = create_user("another_admin").person - admin2.stubs(:has_permission?).returns("true") - @environment.add_admin(admin2) - @environment.save - - fields = InstitutionTestHelper.generate_form_fields( - "Private Institution", - "BR", - "DF", - "Brasilia", - "12.323.557/8900-10", - "PrivateInstitution" - ) - fields[:institutions][:acronym] = "PI" - fields[:edit_institution_page] = false - post :new_institution, fields - - assert(Institution.last.community.admins.include?(admin2) ) - end - -end diff --git a/test/functional/gov_user_plugin_myprofile_controller.rb b/test/functional/gov_user_plugin_myprofile_controller.rb deleted file mode 100644 index 61c48b1..0000000 --- a/test/functional/gov_user_plugin_myprofile_controller.rb +++ /dev/null @@ -1,105 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/institution_test_helper' -require( -File.dirname(__FILE__) + -'/../../controllers/gov_user_plugin_myprofile_controller' -) - -class GovUserPluginMyprofileController; def rescue_action(e) raise e end; -end - -class GovUserPluginMyprofileControllerTest < ActionController::TestCase - def setup - @controller = GovUserPluginMyprofileController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @person = create_user('person').person - @offer = create_user('Angela Silva') - @offer_1 = create_user('Ana de Souza') - @offer_2 = create_user('Angelo Roberto') - - login_as(@person.user_login) - @environment = Environment.default - @environment.enable_plugin('GovUserPlugin') - @environment.save! - end - should "user edit its community institution" do - govPower = GovernmentalPower.create(:name=>"Some Gov Power") - govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") - juridical_nature = JuridicalNature.create(:name => "Autarquia") - - institution = InstitutionTestHelper.create_public_institution( - "Ministerio Publico da Uniao", - "MPU", - "BR", - "DF", - "Gama", - juridical_nature, - govPower, - govSphere, - "12.345.678/9012-45" - ) - - identifier = institution.community.identifier - - fields = InstitutionTestHelper.generate_form_fields( - "institution new name", - "BR", - "DF", - "Gama", - "12.345.678/9012-45", - "PrivateInstitution" - ) - - post( - :edit_institution, - :profile=>institution.community.identifier, - :community=>fields[:community], - :institutions=>fields[:institutions] - ) - - institution = Community[identifier].institution - assert_not_equal "Ministerio Publico da Uniao", institution.community.name - end - - should "not user edit its community institution with wrong values" do - govPower = GovernmentalPower.create(:name=>"Some Gov Power") - govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") - juridical_nature = JuridicalNature.create(:name => "Autarquia") - - institution = InstitutionTestHelper.create_public_institution( - "Ministerio Publico da Uniao", - "MPU", - "BR", - "DF", - "Gama", - juridical_nature, - govPower, - govSphere, - "12.345.678/9012-45" - ) - - identifier = institution.community.identifier - - fields = InstitutionTestHelper.generate_form_fields( - "", - "BR", - "DF", - "Gama", - "6465465465", - "PrivateInstitution" - ) - - post( - :edit_institution, - :profile=>institution.community.identifier, - :community=>fields[:community], - :institutions=>fields[:institutions] - ) - - institution = Community[identifier].institution - assert_equal "Ministerio Publico da Uniao", institution.community.name - assert_equal "12.345.678/9012-45", institution.cnpj - end - -end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb deleted file mode 100644 index 52de533..0000000 --- a/test/functional/profile_editor_controller_test.rb +++ /dev/null @@ -1,112 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/institution_test_helper' -require( -File.dirname(__FILE__) + -'/../../../../app/controllers/my_profile/profile_editor_controller' -) - -class ProfileEditorController; def rescue_action(e) raise e end; end - -class ProfileEditorControllerTest < ActionController::TestCase - - def setup - @controller = ProfileEditorController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - @profile = create_user('default_user').person - - Environment.default.affiliate( - @profile, - [Environment::Roles.admin(Environment.default.id)] + - Profile::Roles.all_roles(Environment.default.id) - ) - - @environment = Environment.default - @environment.enabled_plugins = ['GovUserPlugin'] - admin = create_user("adminuser").person - admin.stubs(:has_permission?).returns("true") - login_as('adminuser') - @environment.add_admin(admin) - @environment.save - - @govPower = GovernmentalPower.create(:name=>"Some Gov Power") - @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") - @juridical_nature = JuridicalNature.create(:name => "Autarquia") - - @institution_list = [] - @institution_list << InstitutionTestHelper.create_public_institution( - "Ministerio Publico da Uniao", - "MPU", - "BR", - "DF", - "Gama", - @juridical_nature, - @govPower, - @govSphere, - "12.345.678/9012-45" - ) - - @institution_list << InstitutionTestHelper.create_public_institution( - "Tribunal Regional da Uniao", - "TRU", - "BR", - "DF", - "Brasilia", - @juridical_nature, - @govPower, - @govSphere, - "12.345.678/9012-90" - ) - end - - should "add new institution for user into edit profile" do - user = create_basic_user - - params_user = Hash.new - params_user[:institution_ids] = [] - - @institution_list.each do |institution| - params_user[:institution_ids] << institution.id - end - - post :edit, :profile => User.last.person.identifier, :user => params_user - - assert_equal @institution_list.count, User.last.institutions.count - end - - should "remove institutions for user into edit profile" do - user = create_basic_user - - @institution_list.each do |institution| - user.institutions << institution - end - user.save! - - params_user = Hash.new - params_user[:institution_ids] = [] - - assert_equal @institution_list.count, User.last.institutions.count - - post :edit, :profile => User.last.person.identifier, :user => params_user - - assert_equal 0, User.last.institutions.count - end - - protected - - def create_basic_user - user = fast_create(User) - user.person = fast_create(Person) - user.person.user = user - user.save! - user.person.save! - user - end - - def create_community name - community = fast_create(Community) - community.name = name - community.save - community - end -end diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb deleted file mode 100644 index ab45f06..0000000 --- a/test/functional/search_controller_test.rb +++ /dev/null @@ -1,57 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' -require( -File.dirname(__FILE__) + -'/../../../../app/controllers/public/search_controller' -) - -class SearchController; def rescue_action(e) raise e end; end - -class SearchControllerTest < ActionController::TestCase - include PluginTestHelper - - def setup - @environment = Environment.default - @environment.enabled_plugins = ['SoftwareCommunitiesPlugin'] - @environment.save - - @controller = SearchController.new - @request = ActionController::TestRequest.new - @request.stubs(:ssl?).returns(:false) - @response = ActionController::TestResponse.new - end - - should "communities searches don't have institution" do - community = create_community("New Community") - institution = create_private_institution( - "New Private Institution", - "NPI" , - "Brazil", - "DF", - "Gama", - "66.544.314/0001-63" - ) - - get :communities, :query => "New" - - assert_includes assigns(:searches)[:communities][:results], community - assert_not_includes assigns(:searches)[:communities][:results], institution.community - end - - should "institutions_search don't have community" do - community = create_community("New Community") - institution = create_private_institution( - "New Private Institution", - "NPI" , - "Brazil", - "DF", - "Gama", - "66.544.314/0001-63" - ) - - get :institutions, :query => "New" - - assert_includes assigns(:searches)[:institutions][:results], institution.community - assert_not_includes assigns(:searches)[:institutions][:results], community - end -end diff --git a/test/helpers/institution_test_helper.rb b/test/helpers/institution_test_helper.rb deleted file mode 100644 index 1f4df2f..0000000 --- a/test/helpers/institution_test_helper.rb +++ /dev/null @@ -1,59 +0,0 @@ -module InstitutionTestHelper - - def self.generate_form_fields name, country, state, city, cnpj, type - fields = { - :community => { - :name => name, - :country => country, - :state => state, - :city => city - }, - :institutions => { - :cnpj=> cnpj, - :type => type, - :acronym => "", - :governmental_power => "", - :governmental_sphere => "", - :juridical_nature => "", - :corporate_name => "coporate default" - } - } - fields - end - - def self.create_public_institution name, acronym, country, state, city, juridical_nature, gov_p, gov_s, cnpj - institution = PublicInstitution.new - institution.community = institution_community(name, country, state, city) - institution.name = name - institution.juridical_nature = juridical_nature - institution.acronym = acronym - institution.governmental_power = gov_p - institution.governmental_sphere = gov_s - institution.cnpj = cnpj - institution.corporate_name = "corporate default" - institution.save - institution - end - - def self.create_private_institution name, acronym, country, state, city, cnpj - institution = PrivateInstitution.new - institution.community = institution_community(name, country, state, city) - institution.name = name - institution.acronym = acronym - institution.cnpj = cnpj - institution.corporate_name = "corporate default" - institution.save - - institution - end - - def self.institution_community name, country, state, city - institution_community = Community::new - institution_community.name = name - institution_community.country = country - institution_community.state = state - institution_community.city = city - institution_community.save - institution_community - end -end \ No newline at end of file diff --git a/test/helpers/plugin_test_helper.rb b/test/helpers/plugin_test_helper.rb deleted file mode 100644 index 741cb2f..0000000 --- a/test/helpers/plugin_test_helper.rb +++ /dev/null @@ -1,77 +0,0 @@ -require File.dirname(__FILE__) + '/../helpers/institution_test_helper' - -module PluginTestHelper - - def create_person name, email, password, password_confirmation, secondary_email, state="state", city="city" - user = create_user( - name.to_slug, - email, - password, - password_confirmation, - secondary_email - ) - person = Person::new - - user.person = person - person.user = user - - person.name = name - person.identifier = name.to_slug - person.state = state - person.city = city - - user.save - person.save - - person - end - - def create_user login, email, password, password_confirmation, secondary_email - user = User.new - - user.login = login - user.email = email - user.password = password - user.password_confirmation = password_confirmation - user.secondary_email = secondary_email - - user - end - - def create_public_institution *params - InstitutionTestHelper.create_public_institution *params - end - - def create_community name - community = fast_create(Community) - community.name = name - community.save - community - end - - - def create_private_institution name, acronym, country, state, city, cnpj - InstitutionTestHelper.create_private_institution( - name, - acronym, - country, - state, - city, - cnpj - ) - end - - def create_public_institution *params - InstitutionTestHelper.create_public_institution *params - end - - def create_community_institution name, country, state, city - community = fast_create(Community) - community.name = name - community.country = country - community.state = state - community.city = city - community.save - community - end -end diff --git a/test/unit/gov_user_person_test.rb b/test/unit/gov_user_person_test.rb deleted file mode 100644 index 0c58478..0000000 --- a/test/unit/gov_user_person_test.rb +++ /dev/null @@ -1,58 +0,0 @@ -# encoding: utf-8 - -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase - include PluginTestHelper - - def setup - @plugin = GovUserPlugin.new - - @user = fast_create(User) - @person = create_person( - "My Name", - "user@email.com", - "123456", - "123456", - "user2@email.com", - "Any State", - "Some City" - ) - end - - def teardown - @plugin = nil - end - - should 'be a noosfero plugin' do - assert_kind_of Noosfero::Plugin, @plugin - end - - should 'save person with a valid full name' do - p = Person::new :name=>"S1mpl3 0f N4m3", :identifier=>"simple-name" - p.user = fast_create(:user) - - assert_equal true, p.save - end - - should 'save person with a valid full name with accents' do - name = 'Jônatàs dâ Sîlvã Jösé' - identifier = "jonatas-jose-da-silva" - p = Person::new :name=>name, :identifier=>identifier - p.user = fast_create(:user) - - assert_equal true, p.save - end - - should 'not save person whose name has not capital letter' do - p = Person::new :name=>"simple name" - assert !p.save, _("Name Should begin with a capital letter and no special characters") - end - - should 'not save person whose name has special characters' do - p = Person::new :name=>"Simple N@me" - - assert !p.save , _("Name Should begin with a capital letter and no special characters") - end -end diff --git a/test/unit/governmental_power_test.rb b/test/unit/governmental_power_test.rb deleted file mode 100644 index 5f777e6..0000000 --- a/test/unit/governmental_power_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/institution_test_helper' - -class GovernmentalPowerTest < ActiveSupport::TestCase - - def setup - @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") - @juridical_nature = JuridicalNature.create(:name => "Autarquia") - end - - def teardown - Institution.destroy_all - end - - should "get public institutions" do - inst_name = "Ministerio Publico da Uniao" - inst_cnpj = "12.345.678/9012-45" - gov_power = GovernmentalPower.create(:name=>"Some gov power") - InstitutionTestHelper.create_public_institution( - inst_name, - "MPU", - "BR", - "DF", - "Gama", - @juridical_nature, - gov_power, - @gov_sphere, - inst_cnpj - ) - - assert_equal gov_power.public_institutions.count, PublicInstitution.count - end -end \ No newline at end of file diff --git a/test/unit/institution_test.rb b/test/unit/institution_test.rb deleted file mode 100644 index c4c77e5..0000000 --- a/test/unit/institution_test.rb +++ /dev/null @@ -1,63 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class InstitutionTest < ActiveSupport::TestCase - include PluginTestHelper - def setup - @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") - @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") - @juridical_nature = JuridicalNature.create(:name => "Autarquia") - - @institution = create_public_institution( - "Ministerio Publico da Uniao", - "MPU", - "BR", - "DF", - "Gama", - @juridical_nature, - @gov_power, - @gov_sphere, - "11.222.333/4444-55" - ) - end - - def teardown - GovernmentalPower.destroy_all - GovernmentalSphere.destroy_all - JuridicalNature.destroy_all - @institution = nil - end - should "not save institutions without name" do - @institution.name = nil - assert_equal false, @institution.save - assert_equal true, @institution.errors.full_messages.include?("Name can't be blank") - end - - should "not save if institution has invalid type" do - invalid_msg = "Type invalid, only public and private institutions are allowed." - @institution.type = "Other type" - assert_equal false, @institution.save - assert_equal true, @institution.errors.full_messages.include?(invalid_msg) - end - - should "not save without country" do - @institution.community.country = nil - assert_equal false, @institution.save - assert_equal true, @institution.errors.full_messages.include?("Country can't be blank") - end - - should "not save without state" do - @institution.community.state = nil - - assert_equal false, @institution.save - assert_equal true, @institution.errors.full_messages.include?("State can't be blank") - end - - should "not save without city" do - @institution.community.city = nil - @institution.community.state = "DF" - - assert_equal false, @institution.save - assert_equal true, @institution.errors.full_messages.include?("City can't be blank") - end -end diff --git a/test/unit/institutions_block_test.rb b/test/unit/institutions_block_test.rb deleted file mode 100644 index bcab723..0000000 --- a/test/unit/institutions_block_test.rb +++ /dev/null @@ -1,51 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class InstitutionsBlockTest < ActiveSupport::TestCase - include PluginTestHelper - should 'inherit from Block' do - assert_kind_of Block, InstitutionsBlock.new - end - - should 'declare its default title' do - InstitutionsBlock.any_instance.stubs(:profile_count).returns(0) - assert_not_equal Block.new.default_title, InstitutionsBlock.new.default_title - end - - should 'describe itself' do - assert_not_equal Block.description, InstitutionsBlock.description - end - - should 'give empty footer on unsupported owner type' do - block = InstitutionsBlock.new - block.expects(:owner).returns(1) - assert_equal '', block.footer - end - - should 'list institutions' do - user = create_person("Jose_Augusto", - "jose_augusto@email.com", - "aaaaaaa", - "aaaaaaa", - 'jose@secondary.com', - "DF", - "Gama" - ) - - institution = create_private_institution( - "inst name", - "IN", - "country", - "state", - "city", - "00.111.222/3333-44" - ) - institution.community.add_member(user) - - block = InstitutionsBlock.new - block.expects(:owner).at_least_once.returns(user) - - assert_equivalent [institution.community], block.profiles - end - -end diff --git a/test/unit/juridical_nature_test.rb b/test/unit/juridical_nature_test.rb deleted file mode 100644 index 80d34c6..0000000 --- a/test/unit/juridical_nature_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class JuridicalNatureTest < ActiveSupport::TestCase - - include PluginTestHelper - - def setup - @govPower = GovernmentalPower.create(:name=>"Some Gov Power") - @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") - end - - def teardown - Institution.destroy_all - end - - should "get public institutions" do - juridical_nature = JuridicalNature.create(:name => "Autarquia") - create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", juridical_nature, @govPower, @govSphere, "22.333.444/5555-66") - create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", juridical_nature, @govPower, @govSphere, "22.333.444/5555-77") - assert juridical_nature.public_institutions.count == PublicInstitution.count - end -end diff --git a/test/unit/organization_rating_test.rb b/test/unit/organization_rating_test.rb deleted file mode 100644 index 748355f..0000000 --- a/test/unit/organization_rating_test.rb +++ /dev/null @@ -1,44 +0,0 @@ -require File.expand_path(File.dirname(__FILE__)) + '/../../../../test/test_helper' -require File.expand_path(File.dirname(__FILE__)) + '/../helpers/plugin_test_helper' - -class OrganizationRatingTest < ActiveSupport::TestCase - include PluginTestHelper - - def setup - @environment = Environment.default - @environment.enabled_plugins = ['SoftwareCommunitiesPlugin'] - @environment.save - end - - should "validate institution if there is an institution_id" do - person = fast_create(Person) - community = fast_create(Community) - private_institution = build_private_institution "huehue", "hue", "11.222.333/4444-55" - - community_rating = OrganizationRating.new(:person => person, :value => 3, :organization => community, :institution => private_institution) - assert_equal false, community_rating.valid? - - assert_equal true, community_rating.errors[:institution].include?("not found") - - private_institution.save - community_rating.institution = private_institution - - assert_equal true, community_rating.valid? - assert_equal false, community_rating.errors[:institution].include?("not found") - end - - private - - def build_private_institution name, corporate_name, cnpj, country="AR" - community = Community.new :name => name - community.country = country - - institution = PrivateInstitution.new :name=> name - institution.corporate_name = corporate_name - institution.cnpj = cnpj - institution.community = community - - institution - end -end - diff --git a/test/unit/person_test.rb b/test/unit/person_test.rb deleted file mode 100644 index dd6c628..0000000 --- a/test/unit/person_test.rb +++ /dev/null @@ -1,43 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase - include PluginTestHelper - def setup - @plugin = GovUserPlugin.new - - @user = fast_create(User) - @person = create_person( - "My Name", - "user@email.com", - "123456", - "123456", - "user@secondaryemail.com", - "Any State", - "Some City" - ) - end - - should 'calculate the percentege of person incomplete fields' do - @person.cell_phone = "76888919" - @person.contact_phone = "987654321" - - assert_equal(67, @plugin.calc_percentage_registration(@person)) - - @person.comercial_phone = "11223344" - @person.country = "I dont know" - @person.state = "I dont know" - @person.city = "I dont know" - @person.organization_website = "www.whatever.com" - @person.image = Image::new :uploaded_data=>fixture_file_upload('/files/rails.png', 'image/png') - @person.save - - assert_equal(100, @plugin.calc_percentage_registration(@person)) - end - - should 'return true when the email has not gov.br,jus.br,leg.br or mp.br' do - @user.secondary_email = "test_email@com.br" - @user.email = "test_email@net.br" - assert @user.save - end -end diff --git a/test/unit/private_institution_test.rb b/test/unit/private_institution_test.rb deleted file mode 100644 index 8f01e95..0000000 --- a/test/unit/private_institution_test.rb +++ /dev/null @@ -1,34 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class PrivateInstitutionTest < ActiveSupport::TestCase - include PluginTestHelper - def setup - @institution = create_private_institution( - "Simple Private Institution", - "SPI", - "BR", - "DF", - "Gama", - "00.000.000/0001-00" - ) - end - - def teardown - @institution = nil - Institution.destroy_all - end - - should "save without a cnpj" do - @institution.cnpj = nil - - assert @institution.save - end - - should "save without fantasy name" do - @institution.acronym = nil - @institution.community.save - - assert @institution.save - end -end diff --git a/test/unit/public_institution_test.rb b/test/unit/public_institution_test.rb deleted file mode 100644 index 9f37965..0000000 --- a/test/unit/public_institution_test.rb +++ /dev/null @@ -1,68 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class PublicInstitutionTest < ActiveSupport::TestCase - include PluginTestHelper - def setup - @gov_power = GovernmentalPower.create(:name=>"Some Gov Power") - @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere") - @juridical_nature = JuridicalNature.create(:name => "Autarquia") - - @institution = create_public_institution( - "Ministerio Publico da Uniao", - "MPU", - "BR", - "DF", - "Gama", - @juridical_nature, - @gov_power, - @gov_sphere, - "11.222.333/4444-55" - ) - end - - def teardown - GovernmentalPower.destroy_all - GovernmentalSphere.destroy_all - JuridicalNature.destroy_all - Institution.destroy_all - @gov_power = nil - @gov_sphere = nil - @juridical_nature = nil - @institution = nil - end - - should "save without a cnpj" do - @institution.cnpj = nil - assert @institution.save - end - - should "save institution without an acronym" do - @institution.acronym = nil - assert @institution.save - end - - should "Not save institution without a governmental_power" do - invalid_msg = "Governmental power can't be blank" - @institution.governmental_power = nil - - assert !@institution.save - assert @institution.errors.full_messages.include? invalid_msg - end - - should "Not save institution without a governmental_sphere" do - invalid_msg = "Governmental sphere can't be blank" - @institution.governmental_sphere = nil - - assert !@institution.save - assert @institution.errors.full_messages.include? invalid_msg - end - - should "not save institution without juridical nature" do - invalid_msg = "Juridical nature can't be blank" - @institution.juridical_nature = nil - - assert !@institution.save - assert @institution.errors.full_messages.include? invalid_msg - end -end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb deleted file mode 100644 index c2b15c6..0000000 --- a/test/unit/user_test.rb +++ /dev/null @@ -1,99 +0,0 @@ -require File.dirname(__FILE__) + '/../../../../test/test_helper' -require File.dirname(__FILE__) + '/../helpers/plugin_test_helper' - -class UserTest < ActiveSupport::TestCase - include PluginTestHelper - - should 'not save user whose both email and secondary email are the same' do - user = fast_create(User) - user.email = "test@email.com" - user.secondary_email = "test@email.com" - - assert !user.save - end - - should 'not save user whose email and secondary email have been taken' do - user1 = create_default_user - user2 = fast_create(User) - - user2.email = "primary@email.com" - user2.secondary_email = "secondary@email.com" - assert !user2.save - end - - should 'not save user whose email has already been used' do - user1 = create_default_user - user2 = fast_create(User) - - user2.email = "primary@email.com" - user2.secondary_email = "noosfero@email.com" - assert !user2.save - end - - should 'not save user whose email has been taken another in users secondary email' do - user1 = create_default_user - user2 = fast_create(User) - - user2.login = "another-login" - user2.email = "secondary@email.com" - user2.secondary_email = "noosfero@email.com" - assert !user2.save - end - - should 'not save user whose secondary email has been taken used in another users email' do - user1 = create_default_user - user2 = fast_create(User) - - user2.login = "another-login" - user2.email = "noosfero@email.com" - user2.secondary_email = "primary@email.com" - assert !user2.save - end - - should 'not save user whose secondary email has already been used in another users secondary email' do - user1 = create_default_user - user2 = fast_create(User) - - user2.login = "another-login" - user2.email = "noosfero@email.com" - user2.secondary_email = "secondary@email.com" - assert !user2.save - end - - should 'not save user whose secondary email is in the wrong format' do - user = fast_create(User) - user.email = "test@email.com" - user.secondary_email = "notarightformat.com" - - assert !user.save - - user.secondary_email = "not@arightformatcom" - - assert !user.save - end - - should 'save more than one user without secondary email' do - user = fast_create(User) - user.email = "test@email.com" - user.secondary_email = "" - user.save - - user2 = fast_create(User) - user2.email = "test2@email.com" - user2.secondary_email = "" - assert user2.save - end - - private - - def create_default_user - user = fast_create(User) - user.login = "a-login" - user.email = "primary@email.com" - user.secondary_email = "secondary@email.com" - user.save - - return user - end - -end diff --git a/views/gov_user_plugin/_institution.html.erb b/views/gov_user_plugin/_institution.html.erb deleted file mode 100644 index e2aa5b0..0000000 --- a/views/gov_user_plugin/_institution.html.erb +++ /dev/null @@ -1,128 +0,0 @@ -

    <%= _('New 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") %>

    -
      - <% flash[:errors].each do |key, value| %> - <% key_name = key.to_s.gsub("_", " ") %> - <% if value.length > 0 %> -
    • <%= _("#{key_name.capitalize} #{value.join()}") %>
    • - <% end %> - <% end %> -
    -
    -<% end %> - -
    - -
    - <%= labelled_form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %> - <%= required_fields_message %> - <%= hidden_field_tag "edit_institution_page", false %> - <%= fields_for :institutions do |inst| %> - -
    - - - -
    -
    - - <%= required f.text_field(:name, :class => flash[:error_community_name], :value => params[:community][:name]) %> - <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %> - - -
    - <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %> - <%= inst.text_field(:corporate_name, :value => params[:institutions][:corporate_name], :size => 55) %> -
    -
    - - <%= required select_country(_('Country'), 'community', 'country', {:class => "type-select #{flash[:error_community_country]}", :id => "community_country"}) %> - - -
    - - <%= f.select(:state, @state_options, {:selected => params[:community][:state]}, {:class => flash[:error_community_state]}) %> -
    -
    - - <%= required f.text_field(:city, :class => flash[:error_community_city], :value => params[:community][:city]) %> - - -
    - <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> - <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field", :value => params[:institutions][:cnpj]) %> -
    - - -
    - <%= hidden_field_tag "acronym_translate", _("Acronym") %> - <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %> - <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %> - <%= inst.text_field(:acronym, :value => params[:institutions][:acronym]) %> -
    -
    - - -
    - <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> - <%= inst.select(:governmental_sphere, @governmental_sphere, :selected=>params[:institutions][:governmental_sphere], :class => flash[:error_institution_governmental_sphere])%> -
    -
    - - -
    - <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> - <%= inst.select(:governmental_power, @governmental_power, :selected=>params[:institutions][:governmental_sphere], :class => flash[:error_institution_governmental_power])%> -
    -
    - -
    - <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %> - <%= inst.select(:juridical_nature, @juridical_nature, :selected=>params[:institutions][:juridical_nature], :class => flash[:error_institution_juridical_nature])%> -
    -
    - - -
    - <%= _("SISP?") %> - <% if @show_sisp_field %> - <%= inst.radio_button(:sisp, true, :class => "#{flash[:error_institution_sisp]}" ) %> - <%= inst.label :sisp ,_("Yes"), :value => true %> - <%= inst.radio_button(:sisp, false, :checked=>"checked", :class => "#{flash[:error_institution_sisp]}") %> - <%= inst.label :sisp ,_("No"), :value => false %> - <% else %> - <%= inst.label("sisp", _("No")) %> - <% end %> -
    -
    - - <% if @url_token == "create_institution_admin" %> - <%= submit_button :save, _('Save') %> - <%= button(:cancel, _("Cancel"), {:controller => "admin_panel", :action => 'index'}) %> - <%else%> -
    - <%= link_to(_('Save'), '#', :id=>'save_institution_button', :class=>'button with-text icon-add') %> - <%= link_to(_('Cancel'), '#', :id=>"cancel_institution_button", :class=>'button with-text icon-cancel') %> -
    - <%= hidden_field_tag :institution_error_message, _("Could not send the form data to the server") %> - <%end%> - - <% end %> - - <% end %> -
    -<%= hidden_field_tag :loading_message, _("Creating institution") %> diff --git a/views/gov_user_plugin/create_institution.html.erb b/views/gov_user_plugin/create_institution.html.erb deleted file mode 100644 index 037140f..0000000 --- a/views/gov_user_plugin/create_institution.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => "institution" %> diff --git a/views/gov_user_plugin/create_institution_admin.html.erb b/views/gov_user_plugin/create_institution_admin.html.erb deleted file mode 100644 index 037140f..0000000 --- a/views/gov_user_plugin/create_institution_admin.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => "institution" %> diff --git a/views/gov_user_plugin_myprofile/edit_institution.html.erb b/views/gov_user_plugin_myprofile/edit_institution.html.erb deleted file mode 100644 index 7b0f936..0000000 --- a/views/gov_user_plugin_myprofile/edit_institution.html.erb +++ /dev/null @@ -1,114 +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].blank? %> -
    -

    <%= _("Can`t create new Institution: #{flash[:errors].length} errors") %>

    -
      - <% flash[:errors].each do |error| %> -
    • <%= error %>
    • - <% end %> -
    -
    -<% end %> - -
    - -
    - <%= labelled_form_for :community,:html => { :multipart => true, :id=>"institution_form" } do |f| %> - <%= hidden_field_tag "edit_institution_page", true %> - <%= fields_for :institutions do |inst| %> - -
    - - - -
    -
    - - <%= required f.text_field(:name, :value => @institution.community.name) %> - <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %> - - -
    - <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %> - <%= required inst.text_field(:corporate_name, :value => @institution.corporate_name) %> -
    -
    - - <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}, :selected => @institution.community.country) %> - - -
    - - <%= f.select(:state, @state_list.collect {|state| [state.name, state.name]}, :selected => @institution.community.state) %> -
    -
    - - <%= required f.text_field(:city, :value => @institution.community.city) %> - - - -
    - <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %> - <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field", :value => @institution.cnpj) %> -
    -
    - - -
    - <%= hidden_field_tag "acronym_translate", _("Acronym") %> - <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %> - <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %> - <%= inst.text_field(:acronym, :value => @institution.acronym) %> -
    -
    - - -
    - <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %> - <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>@institution.governmental_power_id})%> -
    -
    - - -
    - <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %> - <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=> @institution.governmental_sphere_id})%> -
    -
    - -
    - <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %> - <%= inst.select(:juridical_nature, [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]}, {:selected=> @institution.juridical_nature_id})%> -
    -
    - - -
    - <%= _("SISP?") %> - <% if @show_sisp_field %> - <%= inst.label("sisp" ,_("Yes")) %> - <%= inst.radio_button(:sisp, true, :checked=>(@institution.sisp ? true : false)) %> - <%= inst.label("sisp" ,_("No")) %> - <%= inst.radio_button(:sisp, false, :checked=>(@institution.sisp ? false : true)) %> - <% else %> - <%= inst.label("sisp", _("No")) %> - <% end %> -
    -
    - - <%= submit_button :save, _('Save') %> - <% end %> -<% end %> - diff --git a/views/incomplete_registration.html.erb b/views/incomplete_registration.html.erb deleted file mode 100644 index d1dceba..0000000 --- a/views/incomplete_registration.html.erb +++ /dev/null @@ -1,11 +0,0 @@ -
    -
    -
    <%= _("Complete Profile")+": #{@percentege}%" %>
    - -
    - <%= link_to _("Complete your profile"), "#{Noosfero.root}/myprofile/#{@person.identifier}/profile_editor/edit" %> | - <%= link_to _("Hide"), "#", :class=>"hide-incomplete-percentage" %> -
    -
    -
    -
    diff --git a/views/organization_ratings_extra_fields_show_institution.html.erb b/views/organization_ratings_extra_fields_show_institution.html.erb deleted file mode 100644 index 7cc4709..0000000 --- a/views/organization_ratings_extra_fields_show_institution.html.erb +++ /dev/null @@ -1,8 +0,0 @@ -<% if user_rating.institution %> -
    -
    - Institution : <%= user_rating.institution.name unless user_rating.institution.nil? %> -
    -
    -<% end %> - diff --git a/views/person_editor_extras.html.erb b/views/person_editor_extras.html.erb deleted file mode 100644 index a3a11fc..0000000 --- a/views/person_editor_extras.html.erb +++ /dev/null @@ -1,42 +0,0 @@ -
    - <%= label_tag "user[secondary_email]", _('Secondary e-mail')+":", :class=>"formlabel" %> - -
    - <%= text_field_tag "user[secondary_email]", context.profile.user.secondary_email %> -
    -
    - - -
    - <%= label_tag "user[institution_ids]", _('Institutions'), :class=>"formlabel" %> - -
    - <%= text_field_tag(:institution, "", :id=>"input_institution") %> - - <% context.profile.user.institutions.each do |institution| %> - <%= hidden_field_tag("user[institution_ids][]", institution.id, :class => 'user_institutions') %> - <% end %> -
    - - <%= content_tag(:div, _("No institution found"), :id=>"institution_empty_ajax_message", :class=>"errorExplanation hide-field") %> - <%= link_to(_("Add new institution"), "#", :class=>'button with-text icon-add', :id => 'add_new_institution') %> - <%= link_to(_("Create new institution"), "#", :id=>"create_institution_link", :class=>'button with-text icon-add') %> - <%= content_tag(:div, "", :id=>"institution_dialog") %> - - <%= hidden_field_tag("user[institution_ids][]", "", :class => 'user_institutions') %> - <%= hidden_field_tag("institution_selected", "") %> - -
      - <% context.profile.user.institutions.each do |institution| %> -
    • - <%= institution.name %> - <%= link_to("", "#", :class => "button without-text icon-remove remove-institution") %> -
    • - <% end %> -
    -
    - -<%= 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/profile/_institution_tab.html.erb b/views/profile/_institution_tab.html.erb deleted file mode 100644 index 6c2f7fb..0000000 --- a/views/profile/_institution_tab.html.erb +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - <%= display_mpog_field(_('Type:'), profile.institution, :type, true) %> - <%= display_mpog_field(_('CNPJ:'), profile.institution, :cnpj, true) %> - <%= display_mpog_field(_('Last modification:'), profile.institution, :date_modification, true) %> - <%= display_mpog_field(_('Country:'), profile.institution.community, :country, true) %> - <%= display_mpog_field(_('State:'), profile.institution.community, :state, true) %> - <%= display_mpog_field(_('City:'), profile.institution.community, :city, true) %> - <% if profile.institution.type == "PrivateInstitution"%> - <%= display_mpog_field(_('Fantasy Name:'), profile.institution, :acronym, true) %> - <% else %> - <%= display_mpog_field(_('Acronym:'), profile.institution, :acronym, true) %> - <%= display_mpog_field(_('Governmental Power:'), profile.institution.governmental_power, :name, true) %> - <%= display_mpog_field(_('Governmental Sphere:'), profile.institution.governmental_sphere, :name, true) %> - <%= display_mpog_field(_('Juridical Nature:'), profile.institution.juridical_nature, :name, true) %> - <%= content_tag('tr', content_tag('td', _("SISP:")) + content_tag('td', profile.institution.sisp ? _("Yes") : _("No"))) %> - <% end %> -
    <%= _('Institution Information')%>
    diff --git a/views/profile/_profile_tab.html.erb b/views/profile/_profile_tab.html.erb deleted file mode 100644 index 4fc67b0..0000000 --- a/views/profile/_profile_tab.html.erb +++ /dev/null @@ -1,3 +0,0 @@ - - <%= display_mpog_profile_information %> -
    diff --git a/views/ratings_extra_field.html.erb b/views/ratings_extra_field.html.erb deleted file mode 100644 index 6f835d1..0000000 --- a/views/ratings_extra_field.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -
    - <%= label_tag "input_institution", _("Organization name or Enterprise name")%> - - - - <%= content_tag(:div, _("No institution found"), - :id=>"institution_empty_ajax_message", - :class=>"errorExplanation hide-field") %> - <%= hidden_field_tag "organization_rating[institution_id]", "", id: "institution_selected" %> -
    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 %> -- libgit2 0.21.2