Commit 0a30bf7ade4d2bba07526c7973137b9767084fec
Committed by
Arthur Esposte
1 parent
bb74e74e
Exists in
master
and in
5 other branches
Add new fields on create institution view
Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Parley Martins <parley@outlook.com>
Showing
4 changed files
with
18 additions
and
4 deletions
Show diff stats
controllers/mpog_software_plugin_controller.rb
@@ -163,7 +163,9 @@ class MpogSoftwarePluginController < ApplicationController | @@ -163,7 +163,9 @@ class MpogSoftwarePluginController < ApplicationController | ||
163 | begin | 163 | begin |
164 | govPower = GovernmentalPower.find params[:governmental][:power] | 164 | govPower = GovernmentalPower.find params[:governmental][:power] |
165 | govSphere = GovernmentalSphere.find params[:governmental][:sphere] | 165 | govSphere = GovernmentalSphere.find params[:governmental][:sphere] |
166 | + jur_nature = JuridicalNature.find params[:juridical][:nature] | ||
166 | 167 | ||
168 | + institution.juridical_nature = jur_nature | ||
167 | institution.governmental_power = govPower | 169 | institution.governmental_power = govPower |
168 | institution.governmental_sphere = govSphere | 170 | institution.governmental_sphere = govSphere |
169 | rescue | 171 | rescue |
lib/institution.rb
1 | class Institution < ActiveRecord::Base | 1 | class Institution < ActiveRecord::Base |
2 | belongs_to :governmental_power | 2 | belongs_to :governmental_power |
3 | belongs_to :governmental_sphere | 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 | has_and_belongs_to_many :users | 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 | validates :name, :presence=>true, :uniqueness=>true | 13 | validates :name, :presence=>true, :uniqueness=>true |
11 | 14 | ||
12 | before_save :verify_institution_type | 15 | before_save :verify_institution_type |
public/mpog-institution-validations.js
@@ -57,10 +57,13 @@ | @@ -57,10 +57,13 @@ | ||
57 | power : jQuery("#institutions_governmental_power").selected().val(), | 57 | power : jQuery("#institutions_governmental_power").selected().val(), |
58 | sphere : jQuery("#institutions_governmental_sphere").selected().val() | 58 | sphere : jQuery("#institutions_governmental_sphere").selected().val() |
59 | }, | 59 | }, |
60 | + juridical : { | ||
61 | + nature : jQuery("#institutions_juridical_nature").selected().val() | ||
62 | + }, | ||
60 | institution : { | 63 | institution : { |
61 | cnpj: jQuery("#institutions_cnpj").val(), | 64 | cnpj: jQuery("#institutions_cnpj").val(), |
62 | type: get_selected_institution_type(), | 65 | type: get_selected_institution_type(), |
63 | - acronym : jQuery("#institutions_acronym").val() | 66 | + acronym : jQuery("#institutions_acronym").val(), |
64 | }, | 67 | }, |
65 | authenticity_token : jQuery("input[name='authenticity_token']").val(), | 68 | authenticity_token : jQuery("input[name='authenticity_token']").val(), |
66 | recaptcha_response_field : jQuery('#recaptcha_response_field').val(), | 69 | recaptcha_response_field : jQuery('#recaptcha_response_field').val(), |
views/mpog_software_plugin/create_institution.html.erb
@@ -69,6 +69,12 @@ | @@ -69,6 +69,12 @@ | ||
69 | </div> | 69 | </div> |
70 | </span> | 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 | <br /> | 78 | <br /> |
73 | 79 | ||
74 | <div> | 80 | <div> |