Commit eb5062af395e4542bcde7379879e5db9b5107f5f
Committed by
Rodrigo Souto
1 parent
673c506c
Exists in
master
and in
29 other branches
profile_editor: add extra optional fields for person
Signed-off-by: Ana Losnak <analosnak@gmail.com> Signed-off-by: Daniel Bucher <daniel.bucher88@gmail.com> ActionItem1011
Showing
6 changed files
with
36 additions
and
2 deletions
Show diff stats
app/helpers/profile_helper.rb
... | ... | @@ -20,10 +20,12 @@ module ProfileHelper |
20 | 20 | zip = display_field(_('ZIP code:'), profile, :zip_code) |
21 | 21 | phone = display_field(_('Contact phone:'), profile, :contact_phone) |
22 | 22 | email = display_field(_('e-Mail:'), profile, :email) { |email| link_to_email(email) } |
23 | - if address.blank? && zip.blank? && phone.blank? && email.blank? | |
23 | + personal_website = display_field(_('Personal website:'), profile, :personal_website) | |
24 | + jabber = display_field(_('Jabber:'), profile, :jabber_id) | |
25 | + if address.blank? && zip.blank? && phone.blank? && email.blank? && personal_website.blank? && jabber.blank? | |
24 | 26 | '' |
25 | 27 | else |
26 | - content_tag('tr', content_tag('th', _('Contact'), { :colspan => 2 })) + address + zip + phone + email | |
28 | + content_tag('tr', content_tag('th', _('Contact'), { :colspan => 2 })) + address + zip + phone + email + personal_website + jabber | |
27 | 29 | end |
28 | 30 | end |
29 | 31 | ... | ... |
app/models/person.rb
app/views/profile_editor/_person_form.rhtml
... | ... | @@ -13,6 +13,8 @@ |
13 | 13 | <%= optional_field(@person, 'contact_phone', labelled_form_field(_('Home phone'), text_field(:profile_data, :contact_phone, :rel => _('Contact phone')))) %> |
14 | 14 | <%= optional_field(@person, 'cell_phone', f.text_field(:cell_phone, :rel => _('Cell phone'))) %> |
15 | 15 | <%= optional_field(@person, 'comercial_phone', f.text_field(:comercial_phone, :rel => _('Comercial phone'))) %> |
16 | +<%= optional_field(@person, 'jabber_id', f.text_field(:jabber_id, :rel => _('Jabber'))) %> | |
17 | +<%= optional_field(@person, 'personal_website', f.text_field(:personal_website, :rel => _('Personal website'))) %> | |
16 | 18 | <%= optional_field(@person, 'sex', f.radio_group(:profile_data, :sex, [ ['male',_('Male')], ['female',_('Female')] ])) %> |
17 | 19 | <%= optional_field(@person, 'birth_date', labelled_form_field(_('Birth date'), '<div class="select-birth-date">' + pick_date(:profile_data, :birth_date, {:start_year => (Date.today.year - 100), :end_year => (Date.today.year - 5)}) + '</div>')) %> |
18 | 20 | <%= optional_field(@person, 'nationality', f.text_field(:nationality, :rel => _('Nationality'))) %> | ... | ... |
db/migrate/20130801182659_add_extra_fields_for_person.rb
0 → 100644
... | ... | @@ -0,0 +1,11 @@ |
1 | +class AddExtraFieldsForPerson < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + add_column :profiles, :personal_website, :string | |
4 | + add_column :profiles, :jabber_id, :string | |
5 | + end | |
6 | + | |
7 | + def self.down | |
8 | + remove_column :profiles, :personal_website | |
9 | + remove_column :profiles, :jabber_id | |
10 | + end | |
11 | +end | ... | ... |
db/schema.rb
... | ... | @@ -468,6 +468,8 @@ ActiveRecord::Schema.define(:version => 20140108132730) do |
468 | 468 | t.boolean "is_template", :default => false |
469 | 469 | t.integer "template_id" |
470 | 470 | t.string "redirection_after_login" |
471 | + t.string "personal_website" | |
472 | + t.string "jabber_id" | |
471 | 473 | end |
472 | 474 | |
473 | 475 | add_index "profiles", ["environment_id"], :name => "index_profiles_on_environment_id" | ... | ... |
test/unit/person_test.rb
... | ... | @@ -1446,4 +1446,19 @@ class PersonTest < ActiveSupport::TestCase |
1446 | 1446 | assert 3, original_person.memberships.count |
1447 | 1447 | end |
1448 | 1448 | |
1449 | + should 'respond to extra fields' do | |
1450 | + user = create_user('some-user').person | |
1451 | + | |
1452 | + assert user.respond_to?(:personal_website) | |
1453 | + assert user.respond_to?(:jabber_id) | |
1454 | + end | |
1455 | + | |
1456 | + should 'return extra fields when fields method is called' do | |
1457 | + extra_fields = ['jabber_id', 'personal_website'] | |
1458 | + | |
1459 | + extra_fields.each do |field| | |
1460 | + assert_includes Person.fields, field | |
1461 | + end | |
1462 | + end | |
1463 | + | |
1449 | 1464 | end | ... | ... |