Skip to content
This repository was archived by the owner on Mar 9, 2020. It is now read-only.

Commit be39fb0

Browse files
committed
Update CreatePeople migration to contain the basic data fields
1 parent d109593 commit be39fb0

5 files changed

Lines changed: 209 additions & 10 deletions

File tree

app/controllers/people_controller.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ def show
1919

2020
private
2121
def person_params
22-
params.require(:person).permit(:name, :email, :password, :password_confirmation)
22+
params.require(:person).permit(:login, :email, :password,
23+
:password_confirmation, :first_name, :middle_name, :last_name, :ssn,
24+
:birthdate, :address_line_1, :address_line_2, :address_line_3,
25+
:telephone_mobile, :telephone_office, :telephone_private,
26+
:personnel_number, :first_work_day, :working_hours_total,
27+
:working_hours_per_day, :holidays, :holidays_left, :hours,
28+
:overtime_hours, :public_job_description, :private_notes)
2329
end
2430
end

app/views/people/new.html.erb

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<% end %>
1515

1616
<p>
17-
<%= f.label :name %><br>
18-
<%= f.text_field :name %>
17+
<%= f.label :login %><br>
18+
<%= f.text_field :login %>
1919
</p>
2020

2121
<p>
@@ -33,6 +33,111 @@
3333
<%= f.password_field :password_confirmation %>
3434
</p>
3535

36+
<p>
37+
<%= f.label :first_name %><br>
38+
<%= f.text_field :first_name %>
39+
</p>
40+
41+
<p>
42+
<%= f.label :middle_name %><br>
43+
<%= f.text_field :middle_name %>
44+
</p>
45+
46+
<p>
47+
<%= f.label :last_name %><br>
48+
<%= f.text_field :last_name %>
49+
</p>
50+
51+
<p>
52+
<%= f.label :ssn %><br>
53+
<%= f.text_field :ssn %>
54+
</p>
55+
56+
<p>
57+
<%= f.label :birthdate %><br>
58+
<%= f.date_field :birthdate %>
59+
</p>
60+
61+
<p>
62+
<%= f.label :address_line_1 %><br>
63+
<%= f.text_field :address_line_1 %>
64+
</p>
65+
66+
<p>
67+
<%= f.label :address_line_2 %><br>
68+
<%= f.text_field :address_line_2 %>
69+
</p>
70+
71+
<p>
72+
<%= f.label :address_line_3 %><br>
73+
<%= f.text_field :address_line_3 %>
74+
</p>
75+
76+
<p>
77+
<%= f.label :telephone_mobile %><br>
78+
<%= f.text_field :telephone_mobile %>
79+
</p>
80+
81+
<p>
82+
<%= f.label :telephone_office %><br>
83+
<%= f.text_field :telephone_office %>
84+
</p>
85+
86+
<p>
87+
<%= f.label :telephone_private %><br>
88+
<%= f.text_field :telephone_private %>
89+
</p>
90+
91+
<p>
92+
<%= f.label :personnel_number %><br>
93+
<%= f.text_field :personnel_number %>
94+
</p>
95+
96+
<p>
97+
<%= f.label :first_work_day %><br>
98+
<%= f.date_field :first_work_day %>
99+
</p>
100+
101+
<p>
102+
<%= f.label :working_hours_total %><br>
103+
<%= f.text_field :working_hours_total %>
104+
</p>
105+
106+
<p>
107+
<%= f.label :working_hours_per_day %><br>
108+
<%= f.text_field :working_hours_per_day %>
109+
</p>
110+
111+
<p>
112+
<%= f.label :holidays %><br>
113+
<%= f.text_field :holidays %>
114+
</p>
115+
116+
<p>
117+
<%= f.label :holidays_left %><br>
118+
<%= f.text_field :holidays_left %>
119+
</p>
120+
121+
<p>
122+
<%= f.label :hours %><br>
123+
<%= f.text_field :hours %>
124+
</p>
125+
126+
<p>
127+
<%= f.label :overtime_hours %><br>
128+
<%= f.text_field :overtime_hours %>
129+
</p>
130+
131+
<p>
132+
<%= f.label :public_job_description %><br>
133+
<%= f.text_area :public_job_description %>
134+
</p>
135+
136+
<p>
137+
<%= f.label :private_notes %><br>
138+
<%= f.text_area :private_notes %>
139+
</p>
140+
36141
<p>
37142
<%= f.submit %>
38143
</p>

db/migrate/20140726092933_create_people.rb

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,41 @@
11
class CreatePeople < ActiveRecord::Migration
22
def change
33
create_table :people do |t|
4-
t.string :name
4+
# sorcery authentication data
5+
t.string :login, :null => false
56
t.string :email, :null => false
67
t.string :crypted_password, :null => false
78
t.string :salt, :null => false
89

10+
# basic data
11+
t.string :first_name, :null => false
12+
t.string :middle_name
13+
t.string :last_name, :null => false
14+
15+
t.string :ssn
16+
t.date :birthdate
17+
18+
t.string :address_line_1
19+
t.string :address_line_2
20+
t.string :address_line_3
21+
22+
t.string :telephone_mobile
23+
t.string :telephone_office
24+
t.string :telephone_private
25+
26+
# personnel data
27+
t.string :personnel_number # may be empty when not yet assigned
28+
t.date :first_work_day
29+
t.float :working_hours_total, :null => false
30+
t.float :working_hours_per_day, :null => false
31+
t.integer :holidays, :null => false
32+
t.integer :holidays_left, :null => false
33+
t.float :hours, :null => false, :default => 0
34+
t.float :overtime_hours, :null => false, :default => 0
35+
36+
t.text :public_job_description # visible for all
37+
t.text :private_notes # only visible for HR
38+
939
t.timestamps
1040
end
1141

db/schema.rb

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,31 @@
1414
ActiveRecord::Schema.define(version: 20140726092933) do
1515

1616
create_table "people", force: true do |t|
17-
t.string "name"
18-
t.string "email", null: false
19-
t.string "crypted_password", null: false
20-
t.string "salt", null: false
17+
t.string "login", null: false
18+
t.string "email", null: false
19+
t.string "crypted_password", null: false
20+
t.string "salt", null: false
21+
t.string "first_name", null: false
22+
t.string "middle_name"
23+
t.string "last_name", null: false
24+
t.string "ssn"
25+
t.date "birthdate"
26+
t.string "address_line_1"
27+
t.string "address_line_2"
28+
t.string "address_line_3"
29+
t.string "telephone_mobile"
30+
t.string "telephone_office"
31+
t.string "telephone_private"
32+
t.string "personnel_number"
33+
t.date "first_work_day"
34+
t.float "working_hours_total", null: false
35+
t.float "working_hours_per_day", null: false
36+
t.integer "holidays", null: false
37+
t.integer "holidays_left", null: false
38+
t.float "hours", default: 0.0, null: false
39+
t.float "overtime_hours", default: 0.0, null: false
40+
t.text "public_job_description"
41+
t.text "private_notes"
2142
t.datetime "created_at"
2243
t.datetime "updated_at"
2344
end

test/fixtures/people.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,50 @@
11
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
22

33
one:
4-
name: Test One
4+
login: test_one
55
email: test1@example.com
66
crypted_password: ''
77
salt: ''
8+
first_name: One
9+
middle_name: J
10+
last_name: Simpson
11+
ssn: 123456789
12+
birthdate: 1970-01-01
13+
address_line_1: At Home
14+
address_line_2: 1234 HOME
15+
telephone_mobile: +43664664664
16+
telephone_office: 2000
17+
telephone_private: +43123456789
18+
personnel_number: 123
19+
first_work_day: 2000-01-01
20+
working_hours_total: 40
21+
working_hours_per_day: 8
22+
holidays: 25
23+
holidays_left: 10
24+
hours: 40
25+
overtime_hours: 0
26+
public_job_description: Should work
27+
private_notes: nice
828

929
two:
10-
name: Test Two
30+
login: test_two
1131
email: test2@example.com
1232
crypted_password: ''
1333
salt: ''
34+
first_name: Old
35+
last_name: Shatterhand
36+
ssn: 987654312
37+
birthdate: 1978-03-03
38+
address_line_1: Somewhere
39+
address_line_2: 4321 ELSE
40+
telephone_mobile: +312314
41+
telephone_office: 3000
42+
personnel_number: 234
43+
first_work_day: 2008-04-01
44+
working_hours_total: 20
45+
working_hours_per_day: 8
46+
holidays: 20
47+
holidays_left: 20
48+
hours: 20
49+
overtime_hours: 30
50+
public_job_description: Should work hard

0 commit comments

Comments
 (0)