Commit 37794dc3fee27c4ada6f076f50289b40d03b3e58

Authored by Marcos Pereira
Committed by Daniela Feitosa
1 parent 8badd05d
Exists in master and in 1 other branch mezuro_spb

Add 'SIORG code' field and reorganize some fields on create institution forms

Signed-off-by: Álvaro Fernando <alvarofernandoms@gmail.com>
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
Signed-off-by: Marcos Ronaldo <marcos.rpj2@gmail.com>
Signed-off-by: Melissa Wen <melissa.srw@gmail.com>
src/noosfero-spb/gov_user/controllers/gov_user_plugin_controller.rb
... ... @@ -120,7 +120,7 @@ class GovUserPluginController &lt; ApplicationController
120 120 params[:community] ||= {}
121 121 params[:institutions] ||= {}
122 122  
123   - @show_sisp_field = user.is_admin?
  123 + @show_admin_fields = user.is_admin?
124 124 @governmental_sphere = get_governmental_spheres()
125 125 @governmental_power = get_governmental_powers()
126 126 @juridical_nature = get_juridical_natures()
... ...
src/noosfero-spb/gov_user/controllers/gov_user_plugin_myprofile_controller.rb
... ... @@ -7,7 +7,7 @@ class GovUserPluginMyprofileController &lt; MyProfileController
7 7 end
8 8  
9 9 def edit_institution
10   - @show_sisp_field = user.is_admin?
  10 + @show_admin_fields = user.is_admin?
11 11 @state_list = NationalRegion.find(
12 12 :all,
13 13 :conditions => { :national_region_type_id => 2 },
... ...
src/noosfero-spb/gov_user/db/migrate/20160525181858_change_siorg_column_type.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class ChangeSiorgColumnType < ActiveRecord::Migration
  2 + def self.up
  3 + change_column :institutions, :siorg_code, :string
  4 + end
  5 +
  6 + def self.down
  7 + change_column :institutions, :siorg_code, :integer
  8 + end
  9 +end
... ...
src/noosfero-spb/gov_user/features/institution_registration.feature
... ... @@ -47,3 +47,25 @@ Feature: Institution Field
47 47 And I should not see "community_city"
48 48 And I select "Brazil" from "community_country"
49 49 Then I should not see "Gama"
  50 +
  51 + @selenium
  52 + Scenario: Show sisp and siorg field to admin on create new institution form
  53 + Given I follow "Control panel"
  54 + And I follow "Edit Profile"
  55 + When I follow "Create new institution"
  56 + And I choose "Public Institution"
  57 + Then I should see "SISP?"
  58 + And I should see "SIORG Code"
  59 +
  60 + @selenium
  61 + Scenario: Not show sisp and siorg field to regular user on create new institution form
  62 + Given the following users
  63 + | login |
  64 + | zombie |
  65 + And I am logged in as "zombie"
  66 + When I follow "Control panel"
  67 + And I follow "Edit Profile"
  68 + And I follow "Create new institution"
  69 + And I choose "Public Institution"
  70 + Then I should not see "SISP?"
  71 + And I should not see "SIORG Code"
... ...
src/noosfero-spb/gov_user/lib/institution.rb
... ... @@ -46,8 +46,18 @@ class Institution &lt; ActiveRecord::Base
46 46 }
47 47  
48 48 validate :validate_country, :validate_state, :validate_city,
49   - :verify_institution_type
  49 + :verify_institution_type, :verify_siorg_code
50 50  
  51 + def verify_siorg_code
  52 + if (self.siorg_code.present? && (self.siorg_code =~ /^[0-9]+$/).nil?)
  53 + self.errors.add(
  54 + :siorg_code,
  55 + _("invalid, only numbers are allowed.")
  56 + )
  57 + return false
  58 + end
  59 + true
  60 + end
51 61  
52 62 def has_accepted_rating? user_rating
53 63 rating_ids = OrganizationRating.where(institution_id: self.id, organization_id: user_rating.organization_id).map(&:id)
... ...
src/noosfero-spb/gov_user/public/views/create-institution.js
... ... @@ -45,6 +45,7 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;]
45 45  
46 46  
47 47 function get_institution_post_data() {
  48 +
48 49 return {
49 50 cnpj: $("#institutions_cnpj").val(),
50 51 type: $("input[name='institutions[type]']:checked").val(),
... ... @@ -52,7 +53,9 @@ modulejs.define(&#39;CreateInstitution&#39;, [&#39;jquery&#39;, &#39;NoosferoRoot&#39;, &#39;SelectElement&#39;]
52 53 governmental_power: $("#institutions_governmental_power").selected().val(),
53 54 governmental_sphere: $("#institutions_governmental_sphere").selected().val(),
54 55 juridical_nature: $("#institutions_juridical_nature").selected().val(),
55   - corporate_name: $("#institutions_corporate_name").val()
  56 + corporate_name: $("#institutions_corporate_name").val(),
  57 + siorg_code: $("#institutions_siorg_code").val(),
  58 + sisp: $('input[name="institutions[sisp]"]:checked').val()
56 59 };
57 60 }
58 61  
... ...
src/noosfero-spb/gov_user/views/gov_user_plugin/_institution.html.erb
... ... @@ -30,37 +30,48 @@
30 30 <%= hidden_field_tag "edit_institution_page", false %>
31 31 <%= fields_for :institutions do |inst| %>
32 32 <div class="spb-row no-margin-top">
33   - <div class='spb-col spb-col-3'>
  33 + <div class='spb-col'>
34 34 <%= labelled_radio_button _('Public Institution'), 'institutions[type]', 'PublicInstitution', true %>
35 35 </div>
36 36  
37   - <div class="spb-col spb-col-3">
  37 + <div class="spb-col">
38 38 <%= labelled_radio_button _('Private Institution'), 'institutions[type]', 'PrivateInstitution' %>
39 39 </div>
40 40  
41   - <div class="spb-col spb-col-3"></div>
42   - <div class="spb-col spb-col-3"></div>
43 41 </div>
44 42  
45 43 <div class="spb-row">
46   - <div class="spb-col spb-col-5">
  44 + <div class="spb-col">
47 45 <label for="community_name" class="formlabel">
48 46 <%= _("Corporate Name") %><!-- razão social -->
49 47 <span class="required-field">(*)</span>
50 48 </label>
51 49  
52   - <%= f.text_field(:name, :class => flash[:error_community_name], :value => params[:community][:name]) %>
  50 + <%= f.text_field(:name, :class => flash[:error_community_name], :maxlength => 250, :value => params[:community][:name]) %>
53 51 <%= content_tag :span, _("Institution name already exists"), :id=>"already_exists_text", :class=>"errorExplanation hide-field" %>
54 52 </div>
55 53  
56   - <div class="spb-col spb-col-6">
  54 + <div class="public-institutions-fields">
  55 + <div class="spb-col">
  56 + <%= hidden_field_tag "acronym_translate", _("Acronym") %>
  57 + <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %>
  58 + <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel", id: "institution_acronym_label") %>
  59 + <%= inst.text_field(:acronym, :value => params[:institutions][:acronym], :maxlength => 12) %>
  60 + </div>
  61 + </div>
  62 +
  63 + </div>
  64 +
  65 + <div class="spb-row">
  66 + <div class="spb-col spb-col-12">
57 67 <%= inst.label "corporate_name", _("Fantasy name"), :class=>"formlabel" %><!-- Nome fantasia -->
58   - <%= inst.text_field(:corporate_name, :value => params[:institutions][:corporate_name], :size => 55) %>
  68 + <%= inst.text_field(:corporate_name, :value => params[:institutions][:corporate_name], :size => 55, :maxlength => 250) %>
59 69 </div>
60 70 </div>
61 71  
62 72 <div class="spb-row">
63   - <div class="spb-col spb-col-5">
  73 +
  74 + <div class="spb-col">
64 75 <label for="community_country" class="formlabel">
65 76 <%= _("Country") %>
66 77 <span class="required-field">(*)</span>
... ... @@ -69,7 +80,7 @@
69 80 <%= select("community", "country", [[_('Select a country'), -1]] + country_helper.countries, {:class => "type-select #{flash[:error_community_country]}"}) %>
70 81 </div>
71 82  
72   - <div class="spb-col spb-col-2">
  83 + <div class="spb-col">
73 84 <label for="community_state" class="formlabel">
74 85 <%= _("State") %>
75 86 <span class="required-field">(*)</span>
... ... @@ -78,13 +89,13 @@
78 89 <%= select("community", "state", [[_('Select a state'), '']] + @state_options, {:class => "type-select #{flash[:error_community_state]}"}) %>
79 90 </div>
80 91  
81   - <div class="spb-col spb-col-5">
  92 + <div class="spb-col">
82 93 <label class="formlabel" for="community_city">
83 94 <%= _("City") %>
84 95 <span class="required-field">(*)</span>
85 96 </label>
86 97  
87   - <%= f.text_field(:city, :class => flash[:error_community_city], :value => params[:community][:city]) %>
  98 + <%= f.text_field(:city, :class => flash[:error_community_city], :value => params[:community][:city], :maxlength => 250) %>
88 99 </div>
89 100 </div>
90 101  
... ... @@ -99,14 +110,6 @@
99 110 </div>
100 111 </div>
101 112  
102   - <div class="spb-row">
103   - <div class="spb-col spb-col-12">
104   - <%= hidden_field_tag "acronym_translate", _("Acronym") %>
105   - <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %>
106   - <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %>
107   - <%= inst.text_field(:acronym, :value => params[:institutions][:acronym]) %>
108   - </div>
109   - </div>
110 113  
111 114 <div class="spb-row public-institutions-fields">
112 115 <div class="spb-col spb-col-6">
... ... @@ -141,28 +144,35 @@
141 144 </div>
142 145 </div>
143 146  
144   - <div class="spb-row public-institutions-fields">
145   - <div class="spc-col spb-col-12 sisp-fields">
146   - <div class="spb-col spb-col-3">
147   - <% if @show_sisp_field %>
  147 + <% if @show_admin_fields %>
  148 + <div class="spb-row public-institutions-fields">
  149 + <div class="spc-col spb-col-12 sisp-fields">
  150 + <div class="spb-col spb-col-3">
148 151  
149   - <div class="spb-col spb-col-12">
150   - <%= _("SISP?") %>
151   - </div>
  152 + <div class="spb-col spb-col-12">
  153 + <%= _("SISP?") %>
  154 + </div>
152 155  
153   - <div class="spb-col spb-col-5">
154   - <%= inst.radio_button(:sisp, true, :class => "#{flash[:error_institution_sisp]}" ) %>
155   - <%= inst.label :sisp ,_("Yes"), :value => true %>
156   - </div>
  156 + <div class="spb-col spb-col-5">
  157 + <%= inst.radio_button(:sisp, true, :class => "#{flash[:error_institution_sisp]}" ) %>
  158 + <%= inst.label :sisp ,_("Yes"), :value => true %>
  159 + </div>
157 160  
158   - <div class="spb-col spb-col-6">
159   - <%= inst.radio_button(:sisp, false, :checked=>"checked", :class => "#{flash[:error_institution_sisp]}") %>
160   - <%= inst.label :sisp ,_("No"), :value => false %>
  161 + <div class="spb-col spb-col-6">
  162 + <%= inst.radio_button(:sisp, false, :checked=>"checked", :class => "#{flash[:error_institution_sisp]}") %>
  163 + <%= inst.label :sisp ,_("No"), :value => false %>
  164 + </div>
161 165 </div>
162   - <% end %>
163 166 </div>
164 167 </div>
165   - </div>
  168 +
  169 + <div class="spb-row public-institutions-fields">
  170 + <div class="spb-col spb-col-12">
  171 + <%= inst.label("siorg_code" ,_("SIORG Code"), :class=>"formlabel") %>
  172 + <%= inst.text_field(:siorg_code, :value => params[:institutions][:siorg_code]) %>
  173 + </div>
  174 + </div>
  175 + <% end %>
166 176  
167 177 <div class="spb-row modal-form-actions">
168 178 <div class="spb-col spb-col-6">
... ...
src/noosfero-spb/gov_user/views/gov_user_plugin_myprofile/edit_institution.html.erb
... ... @@ -41,10 +41,21 @@
41 41 </div>
42 42  
43 43 <div class="spb-row">
44   - <div class="spb-col spb-col-4">
  44 + <div class="spb-col spb-col-7">
45 45 <%= required labelled_form_field(_('Corporate Name'), text_field_tag('community[name]', @institution.community.name)) %>
46 46 </div>
47   - <div class="spb-col spb-col-5">
  47 + <span class='optional-field'>
  48 + <div class="spb-col spb-col-5">
  49 + <%= hidden_field_tag "acronym_translate", _("Acronym") %>
  50 + <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %>
  51 + <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %>
  52 + <%= inst.text_field(:acronym, :value => @institution.acronym) %>
  53 + </div>
  54 + </div>
  55 + </div>
  56 +
  57 + <div class="spb-row">
  58 + <div class="spb-col spb-col-12">
48 59 <%= labelled_form_field(_('Fantasy name'), inst.text_field(:corporate_name, :value => @institution.corporate_name)) %>
49 60 </div>
50 61 </div>
... ... @@ -63,21 +74,16 @@
63 74 </div>
64 75 </div>
65 76  
66   - <span class='optional-field'>
67   - <div class="formfield type-text">
68   - <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %>
69   - <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field", :value => @institution.cnpj) %>
70   - </div>
71   - </span>
72   -
73   - <span class='optional-field'>
74   - <div class="formfield type-text">
75   - <%= hidden_field_tag "acronym_translate", _("Acronym") %>
76   - <%= hidden_field_tag "fantasy_name_translate", _("Fantasy name") %>
77   - <%= inst.label("acronym" ,_("Acronym"), :class=>"formlabel") %>
78   - <%= inst.text_field(:acronym, :value => @institution.acronym) %>
  77 + <div class="spb-row">
  78 + <div class="spb-col spb-col-12">
  79 + <span class='optional-field'>
  80 + <div class="formfield type-text">
  81 + <%= inst.label("cnpj" ,_("CNPJ"), :class=>"formlabel") %>
  82 + <%= required inst.text_field(:cnpj, :placeholder=>"99.999.999/9999-99", :class=>"intitution_cnpj_field", :value => @institution.cnpj) %>
  83 + </div>
  84 + </span>
79 85 </div>
80   - </span>
  86 + </div>
81 87  
82 88 <div class="spb-row public-institutions-fields">
83 89 <div class="spb-col spb-col-6">
... ... @@ -112,6 +118,17 @@
112 118 </div>
113 119 </div>
114 120  
  121 + <div class="spb-row public-institutions-fields">
  122 + <div class="spb-col spb-col-6">
  123 + <span class='required-field public-institutions-fields'>
  124 + <div class="formfield type-text">
  125 + <%= inst.label("siorg_code" ,_("SIORG Code:"), :class=>"formlabel") %>
  126 + <%= inst.text_field(:siorg_code, :value => @institution.siorg_code) %>
  127 + </div>
  128 + </span>
  129 + </div>
  130 + </div>
  131 +
115 132 <div class="spc-col spb-col-12 sisp-fields">
116 133 <div class="spb-row public-institutions-fields">
117 134 <div class="spb-col spb-col-3">
... ... @@ -120,7 +137,7 @@
120 137 <div class="spb-col spb-col-12">
121 138 <%= _("SISP?") %>
122 139 </div>
123   - <% if @show_sisp_field %>
  140 + <% if @show_admin_fields %>
124 141 <div class="spb-col spb-col-4">
125 142 <%= inst.radio_button(:sisp, true, :checked=>(@institution.sisp ? true : false)) %>
126 143 <%= inst.label("sisp" ,_("Yes")) %>
... ...
src/noosfero-spb/noosfero-spb-theme/css/administration-panel.css
... ... @@ -346,22 +346,33 @@
346 346 margin-bottom: 10px;
347 347 }
348 348  
  349 +.action-gov_user_plugin_myprofile-edit_institution #content .main-content .formfieldline {
  350 + margin-top: 0;
  351 + padding: 0;
  352 +}
  353 +
349 354 .action-gov_user_plugin_myprofile-edit_institution #community_name {
350 355 color: black;
351   - width: 220px
  356 + width: 402px;
352 357 }
353 358  
354 359 .action-gov_user_plugin-create_institution_admin #community_name {
355   - width: 200px;
  360 + width: 372px;
356 361 }
357 362  
358 363 .action-gov_user_plugin_myprofile-edit_institution #institutions_corporate_name {
359   - width: 287px;
  364 + width: 537px;
360 365 color: black;
361 366 }
362 367  
  368 +.action-gov_user_plugin-create_institution_admin #institutions_cnpj,
363 369 .action-gov_user_plugin-create_institution_admin #institutions_corporate_name {
364   - width: 310px;
  370 + width: 508px;
  371 +}
  372 +
  373 +.action-gov_user_plugin_myprofile-edit_institution #institutions_cnpj {
  374 + width: 537px;
  375 + color: black;
365 376 }
366 377  
367 378 .action-gov_user_plugin_myprofile-edit_institution #community_country {
... ... @@ -383,20 +394,18 @@
383 394 }
384 395  
385 396 .action-gov_user_plugin_myprofile-edit_institution #community_city {
386   - width: 165px;
  397 + width: 171px;
387 398 color: black;
388 399 }
389 400  
390 401 .action-gov_user_plugin-create_institution_admin #community_city {
391   - width: 222px;
  402 + width: 199px;
392 403 }
393 404  
394   -.action-gov_user_plugin_myprofile-edit_institution #institutions_cnpj,
395 405 .action-gov_user_plugin_myprofile-edit_institution #institutions_acronym,
396   -.action-gov_user_plugin-create_institution_admin #institutions_cnpj,
397 406 .action-gov_user_plugin-create_institution_admin #institutions_acronym {
398 407 text-indent: 5px;
399   - width: 530px;
  408 + width: 111px;
400 409 }
401 410  
402 411 .action-gov_user_plugin_myprofile-edit_institution .modal-form-actions,
... ... @@ -409,7 +418,20 @@
409 418 margin-top: 15px;
410 419 }
411 420  
412   -.action-gov_user_plugin_myprofile-edit_institution #content form input.button.with-text,
  421 +.action-gov_user_plugin_myprofile-edit_institution #content .main-content input.button.with-text.icon-save.submit {
  422 + background: #3E67B1 none;
  423 + color: #fff;
  424 + border-radius: 4px;
  425 + border: 1px solid #3E67B1;
  426 + font-size: 14px;
  427 + font-family: "open_sansregular", Arial;
  428 + line-height: 17px;
  429 + max-height: 32px;
  430 + height: 32px;
  431 + padding: 5px 15px;
  432 + margin-right: 5px;
  433 +}
  434 +
413 435 .action-gov_user_plugin-create_institution_admin #content form input.button.with-text {
414 436 background-color: #3E67B1;
415 437 color: #fff;
... ... @@ -694,6 +716,14 @@
694 716 color: #585858;
695 717 }
696 718  
  719 +#noosfero_profile-content #content .main-content #profile-data #institutions_siorg_code,
  720 +.action-profile_editor-edit #content .main-content #profile-data #institutions_siorg_code,
  721 +.action-gov_user_plugin-create_institution_admin #content .main-content #institutions_siorg_code,
  722 +.action-gov_user_plugin_myprofile-edit_institution #content .main-content #institutions_siorg_code,
  723 +.action-organization_ratings_plugin_profile-new_rating #content .main-content #institutions_siorg_code {
  724 + width: 189px;
  725 +}
  726 +
697 727 .action-users-send_mail #content .main-content{
698 728 font-family: Arial;
699 729 }
... ...
src/noosfero-spb/noosfero-spb-theme/css/modal.css
... ... @@ -30,7 +30,7 @@
30 30  
31 31 .action-profile_editor-edit #content .main-content #profile-data .modal-dialog,
32 32 .modal-dialog {
33   - width: 45%;
  33 + width: 590px;
34 34 margin: 15px auto;
35 35 position: relative;
36 36 }
... ... @@ -235,13 +235,18 @@
235 235 .action-profile_editor-edit #content .main-content #profile-data .modal #community_name,
236 236 .modal #community_name {
237 237 height: 16px;
238   - width: 200px;
  238 + width: 392px;
239 239 }
240 240  
  241 +.action-profile_editor-edit #content .main-content #profile-data .modal #institutions_cnpj,
  242 +.modal #institutions_cnpj{
  243 + height: 16px;
  244 + width: 115px;
  245 +}
241 246 .action-profile_editor-edit #content .main-content #profile-data .modal #institutions_corporate_name,
242 247 .modal #institutions_corporate_name {
243 248 height: 16px;
244   - width: 285px;
  249 + width: 533px;
245 250 }
246 251  
247 252 .action-profile_editor-edit #content .main-content #profile-data .modal #community_country,
... ... @@ -251,22 +256,20 @@
251 256  
252 257 .action-profile_editor-edit #content .main-content #profile-data .modal #community_state,
253 258 .modal #community_state {
254   - width: 80px;
  259 + width: 90px;
255 260 }
256 261  
257 262 .action-profile_editor-edit #content .main-content #profile-data .modal #community_city,
258 263 .modal #community_city {
259 264 height: 16px;
260   - width: 190px;
  265 + width: 205px;
261 266 margin-top: 2px;
262 267 }
263 268  
264   -.action-profile_editor-edit #content .main-content #profile-data .modal #institutions_cnpj,
265 269 .action-profile_editor-edit #content .main-content #profile-data .modal #institutions_acronym,
266   -.modal #institutions_cnpj,
267 270 .modal #institutions_acronym {
268 271 height: 16px;
269   - width: 530px;
  272 + width: 111px;
270 273 }
271 274  
272 275 .action-profile_editor-edit #content .main-content #profile-data .modal a.button.with-text.icon-add,
... ...