Browse Source

Remove birth date from people

Maarten van den Berg 6 years ago
parent
commit
ff63a05550

+ 1 - 1
app/controllers/members_controller.rb

151
   # through.  Note: differs from the ones in PeopleController because
151
   # through.  Note: differs from the ones in PeopleController because
152
   # creating admins is not allowed.
152
   # creating admins is not allowed.
153
   def invite_params
153
   def invite_params
154
-    params.require(:person).permit(:first_name, :infix, :last_name, :email, :birth_date)
154
+    params.require(:person).permit(:first_name, :infix, :last_name, :email)
155
   end
155
   end
156
 end
156
 end

+ 1 - 1
app/controllers/people_controller.rb

108
 
108
 
109
   # Never trust parameters from the scary internet, only allow the white list through.
109
   # Never trust parameters from the scary internet, only allow the white list through.
110
   def person_params
110
   def person_params
111
-    params.require(:person).permit(:first_name, :infix, :last_name, :email, :birth_date, :is_admin)
111
+    params.require(:person).permit(:first_name, :infix, :last_name, :email, :is_admin)
112
   end
112
   end
113
 end
113
 end

+ 0 - 12
app/models/person.rb

17
   #   @return [String]
17
   #   @return [String]
18
   #     the person's surname. ('Gogh' in 'Vincent van Gogh'.)
18
   #     the person's surname. ('Gogh' in 'Vincent van Gogh'.)
19
   #
19
   #
20
-  # @!attribute birth_date
21
-  #   @return [Date]
22
-  #     the person's birth date.
23
-  #
24
   # @!attribute email
20
   # @!attribute email
25
   #   @return [String]
21
   #   @return [String]
26
   #     the person's email address.
22
   #     the person's email address.
47
   validates :first_name, presence: true
43
   validates :first_name, presence: true
48
   validates :last_name, presence: true
44
   validates :last_name, presence: true
49
 
45
 
50
-  validate :birth_date_cannot_be_in_future
51
-
52
   before_validation :not_admin_if_nil
46
   before_validation :not_admin_if_nil
53
   before_save :update_user_email, if: :email_changed?
47
   before_save :update_user_email, if: :email_changed?
54
 
48
 
88
         p.infix       = row['infix']
82
         p.infix       = row['infix']
89
         p.last_name   = row['last_name']
83
         p.last_name   = row['last_name']
90
         p.email       = row['email']
84
         p.email       = row['email']
91
-        p.birth_date  = Date.strptime(row['birth_date']) if row['birth_date'].present?
92
         p.save!
85
         p.save!
93
       end
86
       end
94
       result << p
87
       result << p
188
 
181
 
189
   private
182
   private
190
 
183
 
191
-  # Assert that the person's birth date, if any, lies in the past.
192
-  def birth_date_cannot_be_in_future
193
-    errors.add(:birth_date, I18n.t('person.errors.cannot_future')) if birth_date&.future?
194
-  end
195
-
196
   # Explicitly force nil to false in the admin field.
184
   # Explicitly force nil to false in the admin field.
197
   def not_admin_if_nil
185
   def not_admin_if_nil
198
     self.is_admin ||= false
186
     self.is_admin ||= false

+ 0 - 4
app/views/people/_form.html.erb

24
       <%= f.label :email %>
24
       <%= f.label :email %>
25
       <%= f.email_field :email, class: 'form-control' %>
25
       <%= f.email_field :email, class: 'form-control' %>
26
     </div>
26
     </div>
27
-    <div class="form-group">
28
-      <%= f.label :birth_date %>
29
-      <%= f.date_field :birth_date, type: 'date', class: 'form-control' %>
30
-    </div>
31
     <% unless defined? no_admin %>
27
     <% unless defined? no_admin %>
32
       <div class="form-group">
28
       <div class="form-group">
33
         <%= f.check_box :is_admin %>
29
         <%= f.check_box :is_admin %>

+ 0 - 1
app/views/people/show.html.erb

1
 <h2><%= @person.full_name %></h2>
1
 <h2><%= @person.full_name %></h2>
2
 <ul>
2
 <ul>
3
-  <li><%= @person.birth_date %></li>
4
   <li><%= @person.email %></li>
3
   <li><%= @person.email %></li>
5
   <li>AttendanceReminder: <%= @person.send_attendance_reminder.to_s %></li>
4
   <li>AttendanceReminder: <%= @person.send_attendance_reminder.to_s %></li>
6
 </ul>
5
 </ul>

+ 0 - 1
config/locales/aardbei_en.yml

77
         infix: "Infix"
77
         infix: "Infix"
78
         last_name: "Last name"
78
         last_name: "Last name"
79
         email: "Email address"
79
         email: "Email address"
80
-        birth_date: "Date of birth"
81
 
80
 
82
       group:
81
       group:
83
         name: "Name"
82
         name: "Name"

+ 0 - 1
config/locales/translation_nl.yml

79
 
79
 
80
       person:
80
       person:
81
         activities: Activiteiten  #g
81
         activities: Activiteiten  #g
82
-        birth_date: Geboortedatum  #g
83
         email: Emailadres  #g
82
         email: Emailadres  #g
84
         first_name: Voornaam  #g
83
         first_name: Voornaam  #g
85
         groups: Groepen  #g
84
         groups: Groepen  #g

+ 5 - 0
db/migrate/20190203193638_remove_birth_date_from_people.rb

1
+class RemoveBirthDateFromPeople < ActiveRecord::Migration[5.0]
2
+  def change
3
+    remove_column :people, :birth_date, :date
4
+  end
5
+end

+ 1 - 2
db/schema.rb

10
 #
10
 #
11
 # It's strongly recommended that you check this file into your version control system.
11
 # It's strongly recommended that you check this file into your version control system.
12
 
12
 
13
-ActiveRecord::Schema.define(version: 20181104220610) do
13
+ActiveRecord::Schema.define(version: 20190203193638) do
14
 
14
 
15
   create_table "activities", force: :cascade do |t|
15
   create_table "activities", force: :cascade do |t|
16
     t.string   "name"
16
     t.string   "name"
92
     t.string   "first_name"
92
     t.string   "first_name"
93
     t.string   "infix"
93
     t.string   "infix"
94
     t.string   "last_name"
94
     t.string   "last_name"
95
-    t.date     "birth_date"
96
     t.string   "email"
95
     t.string   "email"
97
     t.boolean  "is_admin"
96
     t.boolean  "is_admin"
98
     t.datetime "created_at",                              null: false
97
     t.datetime "created_at",                              null: false

+ 0 - 3
db/seeds.rb

13
   first_name: 'Maarten',
13
   first_name: 'Maarten',
14
   infix: 'van den',
14
   infix: 'van den',
15
   last_name: 'Berg',
15
   last_name: 'Berg',
16
-  birth_date: Faker::Date.between(21.years.ago, Time.zone.today),
17
   email: 'maarten@maartenberg.nl',
16
   email: 'maarten@maartenberg.nl',
18
   is_admin: true
17
   is_admin: true
19
 )
18
 )
29
 Person.create!(
28
 Person.create!(
30
   first_name: 'Henkie',
29
   first_name: 'Henkie',
31
   last_name: 'Gekke',
30
   last_name: 'Gekke',
32
-  birth_date: Faker::Date.between(21.years.ago, Time.zone.today),
33
   email: 'gekkehenkie@maartenberg.nl'
31
   email: 'gekkehenkie@maartenberg.nl'
34
 )
32
 )
35
 
33
 
47
   Person.create!(
45
   Person.create!(
48
     first_name: Faker::Name.first_name,
46
     first_name: Faker::Name.first_name,
49
     last_name: Faker::Name.last_name,
47
     last_name: Faker::Name.last_name,
50
-    birth_date: Faker::Date.between(21.years.ago, Time.zone.today),
51
     email: "testuser#{i}@maartenberg.nl"
48
     email: "testuser#{i}@maartenberg.nl"
52
   )
49
   )
53
 end
50
 end

+ 2 - 2
public/batch_persons.csv

1
-first_name,infix,last_name,birth_date,email
2
-Gekke,,Henkie,1-1-1997,gekkehenkie@maartenberg.nl
1
+first_name,infix,last_name,email
2
+Gekke,,Henkie,gekkehenkie@maartenberg.nl

+ 0 - 2
test/fixtures/people.yml

4
   first_name: MyString
4
   first_name: MyString
5
   infix: MyString
5
   infix: MyString
6
   last_name: MyString
6
   last_name: MyString
7
-  birth_date: 2016-12-07
8
   email: MyString
7
   email: MyString
9
   is_admin: 
8
   is_admin: 
10
 
9
 
12
   first_name: MyString
11
   first_name: MyString
13
   infix: MyString
12
   infix: MyString
14
   last_name: MyString
13
   last_name: MyString
15
-  birth_date: 2016-12-07
16
   email: MyString
14
   email: MyString
17
   is_admin: 
15
   is_admin: