Commit a5eca913f88f62d486d6fad78848853f3c51cc00

Authored by Gabriela Navarro
1 parent f60de0fe

Finish move institution to gov_user.

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Thiago Ribeiro  <thiagitosouza@hotmail.com>
features/institution_registration.feature 0 → 100644
... ... @@ -0,0 +1,32 @@
  1 +Feature: Institution Field
  2 + As a user
  3 + I want to sign up resgistring my institution
  4 + So others users can use it
  5 +
  6 + Background:
  7 + Given "SoftwareCommunitiesPlugin" plugin is enabled
  8 + And I am logged in as mpog_admin
  9 + And I go to /admin/plugins
  10 + And I check "SoftwareCommunitiesPlugin"
  11 + And I press "Save changes"
  12 + And Institutions has initial default values on database
  13 + And I am logged in as mpog_admin
  14 +
  15 + @selenium
  16 + Scenario: Show new institution fields when clicked in create new institution
  17 + Given I follow "Edit Profile"
  18 + When I follow "Create new institution"
  19 + And I should see "New Institution"
  20 + And I should see "Public Institution"
  21 + And I should see "Private Institution"
  22 + And I should see "Corporate Name"
  23 + And I should see "Name"
  24 + And I should see "State"
  25 + And I should see "City"
  26 + And I should see "Country"
  27 + And I should see "CNPJ"
  28 + And I should see "Acronym"
  29 + And I choose "Public Institution"
  30 + Then I should see "Governmental Sphere:"
  31 + And I should see "Governmental Power:"
  32 + And I should see "Juridical Nature:"
0 33 \ No newline at end of file
... ...
features/steps_definitions/gov_user_steps.rb 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +Given /^Institutions has initial default values on database$/ do
  2 + GovernmentalPower.create(:name => "Executivo")
  3 + GovernmentalPower.create(:name => "Legislativo")
  4 + GovernmentalPower.create(:name => "Judiciario")
  5 +
  6 + GovernmentalSphere.create(:name => "Federal")
  7 +
  8 + JuridicalNature.create(:name => "Autarquia")
  9 + JuridicalNature.create(:name => "Administracao Direta")
  10 + JuridicalNature.create(:name => "Empresa Publica")
  11 + JuridicalNature.create(:name => "Fundacao")
  12 + JuridicalNature.create(:name => "Orgao Autonomo")
  13 + JuridicalNature.create(:name => "Sociedade")
  14 + JuridicalNature.create(:name => "Sociedade Civil")
  15 + JuridicalNature.create(:name => "Sociedade de Economia Mista")
  16 +
  17 + national_region = NationalRegion.new
  18 + national_region.name = "Distrito Federal"
  19 + national_region.national_region_code = '35'
  20 + national_region.national_region_type_id = NationalRegionType::STATE
  21 + national_region.save
  22 +end
  23 +
  24 +
  25 +Given /^the following public institutions?$/ do |table|
  26 + # table is a Cucumber::Ast::Table
  27 + table.hashes.each do |item|
  28 + community = Community.new
  29 + community.name = item[:name]
  30 + community.country = item[:country]
  31 + community.state = item[:state]
  32 + community.city = item[:city]
  33 + community.save!
  34 +
  35 + governmental_power = GovernmentalPower.where(:name => item[:governmental_power]).first
  36 + governmental_sphere = GovernmentalSphere.where(:name => item[:governmental_sphere]).first
  37 +
  38 + juridical_nature = JuridicalNature.create(:name => item[:juridical_nature])
  39 +
  40 + 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)
  41 + institution.community = community
  42 + institution.corporate_name = item[:corporate_name]
  43 + institution.save!
  44 + end
  45 +end
... ...
features/user_profile_edition.feature
... ... @@ -26,3 +26,32 @@ Feature: Institution Field
26 26 Scenario: Verify text information to use governmental e-mail
27 27 Given I follow "Edit Profile"
28 28 Then I should see "If you work in a public agency use your government e-Mail"
  29 +
  30 + @selenium
  31 + Scenario: Add more then one instituion on profile editor
  32 + Given I follow "Edit Profile"
  33 + And I follow "Add new institution"
  34 + And I type in "Minis" in autocomplete list "#input_institution" and I choose "Ministerio do Planejamento"
  35 + And I follow "Add new institution"
  36 + And I type in "Gover" in autocomplete list "#input_institution" and I choose "Governo do DF"
  37 + And I follow "Add new institution"
  38 + Then I should see "Ministerio do Planejamento" within ".institutions_added"
  39 + And I should see "Governo do DF" within ".institutions_added"
  40 +
  41 + @selenium
  42 + Scenario: Verify if field 'city' is shown when Brazil is selected
  43 + Given I follow "Edit Profile"
  44 + Then I should see "City"
  45 +
  46 + @selenium
  47 + Scenario: Verify if field 'city' does not appear when Brazil is not selected as country
  48 + Given I follow "Edit Profile"
  49 + When I select "United States" from "profile_data_country"
  50 + Then I should not see "City" within ".type-text"
  51 +
  52 + @selenium
  53 + Scenario: Show message of institution not found
  54 + Given I follow "Edit Profile"
  55 + And I fill in "input_institution" with "Some Nonexistent Institution"
  56 + And I sleep for 1 seconds
  57 + Then I should see "No institution found"
... ...
lib/ext/person.rb
... ... @@ -10,6 +10,9 @@ class Person
10 10  
11 11 delegate :login, :to => :user, :prefix => true
12 12  
  13 + def institution?
  14 + false
  15 + end
13 16 def secondary_email
14 17 self.user.secondary_email unless self.user.nil?
15 18 end
... ...
lib/gov_user_plugin.rb
... ... @@ -128,6 +128,10 @@ class GovUserPlugin &lt; Noosfero::Plugin
128 128 views/complete-registration.js
129 129 initializer.js
130 130 app.js
  131 + views/control-panel.js
  132 + views/create-institution.js
  133 + views/new-community.js
  134 + views/user-edit-profile.js
131 135 )
132 136 end
133 137  
... ...
public/initializer.js
... ... @@ -3,6 +3,8 @@
3 3  
4 4 var dependencies = [
5 5 'CompleteRegistration',
  6 + 'UserEditProfile',
  7 + 'CreateInstitution'
6 8 ];
7 9  
8 10  
... ...
public/lib/select-element.js 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +modulejs.define('SelectElement', function() {
  2 + 'use strict';
  3 +
  4 +
  5 + function SelectElement(name, id) {
  6 + this.select = document.createElement("select");
  7 + }
  8 +
  9 +
  10 + SelectElement.prototype.setAttr = function(attr, value) {
  11 + return this.select.setAttribute(attr, value);
  12 + };
  13 +
  14 +
  15 + SelectElement.prototype.addOption = function(option) {
  16 + return this.select.add(option);
  17 + };
  18 +
  19 +
  20 + SelectElement.prototype.getSelect = function() {
  21 + return this.select;
  22 + };
  23 +
  24 +
  25 + SelectElement.generateOption = function(value, text) {
  26 + var option;
  27 + option = document.createElement("option");
  28 + option.setAttribute("value", value);
  29 + option.text = text;
  30 + return option;
  31 + };
  32 +
  33 +
  34 + return SelectElement;
  35 +});
... ...
public/lib/select-field-choices.js 0 → 100644
... ... @@ -0,0 +1,81 @@
  1 +modulejs.define('SelectFieldChoices', ['jquery', 'SelectElement'], function($, SelectElement) {
  2 + 'use strict';
  3 +
  4 +
  5 + function SelectFieldChoices(state_id, city_id, state_url) {
  6 + this.state_id = state_id;
  7 + this.input_html = $(state_id).parent().html();
  8 + this.old_value = $(state_id).val();
  9 + this.city_parent_div = $(city_id).parent().parent().parent();
  10 + this.state_url = state_url;
  11 + }
  12 +
  13 +
  14 + SelectFieldChoices.prototype.getCurrentStateElement = function() {
  15 + return $(this.state_id);
  16 + };
  17 +
  18 +
  19 + SelectFieldChoices.prototype.replaceWith = function(html) {
  20 + var parent_div = this.getCurrentStateElement().parent();
  21 + parent_div.html(html);
  22 + };
  23 +
  24 +
  25 + SelectFieldChoices.prototype.generateSelect = function(state_list) {
  26 + var select_element, option;
  27 +
  28 + select_element = new SelectElement();
  29 + select_element.setAttr("name", "profile_data[state]");
  30 + select_element.setAttr("id", "state_field");
  31 + select_element.setAttr("class", "type-select valid");
  32 +
  33 + state_list.forEach(function(state) {
  34 + option = SelectElement.generateOption(state, state);
  35 + select_element.addOption(option);
  36 + });
  37 +
  38 + return select_element.getSelect();
  39 + };
  40 +
  41 +
  42 + SelectFieldChoices.prototype.replaceStateWithSelectElement = function() {
  43 + var klass = this;
  44 +
  45 + $.get(this.state_url, function(response) {
  46 + var select_html;
  47 +
  48 + if (response.length > 0) {
  49 + select_html = klass.generateSelect(response);
  50 + klass.replaceWith(select_html);
  51 +
  52 + if (klass.old_value.length !== 0 && response.include(klass.old_value)) {
  53 + klass.getCurrentStateElement().val(klass.old_value);
  54 + }
  55 + }
  56 + });
  57 + };
  58 +
  59 +
  60 + SelectFieldChoices.prototype.replaceStateWithInputElement = function() {
  61 + this.replaceWith(this.input_html);
  62 + };
  63 +
  64 +
  65 + SelectFieldChoices.prototype.hideCity = function() {
  66 + this.city_parent_div.addClass("mpog_hidden_field");
  67 + };
  68 +
  69 +
  70 + SelectFieldChoices.prototype.showCity = function() {
  71 + this.city_parent_div.removeClass("mpog_hidden_field");
  72 + };
  73 +
  74 +
  75 + SelectFieldChoices.prototype.actualFieldIsInput = function() {
  76 + return this.getCurrentStateElement().attr("type") === "text";
  77 + };
  78 +
  79 +
  80 + return SelectFieldChoices;
  81 +});
... ...
public/static/governmental_powers.txt 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +Executivo
  2 +Legislativo
  3 +Judiciario
  4 +Nao se aplica
... ...
public/static/governmental_sphere.txt 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +Federal
  2 +Estadual
  3 +Distrital
  4 +Municipal
0 5 \ No newline at end of file
... ...
public/static/juridical_nature.txt 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +Administracao Direta
  2 +Autarquia
  3 +Empresa Publica
  4 +Fundacao
  5 +Orgao Autonomo
  6 +Sociedade
  7 +Sociedade Civil
  8 +Sociedade de Economia Mista
... ...
public/views/control-panel.js 0 → 100644
... ... @@ -0,0 +1,32 @@
  1 +modulejs.define('ControlPanel', ['jquery'], function($) {
  2 + 'use strict';
  3 +
  4 + function add_institution_on_control_panel(control_panel) {
  5 + var institution_link = $(".control-panel-instituton-link").remove();
  6 +
  7 + if( institution_link.size() > 0 ) {
  8 + control_panel.prepend(institution_link);
  9 + }
  10 + }
  11 +
  12 +
  13 + function add_itens_on_controla_panel() {
  14 + var control_panel = $(".control-panel");
  15 +
  16 + if( control_panel.size() > 0 ) {
  17 + add_institution_on_control_panel(control_panel);
  18 + }
  19 + }
  20 +
  21 +
  22 + return {
  23 + isCurrentPage: function() {
  24 + return $("#profile-editor-index").length === 1;
  25 + },
  26 +
  27 +
  28 + init: function() {
  29 + add_itens_on_controla_panel();
  30 + }
  31 + }
  32 +});
... ...
public/views/create-institution.js 0 → 100644
... ... @@ -0,0 +1,312 @@
  1 +modulejs.define('CreateInstitution', ['jquery', 'NoosferoRoot', 'SelectElement'], function($, NoosferoRoot, SelectElement) {
  2 + 'use strict';
  3 +
  4 + var AJAX_URL = {
  5 + create_institution_modal:
  6 + NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/create_institution"),
  7 + new_institution:
  8 + NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/new_institution"),
  9 + institution_already_exists:
  10 + NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/institution_already_exists"),
  11 + get_institutions:
  12 + NoosferoRoot.urlWithSubDirectory("/plugin/software_communities/get_institutions")
  13 + };
  14 +
  15 +
  16 + function open_create_institution_modal(evt) {
  17 + evt.preventDefault();
  18 +
  19 + $.get(AJAX_URL.create_institution_modal, function(response){
  20 + $("#institution_dialog").html(response);
  21 +
  22 + set_form_count_custom_data();
  23 + set_events();
  24 +
  25 + $("#institution_dialog").dialog({
  26 + modal: true,
  27 + width: 500,
  28 + height: 530,
  29 + position: 'center',
  30 + close: function() {
  31 + $("#institution_dialog").html("");
  32 + $('#institution_empty_ajax_message').switchClass("show-field", "hide-field");
  33 + }
  34 + });
  35 + });
  36 + }
  37 +
  38 +
  39 + function show_public_institutions_fields() {
  40 + $(".public-institutions-fields").show();
  41 + }
  42 +
  43 +
  44 + function show_private_institutions_fields() {
  45 + $(".public-institutions-fields").hide();
  46 +
  47 + $("#institutions_governmental_power option").selected(0);
  48 + $("#institutions_governmental_sphere option").selected(0);
  49 + }
  50 +
  51 +
  52 + function get_comunity_post_data() {
  53 + return {
  54 + name : $("#community_name").val(),
  55 + country : $("#community_country").val(),
  56 + state : $("#community_state").val(),
  57 + city : $("#community_city").val()
  58 + }
  59 + }
  60 +
  61 +
  62 + function get_institution_post_data() {
  63 + return {
  64 + cnpj: $("#institutions_cnpj").val(),
  65 + type: $("input[name='institutions[type]']:checked").val(),
  66 + acronym : $("#institutions_acronym").val(),
  67 + governmental_power: $("#institutions_governmental_power").selected().val(),
  68 + governmental_sphere: $("#institutions_governmental_sphere").selected().val(),
  69 + juridical_nature: $("#institutions_juridical_nature").selected().val(),
  70 + corporate_name: $("#institutions_corporate_name").val()
  71 + }
  72 + }
  73 +
  74 +
  75 + function get_post_data() {
  76 + var post_data = {};
  77 +
  78 + post_data.community = get_comunity_post_data();
  79 + post_data.institutions = get_institution_post_data();
  80 +
  81 + return post_data;
  82 + }
  83 +
  84 +
  85 + function success_ajax_response(response) {
  86 + close_loading();
  87 +
  88 + if(response.success){
  89 + var institution_name = response.institution_data.name;
  90 + var institution_id = response.institution_data.id;
  91 +
  92 + $("#institution_dialog").html("<div class='errorExplanation'><h2>"+response.message+"</h2></div>");
  93 + $("#create_institution_errors").switchClass("show-field", "hide-field");
  94 +
  95 + $(".institution_container").append(get_clone_institution_data(institution_id));
  96 + add_selected_institution_to_list(institution_id, institution_name);
  97 +
  98 + $(".remove-institution").click(remove_institution);
  99 + } else {
  100 + var errors = "<ul>";
  101 +
  102 + for(var i = 0; i < response.errors.length; i++) {
  103 + errors += "<li>"+response.errors[i]+"</li>";
  104 + }
  105 + errors += "</ul>";
  106 +
  107 + $("#create_institution_errors").switchClass("hide-field", "show-field").html("<h2>"+response.message+"</h2>"+errors);
  108 + }
  109 + }
  110 +
  111 +
  112 + function save_institution(evt) {
  113 + evt.preventDefault();
  114 +
  115 + open_loading($("#loading_message").val());
  116 + $.ajax({
  117 + url: AJAX_URL.new_institution,
  118 + data : get_post_data(),
  119 + type: "POST",
  120 + success: success_ajax_response,
  121 + error: function() {
  122 + close_loading();
  123 + var error_message = $("#institution_error_message").val();
  124 + $("#create_institution_errors").switchClass("hide-field", "show-field").html("<h2>"+error_message+"</h2>");
  125 + }
  126 + });
  127 + }
  128 +
  129 +
  130 + function institution_already_exists(){
  131 + if( this.value.length >= 3 ) {
  132 + $.get(AJAX_URL.institution_already_exists, {name:this.value}, function(response){
  133 + if( response === true ) {
  134 + $("#already_exists_text").switchClass("hide-field", "show-field");
  135 + } else {
  136 + $("#already_exists_text").switchClass("show-field", "hide-field");
  137 + }
  138 + });
  139 + }
  140 + }
  141 +
  142 +
  143 + function get_clone_institution_data(value) {
  144 + var user_institutions = $(".user_institutions").first().clone();
  145 + user_institutions.val(value);
  146 +
  147 + return user_institutions;
  148 + }
  149 +
  150 +
  151 + function institution_autocomplete() {
  152 + $("#input_institution").autocomplete({
  153 + source : function(request, response){
  154 + $.ajax({
  155 + type: "GET",
  156 + url: AJAX_URL.get_institutions,
  157 + data: {query: request.term},
  158 + success: function(result){
  159 + response(result);
  160 +
  161 + if( result.length === 0 ) {
  162 + $('#institution_empty_ajax_message').switchClass("hide-field", "show-field");
  163 + } else {
  164 + $('#institution_empty_ajax_message').switchClass("show-field", "hide-field");
  165 + }
  166 + },
  167 + error: function(ajax, stat, errorThrown) {
  168 + console.log('Link not found : ' + errorThrown);
  169 + }
  170 + });
  171 + },
  172 +
  173 + minLength: 2,
  174 +
  175 + select : function (event, selected) {
  176 + $("#institution_selected").val(selected.item.id).attr("data-name", selected.item.label);
  177 + }
  178 + });
  179 + }
  180 +
  181 +
  182 + function add_selected_institution_to_list(id, name) {
  183 + var selected_institution = "<li data-institution='"+id+"'>"+name;
  184 + selected_institution += "<a href='#' class='button without-text icon-remove remove-institution'></a></li>";
  185 +
  186 + $(".institutions_added").append(selected_institution);
  187 + }
  188 +
  189 +
  190 + function add_new_institution(evt) {
  191 + evt.preventDefault();
  192 + var selected = $("#institution_selected");
  193 + var institution_already_added = $(".institutions_added li[data-institution='"+selected.val()+"']").length;
  194 +
  195 + if(selected.val().length > 0 && institution_already_added === 0) {
  196 + //field that send the institutions to the server
  197 + $(".institution_container").append(get_clone_institution_data(selected.val()));
  198 +
  199 + // Visualy add the selected institution to the list
  200 + add_selected_institution_to_list(selected.val(), selected.attr("data-name"));
  201 +
  202 + // clean the institution flag
  203 + selected.val("").attr("data-name", "");
  204 + $("#input_institution").val("");
  205 +
  206 + $(".remove-institution").click(remove_institution);
  207 + }
  208 + }
  209 +
  210 +
  211 + function remove_institution(evt) {
  212 + evt.preventDefault();
  213 + var code = $(this).parent().attr("data-institution");
  214 +
  215 + $(".user_institutions[value="+code+"]").remove();
  216 + $(this).parent().remove();
  217 + }
  218 +
  219 +
  220 + function add_mask_to_form_items() {
  221 + $(".intitution_cnpj_field").mask("99.999.999/9999-99");
  222 + }
  223 +
  224 +
  225 + function show_hide_cnpj_city(country) {
  226 + var cnpj = $("#institutions_cnpj").parent().parent();
  227 + var city = $("#community_city").parent().parent();
  228 + var state = $("#community_state").parent().parent();
  229 +
  230 + if( country === "-1" ) $("#community_country").val("BR");
  231 +
  232 + if( country !== "BR" ) {
  233 + cnpj.hide();
  234 + city.hide();
  235 + state.hide();
  236 + } else {
  237 + cnpj.show();
  238 + city.show();
  239 + state.show();
  240 + }
  241 + }
  242 +
  243 +
  244 + function institution_type_actions(type) {
  245 + if( type === "PublicInstitution" ) {
  246 + show_public_institutions_fields();
  247 + } else {
  248 + show_private_institutions_fields();
  249 + }
  250 + }
  251 +
  252 +
  253 + function set_form_count_custom_data() {
  254 + var divisor_option = SelectElement.generateOption("-1", "--------------------------------");
  255 + var default_option = SelectElement.generateOption("BR", "Brazil");
  256 +
  257 + var inst_type = $("input[name='institutions[type]']:checked").val();
  258 + var country = $("#community_country").val();
  259 +
  260 + institution_type_actions(inst_type);
  261 + show_hide_cnpj_city(country);
  262 +
  263 + if( $('#community_country').find("option[value='']").length === 1 ) {
  264 + $('#community_country').find("option[value='']").remove();
  265 + $('#community_country').prepend(divisor_option);
  266 + $('#community_country').prepend(default_option);
  267 +
  268 + if($("#edit_institution_page").val() === "false") {
  269 + $('#community_country').val("BR");
  270 + show_hide_cnpj_city($('#community_country').val());
  271 + }
  272 + }
  273 + }
  274 +
  275 +
  276 + function set_events() {
  277 + $("#create_institution_link").click(open_create_institution_modal);
  278 +
  279 + $("input[name='institutions[type]']").click(function(){
  280 + institution_type_actions(this.value);
  281 + });
  282 +
  283 + $('#save_institution_button').click(save_institution);
  284 +
  285 + $("#community_name").keyup(institution_already_exists);
  286 +
  287 + $("#add_new_institution").click(add_new_institution);
  288 +
  289 + $(".remove-institution").click(remove_institution);
  290 +
  291 + $("#community_country").change(function(){
  292 + show_hide_cnpj_city(this.value);
  293 + });
  294 +
  295 + add_mask_to_form_items();
  296 +
  297 + institution_autocomplete();
  298 + }
  299 +
  300 +
  301 + return {
  302 + isCurrentPage: function() {
  303 + return $("#institution_form").length === 1;
  304 + },
  305 +
  306 +
  307 + init: function() {
  308 + set_form_count_custom_data();
  309 + set_events();
  310 + }
  311 + }
  312 +});
... ...
public/views/new-community.js 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +modulejs.define("NewCommunity", ['jquery'], function($) {
  2 +
  3 + function replace_mandatory_message() {
  4 + $(".required-field").first()
  5 + .replaceWith("<span class='required-field'> Os campos em destaque<label class='pseudoformlabel'> (*)</label> são obrigatórios. </span>");
  6 + }
  7 +
  8 + function remove_image_builder_text() {
  9 + $("label:contains('Image builder')").hide();
  10 + }
  11 +
  12 + function hide_organization_template_fields(){
  13 + $('#template-options').hide();
  14 + }
  15 +
  16 + return {
  17 +
  18 + isCurrentPage: function() {
  19 + return true;
  20 + },
  21 +
  22 + init: function() {
  23 + replace_mandatory_message();
  24 + remove_image_builder_text();
  25 + hide_organization_template_fields();
  26 + }
  27 + }
  28 +})
... ...
public/views/user-edit-profile.js 0 → 100644
... ... @@ -0,0 +1,216 @@
  1 +modulejs.define('UserEditProfile', ['jquery', 'SelectElement', 'SelectFieldChoices', 'CreateInstitution'], function($, SelectElement, SelectFieldChoices, CreateInstitution) {
  2 + 'use strict';
  3 +
  4 + function set_form_count_custom_data() {
  5 + var divisor_option = SelectElement.generateOption("-1", "--------------------------------");
  6 + var default_option = SelectElement.generateOption("BR", "Brazil");
  7 +
  8 + $('#profile_data_country').find("option[value='']").remove();
  9 + $('#profile_data_country').prepend(divisor_option);
  10 + $('#profile_data_country').prepend(default_option);
  11 + $('#profile_data_country').val("BR");
  12 + }
  13 +
  14 +
  15 + function set_initial_form_custom_data(selectFieldChoices) {
  16 + set_form_count_custom_data();
  17 +
  18 + $("#password-balloon").html($("#user_password_menssage").val());
  19 + $("#profile_data_email").parent().append($("#email_public_message").remove());
  20 +
  21 + if( $("#state_field").length !== 0 ) selectFieldChoices.replaceStateWithSelectElement();
  22 + }
  23 +
  24 +
  25 + function show_state_if_country_is_brazil() {
  26 + var selectFieldChoices = new SelectFieldChoices("#state_field", "#city_field", "/plugin/software_communities/get_brazil_states");
  27 + set_initial_form_custom_data(selectFieldChoices);
  28 +
  29 + $("#profile_data_country").change(function(){
  30 + if( this.value === "-1" ) $(this).val("BR");
  31 +
  32 + if( this.value === "BR" && selectFieldChoices.actualFieldIsInput() ) {
  33 + selectFieldChoices.replaceStateWithSelectElement();
  34 + selectFieldChoices.showCity();
  35 + } else if( this.value !== "BR" && !selectFieldChoices.actualFieldIsInput() ) {
  36 + selectFieldChoices.replaceStateWithInputElement();
  37 + selectFieldChoices.hideCity();
  38 + }
  39 + });
  40 + }
  41 +
  42 +
  43 + function show_or_hide_phone_mask() {
  44 + if($("#profile_data_country").val() === "BR") {
  45 + if( (typeof $("#profile_data_cell_phone").data("rawMaskFn") === 'undefined') ) {
  46 + $("#profile_data_cell_phone").mask("(99) 9999?9-9999");
  47 + $("#profile_data_comercial_phone").mask("(99) 9999?9-9999");
  48 + $("#profile_data_contact_phone").mask("(99) 9999?9-9999");
  49 + }
  50 + } else {
  51 + $("#profile_data_cell_phone").unmask();
  52 + $("#profile_data_comercial_phone").unmask();
  53 + $("#profile_data_contact_phone").unmask();
  54 + }
  55 + }
  56 +
  57 +
  58 + function fix_phone_mask_format(id) {
  59 + $(id).blur(function() {
  60 + var last = $(this).val().substr( $(this).val().indexOf("-") + 1 );
  61 +
  62 + if( last.length === 3 ) {
  63 + var move = $(this).val().substr( $(this).val().indexOf("-") - 1, 1 );
  64 + var lastfour = move + last;
  65 + var first = $(this).val().substr( 0, 9 );
  66 +
  67 + $(this).val( first + '-' + lastfour );
  68 + }
  69 + });
  70 + }
  71 +
  72 +
  73 + function show_plugin_error_message(field_selector, hidden_message_id ) {
  74 + var field = $(field_selector);
  75 +
  76 + field.removeClass("validated").addClass("invalid");
  77 +
  78 + if(!$("." + hidden_message_id)[0]) {
  79 + var message = $("#" + hidden_message_id).val();
  80 + field.parent().append("<div class='" + hidden_message_id + " errorExplanation'>"+message+"</span>");
  81 + } else {
  82 + $("." + hidden_message_id).show();
  83 + }
  84 + }
  85 +
  86 +
  87 + function hide_plugin_error_message(field_selector, hidden_message_id) {
  88 + $(field_selector).removeClass("invalid").addClass("validated");
  89 + $("." + hidden_message_id).hide();
  90 + }
  91 +
  92 +
  93 + function add_blur_fields(field_selector, hidden_message_id, validation_function, allow_blank) {
  94 + $(field_selector).blur(function(){
  95 + $(this).attr("class", "");
  96 +
  97 + if( validation_function(this.value, !!allow_blank) ) {
  98 + show_plugin_error_message(field_selector, hidden_message_id);
  99 + } else {
  100 + hide_plugin_error_message(field_selector, hidden_message_id);
  101 + }
  102 + });
  103 + }
  104 +
  105 +
  106 + function invalid_email_validation(value, allow_blank) {
  107 + if( allow_blank && value.trim().length === 0 ) {
  108 + return false;
  109 + }
  110 +
  111 + var correct_format_regex = new RegExp(/^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/);
  112 +
  113 + return !correct_format_regex.test(value);
  114 + }
  115 +
  116 +
  117 + function invalid_site_validation(value) {
  118 + var correct_format_regex = new RegExp(/(^|)(http[s]{0,1})\:\/\/(\w+[.])\w+/g);
  119 +
  120 + return !correct_format_regex.test(value);
  121 + }
  122 +
  123 +
  124 + function get_privacy_selector_parent_div(field_id, actual) {
  125 + if( actual === undefined ) actual = $(field_id);
  126 +
  127 + if( actual.is("form") || actual.length === 0 ) return null; // Not allow recursion over form
  128 +
  129 + if( actual.hasClass("field-with-privacy-selector") ) {
  130 + return actual;
  131 + } else {
  132 + return get_privacy_selector_parent_div(field_id, actual.parent());
  133 + }
  134 + }
  135 +
  136 +
  137 + function try_to_remove(list, field) {
  138 + try {
  139 + list.push(field.remove());
  140 + } catch(e) {
  141 + console.log("Cound not remove field");
  142 + }
  143 + }
  144 +
  145 +
  146 + function get_edit_fields_in_insertion_order() {
  147 + var containers = [];
  148 +
  149 + try_to_remove(containers, get_privacy_selector_parent_div("#city_field"));
  150 + try_to_remove(containers, get_privacy_selector_parent_div("#state_field"));
  151 + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_country"));
  152 + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_birth_date"));
  153 + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_organization_website"));
  154 + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_personal_website"));
  155 + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_comercial_phone"));
  156 + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_contact_phone"));
  157 + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_cell_phone"));
  158 + try_to_remove(containers, $("#select_institution"));
  159 + try_to_remove(containers, $("#user_secondary_email").parent().parent());
  160 + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_email"));
  161 + try_to_remove(containers, get_privacy_selector_parent_div("#profile_data_name"));
  162 + try_to_remove(containers, $(".pseudoformlabel").parent().parent());
  163 + try_to_remove(containers, $("h2")[0]);
  164 +
  165 + return containers;
  166 + }
  167 +
  168 +
  169 + function change_edit_fields_order() {
  170 + var form = $("#profile-data");
  171 +
  172 + if( form.length !== 0 ) {
  173 + var containers = get_edit_fields_in_insertion_order();
  174 +
  175 + containers.forEach(function(container){
  176 + form.prepend(container);
  177 + });
  178 + }
  179 + }
  180 +
  181 +
  182 + function set_fields_validations() {
  183 + $("#profile_data_country").blur(show_or_hide_phone_mask);
  184 +
  185 + $("#profile_data_birth_date").mask("99/99/9999");
  186 +
  187 + fix_phone_mask_format("#profile_data_cell_phone");
  188 + fix_phone_mask_format("#profile_data_comercial_phone");
  189 + fix_phone_mask_format("#profile_data_contact_phone");
  190 +
  191 + add_blur_fields("#profile_data_email", "email_error", invalid_email_validation);
  192 + add_blur_fields("#user_secondary_email", "email_error", invalid_email_validation, true);
  193 + add_blur_fields("#profile_data_personal_website", "site_error", invalid_site_validation);
  194 + add_blur_fields("#profile_data_organization_website", "site_error", invalid_site_validation);
  195 + }
  196 +
  197 +
  198 + return {
  199 + isCurrentPage: function() {
  200 + return $('#profile_data_email').length === 1;
  201 + },
  202 +
  203 +
  204 + init: function() {
  205 + change_edit_fields_order(); // To change the fields order, it MUST be the first function executed
  206 +
  207 + show_state_if_country_is_brazil();
  208 +
  209 + show_or_hide_phone_mask();
  210 +
  211 + set_fields_validations();
  212 +
  213 + CreateInstitution.init();
  214 + }
  215 + }
  216 +});
... ...
test/unit/gov_user_person_test.rb 0 → 100644
... ... @@ -0,0 +1,57 @@
  1 +# encoding: utf-8
  2 +
  3 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  4 +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
  5 +
  6 +class SoftwareCommunitiesPluginPersonTest < ActiveSupport::TestCase
  7 + include PluginTestHelper
  8 +
  9 + def setup
  10 + @plugin = GovUserPlugin.new
  11 +
  12 + @user = fast_create(User)
  13 + @person = create_person(
  14 + "My Name",
  15 + "user@email.com",
  16 + "123456",
  17 + "123456",
  18 + "Any State",
  19 + "Some City"
  20 + )
  21 + end
  22 +
  23 + def teardown
  24 + @plugin = nil
  25 + end
  26 +
  27 + should 'be a noosfero plugin' do
  28 + assert_kind_of Noosfero::Plugin, @plugin
  29 + end
  30 +
  31 + should 'save person with a valid full name' do
  32 + p = Person::new :name=>"S1mpl3 0f N4m3", :identifier=>"simple-name"
  33 + p.user = fast_create(:user)
  34 +
  35 + assert_equal true, p.save
  36 + end
  37 +
  38 + should 'save person with a valid full name with accents' do
  39 + name = 'Jônatàs dâ Sîlvã Jösé'
  40 + identifier = "jonatas-jose-da-silva"
  41 + p = Person::new :name=>name, :identifier=>identifier
  42 + p.user = fast_create(:user)
  43 +
  44 + assert_equal true, p.save
  45 + end
  46 +
  47 + should 'not save person whose name has not capital letter' do
  48 + p = Person::new :name=>"simple name"
  49 + assert !p.save, _("Name Should begin with a capital letter and no special characters")
  50 + end
  51 +
  52 + should 'not save person whose name has special characters' do
  53 + p = Person::new :name=>"Simple N@me"
  54 +
  55 + assert !p.save , _("Name Should begin with a capital letter and no special characters")
  56 + end
  57 +end
... ...
test/unit/governmental_power_test.rb 0 → 100644
... ... @@ -0,0 +1,33 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) + '/../helpers/institution_test_helper'
  3 +
  4 +class GovernmentalPowerTest < ActiveSupport::TestCase
  5 +
  6 + def setup
  7 + @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
  8 + @juridical_nature = JuridicalNature.create(:name => "Autarquia")
  9 + end
  10 +
  11 + def teardown
  12 + Institution.destroy_all
  13 + end
  14 +
  15 + should "get public institutions" do
  16 + inst_name = "Ministerio Publico da Uniao"
  17 + inst_cnpj = "12.345.678/9012-45"
  18 + gov_power = GovernmentalPower.create(:name=>"Some gov power")
  19 + InstitutionTestHelper.create_public_institution(
  20 + inst_name,
  21 + "MPU",
  22 + "BR",
  23 + "DF",
  24 + "Gama",
  25 + @juridical_nature,
  26 + gov_power,
  27 + @gov_sphere,
  28 + inst_cnpj
  29 + )
  30 +
  31 + assert_equal gov_power.public_institutions.count, PublicInstitution.count
  32 + end
  33 +end
0 34 \ No newline at end of file
... ...
test/unit/institution_test.rb 0 → 100644
... ... @@ -0,0 +1,62 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
  3 +
  4 +class InstitutionTest < ActiveSupport::TestCase
  5 + include PluginTestHelper
  6 + def setup
  7 + @gov_power = GovernmentalPower.create(:name=>"Some Gov Power")
  8 + @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
  9 + @juridical_nature = JuridicalNature.create(:name => "Autarquia")
  10 +
  11 + @institution = create_public_institution(
  12 + "Ministerio Publico da Uniao",
  13 + "MPU",
  14 + "BR",
  15 + "DF",
  16 + "Gama",
  17 + @juridical_nature,
  18 + @gov_power,
  19 + @gov_sphere,
  20 + "11.222.333/4444-55"
  21 + )
  22 + end
  23 +
  24 + def teardown
  25 + GovernmentalPower.destroy_all
  26 + GovernmentalSphere.destroy_all
  27 + JuridicalNature.destroy_all
  28 + @institution = nil
  29 + end
  30 + should "not save institutions without name" do
  31 + @institution.name = nil
  32 + assert !@institution.save
  33 + assert @institution.errors.full_messages.include? "Name can't be blank"
  34 + end
  35 +
  36 + should "not save if institution has invalid type" do
  37 + invalid_msg = "Type invalid, only public and private institutions are allowed."
  38 + @institution.type = "Other type"
  39 + assert !@institution.save, 'Invalid type'
  40 + assert @institution.errors.full_messages.include? invalid_msg
  41 + end
  42 +
  43 + should "not save without country" do
  44 + @institution.community.country = nil
  45 + assert !@institution.save, "Country can't be blank"
  46 + assert @institution.errors.full_messages.include? "Country can't be blank"
  47 + end
  48 +
  49 + should "not save without state" do
  50 + @institution.community.state = nil
  51 +
  52 + assert !@institution.save, "State can't be blank"
  53 + assert @institution.errors.full_messages.include? "State can't be blank"
  54 + end
  55 +
  56 + should "not save without city" do
  57 + @institution.community.city = nil
  58 +
  59 + assert !@institution.save, "City can't be blank"
  60 + assert @institution.errors.full_messages.include? "City can't be blank"
  61 + end
  62 +end
... ...
test/unit/institutions_block_test.rb 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
  3 +
  4 +class InstitutionsBlockTest < ActiveSupport::TestCase
  5 + include PluginTestHelper
  6 + should 'inherit from Block' do
  7 + assert_kind_of Block, InstitutionsBlock.new
  8 + end
  9 +
  10 + should 'declare its default title' do
  11 + InstitutionsBlock.any_instance.stubs(:profile_count).returns(0)
  12 + assert_not_equal Block.new.default_title, InstitutionsBlock.new.default_title
  13 + end
  14 +
  15 + should 'describe itself' do
  16 + assert_not_equal Block.description, InstitutionsBlock.description
  17 + end
  18 +
  19 + should 'give empty footer on unsupported owner type' do
  20 + block = InstitutionsBlock.new
  21 + block.expects(:owner).returns(1)
  22 + assert_equal '', block.footer
  23 + end
  24 +
  25 + should 'list institutions' do
  26 + user = create_person("Jose_Augusto",
  27 + "jose_augusto@email.com",
  28 + "aaaaaaa",
  29 + "aaaaaaa",
  30 + 'jose@secondary.com',
  31 + "DF",
  32 + "Gama"
  33 + )
  34 +
  35 + institution = create_private_institution(
  36 + "inst name",
  37 + "IN",
  38 + "country",
  39 + "state",
  40 + "city",
  41 + "00.111.222/3333-44"
  42 + )
  43 + institution.community.add_member(user)
  44 +
  45 + block = InstitutionsBlock.new
  46 + block.expects(:owner).at_least_once.returns(user)
  47 +
  48 + assert_equivalent [institution.community], block.profiles
  49 + end
  50 +
  51 +end
... ...
test/unit/juridical_nature_test.rb 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
  3 +
  4 +class JuridicalNatureTest < ActiveSupport::TestCase
  5 +
  6 + include PluginTestHelper
  7 +
  8 + def setup
  9 + @govPower = GovernmentalPower.create(:name=>"Some Gov Power")
  10 + @govSphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
  11 + end
  12 +
  13 + def teardown
  14 + Institution.destroy_all
  15 + end
  16 +
  17 + should "get public institutions" do
  18 + juridical_nature = JuridicalNature.create(:name => "Autarquia")
  19 + create_public_institution("Ministerio Publico da Uniao", "MPU", "BR", "DF", "Gama", juridical_nature, @govPower, @govSphere, "22.333.444/5555-66")
  20 + create_public_institution("Tribunal Regional da Uniao", "TRU", "BR", "DF", "Brasilia", juridical_nature, @govPower, @govSphere, "22.333.444/5555-77")
  21 + assert juridical_nature.public_institutions.count == PublicInstitution.count
  22 + end
  23 +end
... ...
test/unit/private_institution_test.rb 0 → 100644
... ... @@ -0,0 +1,50 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
  3 +
  4 +class PrivateInstitutionTest < ActiveSupport::TestCase
  5 + include PluginTestHelper
  6 + def setup
  7 + @institution = create_private_institution(
  8 + "Simple Private Institution",
  9 + "SPI",
  10 + "BR",
  11 + "DF",
  12 + "Gama",
  13 + "00.000.000/0001-00"
  14 + )
  15 + end
  16 +
  17 + def teardown
  18 + @institution = nil
  19 + Institution.destroy_all
  20 + end
  21 +
  22 + should "not save without a cnpj" do
  23 + @institution.cnpj = nil
  24 +
  25 + assert !@institution.save
  26 + assert @institution.errors.full_messages.include? "Cnpj can't be blank"
  27 + end
  28 +
  29 + should "not save with a repeated cnpj" do
  30 + msg = "Cnpj has already been taken"
  31 + assert @institution.save
  32 + sec_institution = create_private_institution(
  33 + "Another Private Institution",
  34 + "API",
  35 + "BR",
  36 + "DF",
  37 + "Gama",
  38 + "00.000.000/0001-00"
  39 + )
  40 +
  41 + assert sec_institution.errors.full_messages.include? msg
  42 + end
  43 +
  44 + should "save without fantasy name" do
  45 + @institution.acronym = nil
  46 + @institution.community.save
  47 +
  48 + assert @institution.save
  49 + end
  50 +end
... ...
test/unit/public_institution_test.rb 0 → 100644
... ... @@ -0,0 +1,68 @@
  1 +require File.dirname(__FILE__) + '/../../../../test/test_helper'
  2 +require File.dirname(__FILE__) + '/../helpers/plugin_test_helper'
  3 +
  4 +class PublicInstitutionTest < ActiveSupport::TestCase
  5 + include PluginTestHelper
  6 + def setup
  7 + @gov_power = GovernmentalPower.create(:name=>"Some Gov Power")
  8 + @gov_sphere = GovernmentalSphere.create(:name=>"Some Gov Sphere")
  9 + @juridical_nature = JuridicalNature.create(:name => "Autarquia")
  10 +
  11 + @institution = create_public_institution(
  12 + "Ministerio Publico da Uniao",
  13 + "MPU",
  14 + "BR",
  15 + "DF",
  16 + "Gama",
  17 + @juridical_nature,
  18 + @gov_power,
  19 + @gov_sphere,
  20 + "11.222.333/4444-55"
  21 + )
  22 + end
  23 +
  24 + def teardown
  25 + GovernmentalPower.destroy_all
  26 + GovernmentalSphere.destroy_all
  27 + JuridicalNature.destroy_all
  28 + Institution.destroy_all
  29 + @gov_power = nil
  30 + @gov_sphere = nil
  31 + @juridical_nature = nil
  32 + @institution = nil
  33 + end
  34 +
  35 + should "not save without a cnpj" do
  36 + @institution.cnpj = nil
  37 + assert !@institution.save
  38 + end
  39 +
  40 + should "save institution without an acronym" do
  41 + @institution.acronym = nil
  42 + assert @institution.save
  43 + end
  44 +
  45 + should "Not save institution without a governmental_power" do
  46 + invalid_msg = "Governmental power can't be blank"
  47 + @institution.governmental_power = nil
  48 +
  49 + assert !@institution.save
  50 + assert @institution.errors.full_messages.include? invalid_msg
  51 + end
  52 +
  53 + should "Not save institution without a governmental_sphere" do
  54 + invalid_msg = "Governmental sphere can't be blank"
  55 + @institution.governmental_sphere = nil
  56 +
  57 + assert !@institution.save
  58 + assert @institution.errors.full_messages.include? invalid_msg
  59 + end
  60 +
  61 + should "not save institution without juridical nature" do
  62 + invalid_msg = "Juridical nature can't be blank"
  63 + @institution.juridical_nature = nil
  64 +
  65 + assert !@institution.save
  66 + assert @institution.errors.full_messages.include? invalid_msg
  67 + end
  68 +end
... ...
views/gov_user_plugin_myprofile/_public_software_info.html.erb
... ... @@ -1,102 +0,0 @@
1   -<div id = "public_software">
2   - <% if @disabled_public_software_field == true %>
3   - <%= check_box_tag("software[public_software]", "true", @software_info.public_software?, :disabled => "disabled") %>
4   - <%= label_tag _("Public Software"), _("Public software"), :class => "public_software_disabled" %>
5   - <% else %>
6   - <%= check_box_tag("software[public_software]", "true", @software_info.public_software?) %>
7   - <%= label_tag _("Public Software"), _("Public software"), :class => "public_software_enabled" %>
8   - <% end %>
9   - <div class="public-software-fields">
10   - <h4> <%= _("Public Software") %> </h4>
11   - <div class="formfieldline">
12   - <%= label_tag _("Adherent to e-PING ?") %>
13   -
14   - <%= label_tag "e_ping_true", "Yes" %>
15   - <%= radio_button_tag("software[e_ping]", true, @software_info.e_ping)%>
16   - <%= label_tag "e_ping_false", "No"%>
17   - <%= radio_button_tag("software[e_ping]", false, !@software_info.e_ping)%>
18   - </div>
19   -
20   - <div class="formfieldline">
21   - <%= label_tag _("Adherent to e-MAG ?") %>
22   -
23   - <%= label_tag "e_mag_true", "Yes"%>
24   - <%= radio_button_tag("software[e_mag]", true, @software_info.e_mag)%>
25   - <%= label_tag "e_mag_false", "No"%>
26   - <%= radio_button_tag("software[e_mag]", false, !@software_info.e_mag)%>
27   - </div>
28   -
29   - <div class="formfieldline">
30   - <%= label_tag _("Adherent to ICP-Brasil ?") %>
31   -
32   - <%= label_tag "icp_brasil_true", "Yes"%>
33   - <%= radio_button_tag("software[icp_brasil]", true, @software_info.icp_brasil)%>
34   - <%= label_tag "icp_brasil_false", "No"%>
35   - <%= radio_button_tag("software[icp_brasil]", false, !@software_info.icp_brasil)%>
36   - </div>
37   -
38   - <div class="formfieldline">
39   - <%= label_tag _("Adherent to e-ARQ ?") %>
40   -
41   - <%= label_tag "e_arq_true", "Yes"%>
42   - <%= radio_button_tag("software[e_arq]", true, @software_info.e_arq)%>
43   - <%= label_tag "e_arq_false", "No"%>
44   - <%= radio_button_tag("software[e_arq]", false, !@software_info.e_arq)%>
45   - </div>
46   -
47   - <div class="formfieldline">
48   - <%= label_tag _("Internacionalizable ?") %>
49   -
50   - <%= label_tag "intern_true", "Yes" %>
51   - <%= radio_button_tag("software[intern]", true, @software_info.intern)%>
52   - <%= label_tag "intern_false", "No"%>
53   - <%= radio_button_tag("software[intern]", false, !@software_info.intern)%>
54   - </div>
55   - </div>
56   -</div>
57   -
58   -<div class="formfieldline">
59   - <h4> <%= _("Operating Platform") %> </h4>
60   - <%= text_area_tag "software[operating_platform]", @software_info.operating_platform, :cols => 40, :rows => 5%>
61   -</div>
62   -
63   -<div class="formfieldline">
64   - <h4> <%= _("Features") %> </h4>
65   - <%= text_area_tag "software[features]", @software_info.features, :maxlength=>"4000", :cols => 40, :rows => 5%>
66   -</div>
67   -
68   -<div id = "demonstration_url">
69   - <h4> <%= _("Demonstration url") %> </h4>
70   - <%= text_field_tag("software[demonstration_url]", @software_info.demonstration_url) %>
71   -</div>
72   -
73   -<div id='libraries_fields'>
74   - <h4> <%= _("Libraries") %> </h4>
75   -
76   - <%= render :partial => 'library_fields', :locals => {:object_name => 'community', :profile => @community, :libraries => @list_libraries } %>
77   -</div>
78   -
79   -<br />
80   -
81   -<div id='operating_system_fields'>
82   - <h4> <%= _("Operating Systems") %> </h4>
83   -
84   - <%= render :partial => 'operating_system_fields', :locals => {:object_name => 'community', :profile => @community, :operating_systems_fields => @list_operating_systems} %>
85   -</div>
86   -<br />
87   -
88   -<br />
89   -<div id='programming_languages_fields'>
90   - <h4> <%= _("Programming languages") %> </h4>
91   -
92   - <%= render :partial => 'language_fields', :locals => { :object_name => 'community', :profile => @community, :languages => @list_languages } %>
93   -</div>
94   -
95   -<br />
96   -<div id='database_fields'>
97   - <h4> <%= _("Databases") %> </h4>
98   -
99   - <%= render :partial => 'database_fields', :locals => {:object_name => 'community', :profile => @community, :database => @list_databases } %>
100   -</div>
101   -
102   -<br>
views/person_editor_extras.html.erb
... ... @@ -6,6 +6,36 @@
6 6 </div>
7 7 </div>
8 8  
  9 +
  10 +<div class="formfieldline" id="select_institution">
  11 + <%= label_tag "user[institution_ids]", _('Institutions'), :class=>"formlabel" %>
  12 +
  13 + <div class="institution_container">
  14 + <%= text_field_tag(:institution, "", :id=>"input_institution") %>
  15 +
  16 + <% context.profile.user.institutions.each do |institution| %>
  17 + <%= hidden_field_tag("user[institution_ids][]", institution.id, :class => 'user_institutions') %>
  18 + <% end %>
  19 + </div>
  20 +
  21 + <%= content_tag(:div, _("No institution found"), :id=>"institution_empty_ajax_message", :class=>"errorExplanation hide-field") %>
  22 + <%= link_to(_("Add new institution"), "#", :class=>'button with-text icon-add', :id => 'add_new_institution') %>
  23 + <%= link_to(_("Create new institution"), "#", :id=>"create_institution_link", :class=>'button with-text icon-add') %>
  24 + <%= content_tag(:div, "", :id=>"institution_dialog") %>
  25 +
  26 + <%= hidden_field_tag("user[institution_ids][]", "", :class => 'user_institutions') %>
  27 + <%= hidden_field_tag("institution_selected", "") %>
  28 +
  29 + <ul class="institutions_added">
  30 + <% context.profile.user.institutions.each do |institution| %>
  31 + <li data-institution="<%= institution.id %>">
  32 + <%= institution.name %>
  33 + <%= link_to("", "#", :class => "button without-text icon-remove remove-institution") %>
  34 + </li>
  35 + <% end %>
  36 + </ul>
  37 +</div>
  38 +
9 39 <%= hidden_field_tag("full_name_error", _("Should begin with a capital letter and no special characters")) %>
10 40 <%= hidden_field_tag("email_error", _("Email should have the following format: name@host.br")) %>
11 41 <%= hidden_field_tag("site_error", _("Site should have a valid format: http://name.hosts")) %>
... ...
views/profile/_institution_tab.html.erb 0 → 100644
... ... @@ -0,0 +1,21 @@
  1 +<table>
  2 + <tr>
  3 + <th colspan='2'><%= _('Institution Information')%></th>
  4 + </tr>
  5 +
  6 + <%= display_mpog_field(_('Type:'), profile.institution, :type, true) %>
  7 + <%= display_mpog_field(_('CNPJ:'), profile.institution, :cnpj, true) %>
  8 + <%= display_mpog_field(_('Last modification:'), profile.institution, :date_modification, true) %>
  9 + <%= display_mpog_field(_('Country:'), profile.institution.community, :country, true) %>
  10 + <%= display_mpog_field(_('State:'), profile.institution.community, :state, true) %>
  11 + <%= display_mpog_field(_('City:'), profile.institution.community, :city, true) %>
  12 + <% if profile.institution.type == "PrivateInstitution"%>
  13 + <%= display_mpog_field(_('Fantasy Name:'), profile.institution, :acronym, true) %>
  14 + <% else %>
  15 + <%= display_mpog_field(_('Acronym:'), profile.institution, :acronym, true) %>
  16 + <%= display_mpog_field(_('Governmental Power:'), profile.institution.governmental_power, :name, true) %>
  17 + <%= display_mpog_field(_('Governmental Sphere:'), profile.institution.governmental_sphere, :name, true) %>
  18 + <%= display_mpog_field(_('Juridical Nature:'), profile.institution.juridical_nature, :name, true) %>
  19 + <%= content_tag('tr', content_tag('td', _("SISP:")) + content_tag('td', profile.institution.sisp ? _("Yes") : _("No"))) %>
  20 + <% end %>
  21 +</table>
... ...
views/profile/_profile_tab.html.erb 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<table>
  2 + <%= display_mpog_profile_information %>
  3 +</table>
... ...