Commit 70d4c6080301d03d4d6d346a0d7fbe234cde5237

Authored by Gabriela Navarro
1 parent d2acf743
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

Moving position of fields on institution creation and add corporate_name

field

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
db/migrate/20141103183013_add_corporate_name_to_institution.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class AddCorporateNameToInstitution < ActiveRecord::Migration
  2 + def up
  3 + add_column :institutions, :corporate_name, :string
  4 + end
  5 +
  6 + def down
  7 + remove_column :institutions, :corporate_name
  8 + end
  9 +end
... ...
lib/institution.rb
... ... @@ -8,10 +8,12 @@ class Institution &lt; ActiveRecord::Base
8 8 attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type,
9 9 :sub_juridical_nature, :normalization_level,
10 10 :version, :cnpj, :type, :governmental_power, :governmental_sphere,
11   - :sisp, :juridical_nature
  11 + :sisp, :juridical_nature, :corporate_name
12 12  
13 13 validates :name, :presence=>true, :uniqueness=>true
14 14  
  15 + validates :corporate_name, :presence => true
  16 +
15 17 before_save :verify_institution_type
16 18  
17 19 belongs_to :community
... ...
public/mpog-institution-validations.js
... ... @@ -46,7 +46,8 @@
46 46 acronym : jQuery("#institutions_acronym").val(),
47 47 governmental_power: jQuery("#institutions_governmental_power").selected().val(),
48 48 governmental_sphere: jQuery("#institutions_governmental_sphere").selected().val(),
49   - juridical_nature: jQuery("#institutions_juridical_nature").selected().val()
  49 + juridical_nature: jQuery("#institutions_juridical_nature").selected().val(),
  50 + corporate_name: jQuery("#institutions_corporate_name").val()
50 51 },
51 52 }
52 53 }
... ...
test/functional/mpog_software_plugin_controller_test.rb
... ... @@ -164,7 +164,8 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
164 164 :acronym => "",
165 165 :governmental_power => "",
166 166 :governmental_sphere => "",
167   - :juridical_nature => ""
  167 + :juridical_nature => "",
  168 + :corporate_name => "coporate default"
168 169 }
169 170 }
170 171 fields
... ... @@ -186,6 +187,7 @@ class MpogSoftwarePluginControllerTest &lt; ActionController::TestCase
186 187 institution.governmental_power = gov_p
187 188 institution.governmental_sphere = gov_s
188 189 institution.cnpj = cnpj
  190 + institution.corporate_name = "corporate default"
189 191 institution.save!
190 192 institution
191 193 end
... ...
views/mpog_software_plugin/_institution.html.erb
... ... @@ -20,33 +20,45 @@
20 20 <div id = 'create_institution_errors' class='errorExplanation hide-field'></div>
21 21  
22 22 <div>
  23 + <div class="fields-required">
  24 + <span class="errorExplanation"><%= _("All fields with (*) are mandatory") %></span>
  25 + </div>
  26 + <br/>
23 27 <%= labelled_form_for :community, :url => {:action=>"new_institution"}, :html => { :multipart => true, :id=>"institution_form" } do |f| %>
24   - <%= required f.text_field(:name) %>
25   - <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %>
26   -
27   - <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %>
28   - <%= required f.text_field(:state) %>
29   - <%= required f.text_field(:city) %>
30 28  
31 29 <%= fields_for :institutions do |inst| %>
  30 + <span class=''>
  31 + <div class='formfield type-radio'>
  32 + <label> <%= _("Public Institution") %>
  33 + <%= radio_button_tag("institutions[type]", "PublicInstitution", true) %>
  34 + </label>
  35 +
  36 + <label>
  37 + <%= _("Private Institution") %>
  38 + <%= radio_button_tag("institutions[type]" ,"PrivateInstitution")%>
  39 + </label>
  40 + </div>
  41 + </span>
  42 +
  43 + <%= required f.text_field(:name) %>
  44 + <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %>
32 45  
33 46 <span class='required-field'>
34 47 <div class="formfield type-text">
35   - <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %>
36   - <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field") %>
  48 + <%= inst.label "corporate_name", _("Corporate Name"), :class=>"formlabel" %>
  49 + <%= required inst.text_field(:corporate_name) %>
37 50 </div>
38 51 </span>
39 52  
40   - <span class=''>
41   - <div class='formfield type-radio'>
42   - <label> <%= _("Public Institution") %>
43   - <%= radio_button_tag("institutions[type]", "PublicInstitution", true) %>
44   - </label>
45   -
46   - <label>
47   - <%= _("Private Institution") %>
48   - <%= radio_button_tag("institutions[type]" ,"PrivateInstitution")%>
49   - </label>
  53 + <%= required select_country(_('Country'), 'community', 'country', {:class => 'type-select', :id => "community_country"}) %>
  54 + <%= required f.text_field(:state) %>
  55 + <%= required f.text_field(:city) %>
  56 +
  57 +
  58 + <span class='required-field'>
  59 + <div class="formfield type-text">
  60 + <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %>
  61 + <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field") %>
50 62 </div>
51 63 </span>
52 64  
... ... @@ -61,18 +73,17 @@
61 73  
62 74 <span class='required-field public-institutions-fields'>
63 75 <div class="formfield type-text">
64   - <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %>
65   - <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=>0})%>
  76 + <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %>
  77 + <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>0})%>
66 78 </div>
67 79 </span>
68 80  
69 81 <span class='required-field public-institutions-fields'>
70 82 <div class="formfield type-text">
71   - <%= inst.label("governmental_sphere_id" ,_("Governmental Sphere:"), :class=>"formlabel") %>
72   - <%= inst.select(:governmental_sphere, [[_("Select a Governmental Sphere"), 0]]|GovernmentalSphere.all.map {|s| [s.name, s.id]}, {:selected=>0})%>
  83 + <%= inst.label("governmental_power_id" ,_("Governmental Power:"), :class=>"formlabel") %>
  84 + <%= inst.select(:governmental_power, [[_("Select a Governmental Power"), 0]]|GovernmentalPower.all.map {|g| [g.name, g.id]}, {:selected=>0})%>
73 85 </div>
74 86 </span>
75   -
76 87 <span class='required-field public-institutions-fields'>
77 88 <div class="formfield type-text">
78 89 <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %>
... ...