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,6 +151,6 @@ class MembersController < ApplicationController
151 151
   # through.  Note: differs from the ones in PeopleController because
152 152
   # creating admins is not allowed.
153 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 155
   end
156 156
 end

+ 1 - 1
app/controllers/people_controller.rb

@@ -108,6 +108,6 @@ class PeopleController < ApplicationController
108 108
 
109 109
   # Never trust parameters from the scary internet, only allow the white list through.
110 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 112
   end
113 113
 end

+ 0 - 12
app/models/person.rb

@@ -17,10 +17,6 @@ class Person < ApplicationRecord
17 17
   #   @return [String]
18 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 20
   # @!attribute email
25 21
   #   @return [String]
26 22
   #     the person's email address.
@@ -47,8 +43,6 @@ class Person < ApplicationRecord
47 43
   validates :first_name, presence: true
48 44
   validates :last_name, presence: true
49 45
 
50
-  validate :birth_date_cannot_be_in_future
51
-
52 46
   before_validation :not_admin_if_nil
53 47
   before_save :update_user_email, if: :email_changed?
54 48
 
@@ -88,7 +82,6 @@ class Person < ApplicationRecord
88 82
         p.infix       = row['infix']
89 83
         p.last_name   = row['last_name']
90 84
         p.email       = row['email']
91
-        p.birth_date  = Date.strptime(row['birth_date']) if row['birth_date'].present?
92 85
         p.save!
93 86
       end
94 87
       result << p
@@ -188,11 +181,6 @@ class Person < ApplicationRecord
188 181
 
189 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 184
   # Explicitly force nil to false in the admin field.
197 185
   def not_admin_if_nil
198 186
     self.is_admin ||= false

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

@@ -24,10 +24,6 @@
24 24
       <%= f.label :email %>
25 25
       <%= f.email_field :email, class: 'form-control' %>
26 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 27
     <% unless defined? no_admin %>
32 28
       <div class="form-group">
33 29
         <%= f.check_box :is_admin %>

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

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

+ 0 - 1
config/locales/aardbei_en.yml

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

+ 0 - 1
config/locales/translation_nl.yml

@@ -79,7 +79,6 @@ nl:
79 79
 
80 80
       person:
81 81
         activities: Activiteiten  #g
82
-        birth_date: Geboortedatum  #g
83 82
         email: Emailadres  #g
84 83
         first_name: Voornaam  #g
85 84
         groups: Groepen  #g

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

@@ -0,0 +1,5 @@
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,7 +10,7 @@
10 10
 #
11 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 15
   create_table "activities", force: :cascade do |t|
16 16
     t.string   "name"
@@ -92,7 +92,6 @@ ActiveRecord::Schema.define(version: 20181104220610) do
92 92
     t.string   "first_name"
93 93
     t.string   "infix"
94 94
     t.string   "last_name"
95
-    t.date     "birth_date"
96 95
     t.string   "email"
97 96
     t.boolean  "is_admin"
98 97
     t.datetime "created_at",                              null: false

+ 0 - 3
db/seeds.rb

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

+ 2 - 2
public/batch_persons.csv

@@ -1,2 +1,2 @@
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,7 +4,6 @@ one:
4 4
   first_name: MyString
5 5
   infix: MyString
6 6
   last_name: MyString
7
-  birth_date: 2016-12-07
8 7
   email: MyString
9 8
   is_admin: 
10 9
 
@@ -12,6 +11,5 @@ two:
12 11
   first_name: MyString
13 12
   infix: MyString
14 13
   last_name: MyString
15
-  birth_date: 2016-12-07
16 14
   email: MyString
17 15
   is_admin: