Commit 0a30bf7ade4d2bba07526c7973137b9767084fec

Authored by Gabriela Navarro
Committed by Arthur Esposte
1 parent bb74e74e

Add new fields on create institution view

Signed-off-by: Gabriela Navarro <navarro1703@gmail.com>
Signed-off-by: Parley Martins <parley@outlook.com>
controllers/mpog_software_plugin_controller.rb
... ... @@ -163,7 +163,9 @@ class MpogSoftwarePluginController &lt; ApplicationController
163 163 begin
164 164 govPower = GovernmentalPower.find params[:governmental][:power]
165 165 govSphere = GovernmentalSphere.find params[:governmental][:sphere]
  166 + jur_nature = JuridicalNature.find params[:juridical][:nature]
166 167  
  168 + institution.juridical_nature = jur_nature
167 169 institution.governmental_power = govPower
168 170 institution.governmental_sphere = govSphere
169 171 rescue
... ...
lib/institution.rb
1 1 class Institution < ActiveRecord::Base
2 2 belongs_to :governmental_power
3 3 belongs_to :governmental_sphere
  4 + belongs_to :juridical_nature
4 5  
5   - attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type,
6   - :juridical_nature, :sub_juridical_nature, :normalization_level,
7   - :version, :cnpj, :type, :governmental_power, :governmental_sphere
8 6 has_and_belongs_to_many :users
9 7  
  8 + attr_accessible :name, :acronym, :unit_code, :parent_code, :unit_type,
  9 + :sub_juridical_nature, :normalization_level,
  10 + :version, :cnpj, :type, :governmental_power, :governmental_sphere,
  11 + :sisp, :juridical_nature
  12 +
10 13 validates :name, :presence=>true, :uniqueness=>true
11 14  
12 15 before_save :verify_institution_type
... ...
public/mpog-institution-validations.js
... ... @@ -57,10 +57,13 @@
57 57 power : jQuery("#institutions_governmental_power").selected().val(),
58 58 sphere : jQuery("#institutions_governmental_sphere").selected().val()
59 59 },
  60 + juridical : {
  61 + nature : jQuery("#institutions_juridical_nature").selected().val()
  62 + },
60 63 institution : {
61 64 cnpj: jQuery("#institutions_cnpj").val(),
62 65 type: get_selected_institution_type(),
63   - acronym : jQuery("#institutions_acronym").val()
  66 + acronym : jQuery("#institutions_acronym").val(),
64 67 },
65 68 authenticity_token : jQuery("input[name='authenticity_token']").val(),
66 69 recaptcha_response_field : jQuery('#recaptcha_response_field').val(),
... ...
views/mpog_software_plugin/create_institution.html.erb
... ... @@ -69,6 +69,12 @@
69 69 </div>
70 70 </span>
71 71  
  72 + <span class='required-field public-institutions-fields'>
  73 + <div class="formfield type-text">
  74 + <%= inst.label("juridical_nature_id" ,_("Juridical Nature:"), :class=>"formlabel") %>
  75 + <%= inst.select(:juridical_nature, [[_("Select a Juridical Nature"), 0]]|JuridicalNature.all.map {|j| [j.name, j.id]}, {:selected=>0})%>
  76 + </div>
  77 + </span>
72 78 <br />
73 79  
74 80 <div>
... ...