Skip to content

Commit

Permalink
Merge pull request #571 from shresthamit07/as/add_dob_to_member
Browse files Browse the repository at this point in the history
#556 Add Date of birth field to the member.
  • Loading branch information
anthonycrumley authored Oct 25, 2017
2 parents 9627edd + 527dc65 commit 25c7695
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/members_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,6 @@ def filtered_members

# Never trust parameters from the scary internet, only allow the white list through.
def member_params
params.require(:member).permit(:first_name, :last_name, :phone, :email, :identity, :affiliation, :address, :city, :state, :zip_code, :shirt_size, :shirt_received, :place_of_worship, :recruitment, :community_networks, :extra_groups, :other_networks, :graduating_class_id, :school_id, :identity_id, :organization_ids => [], :neighborhood_ids => [], :extracurricular_activity_ids => [], talent_ids: [], :cohort_ids => [])
params.require(:member).permit(:first_name, :last_name, :date_of_birth, :phone, :email, :identity, :affiliation, :address, :city, :state, :zip_code, :shirt_size, :shirt_received, :place_of_worship, :recruitment, :community_networks, :extra_groups, :other_networks, :graduating_class_id, :school_id, :identity_id, :organization_ids => [], :neighborhood_ids => [], :extracurricular_activity_ids => [], talent_ids: [], :cohort_ids => [])
end
end
2 changes: 1 addition & 1 deletion app/controllers/sign_ups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def update
private

def member_params
params.permit(member: [:id, :first_name, :last_name, :phone, :email, :identity_id, :school_id, :graduating_class_id])[:member]
params.permit(member: [:id, :first_name, :last_name, :date_of_birth, :phone, :email, :identity_id, :school_id, :graduating_class_id])[:member]
end

def participation_params
Expand Down
6 changes: 6 additions & 0 deletions app/views/members/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
<%= f.text_field :last_name, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label :date_of_birth, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.date_field :date_of_birth, min: 150.years.ago, max: Date.today, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label :phone, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
Expand Down
7 changes: 7 additions & 0 deletions app/views/members/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
<dt>Last name:</dt>
<dd><%= @member.last_name %></dd>

<dt>Date of Birth:</dt>
<% if @member.date_of_birth.present? %>
<dd><%= @member.try(:date_of_birth).strftime('%m/%d/%Y') %></dd>
<% else %>
<dd></dd>
<% end %>

<dt>Phone:</dt>
<dd><%= phone_to @member.phone %></dd>

Expand Down
6 changes: 6 additions & 0 deletions app/views/sign_ups/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
<%= f.text_field :last_name, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label :date_of_birth, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
<%= f.date_field :date_of_birth, min: 150.years.ago, max: Date.today, class: "form-control" %>
</div>
</div>
<div class="form-group">
<%= f.label :phone, class: "col-sm-2 control-label" %>
<div class="col-sm-10">
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20170906165256_add_date_of_birth_to_members.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddDateOfBirthToMembers < ActiveRecord::Migration[5.1]
def change
add_column :members, :date_of_birth, :datetime
end
end
1 change: 1 addition & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
t.integer "school_id"
t.string "mongo_id"
t.integer "identity_id"
t.datetime "date_of_birth"
t.index ["identity_id"], name: "index_members_on_identity_id"
end

Expand Down
5 changes: 5 additions & 0 deletions test/models/member_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ class MemberTest < ActiveSupport::TestCase
member = Member.new(first_name: 'First', last_name: 'Last')
assert member.save
end

test 'should save member with date of birth' do
member = Member.new(first_name: 'First', last_name: 'Last', date_of_birth: 20.days.ago)
assert member.save
end
end

0 comments on commit 25c7695

Please sign in to comment.