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

Commit

Permalink
Update CreatePeople migration to contain the basic data fields
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidS committed Jul 27, 2014
1 parent d109593 commit be39fb0
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 10 deletions.
8 changes: 7 additions & 1 deletion app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ def show

private
def person_params
params.require(:person).permit(:name, :email, :password, :password_confirmation)
params.require(:person).permit(:login, :email, :password,
:password_confirmation, :first_name, :middle_name, :last_name, :ssn,
:birthdate, :address_line_1, :address_line_2, :address_line_3,
:telephone_mobile, :telephone_office, :telephone_private,
:personnel_number, :first_work_day, :working_hours_total,
:working_hours_per_day, :holidays, :holidays_left, :hours,
:overtime_hours, :public_job_description, :private_notes)
end
end
109 changes: 107 additions & 2 deletions app/views/people/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<% end %>

<p>
<%= f.label :name %><br>
<%= f.text_field :name %>
<%= f.label :login %><br>
<%= f.text_field :login %>
</p>

<p>
Expand All @@ -33,6 +33,111 @@
<%= f.password_field :password_confirmation %>
</p>

<p>
<%= f.label :first_name %><br>
<%= f.text_field :first_name %>
</p>

<p>
<%= f.label :middle_name %><br>
<%= f.text_field :middle_name %>
</p>

<p>
<%= f.label :last_name %><br>
<%= f.text_field :last_name %>
</p>

<p>
<%= f.label :ssn %><br>
<%= f.text_field :ssn %>
</p>

<p>
<%= f.label :birthdate %><br>
<%= f.date_field :birthdate %>
</p>

<p>
<%= f.label :address_line_1 %><br>
<%= f.text_field :address_line_1 %>
</p>

<p>
<%= f.label :address_line_2 %><br>
<%= f.text_field :address_line_2 %>
</p>

<p>
<%= f.label :address_line_3 %><br>
<%= f.text_field :address_line_3 %>
</p>

<p>
<%= f.label :telephone_mobile %><br>
<%= f.text_field :telephone_mobile %>
</p>

<p>
<%= f.label :telephone_office %><br>
<%= f.text_field :telephone_office %>
</p>

<p>
<%= f.label :telephone_private %><br>
<%= f.text_field :telephone_private %>
</p>

<p>
<%= f.label :personnel_number %><br>
<%= f.text_field :personnel_number %>
</p>

<p>
<%= f.label :first_work_day %><br>
<%= f.date_field :first_work_day %>
</p>

<p>
<%= f.label :working_hours_total %><br>
<%= f.text_field :working_hours_total %>
</p>

<p>
<%= f.label :working_hours_per_day %><br>
<%= f.text_field :working_hours_per_day %>
</p>

<p>
<%= f.label :holidays %><br>
<%= f.text_field :holidays %>
</p>

<p>
<%= f.label :holidays_left %><br>
<%= f.text_field :holidays_left %>
</p>

<p>
<%= f.label :hours %><br>
<%= f.text_field :hours %>
</p>

<p>
<%= f.label :overtime_hours %><br>
<%= f.text_field :overtime_hours %>
</p>

<p>
<%= f.label :public_job_description %><br>
<%= f.text_area :public_job_description %>
</p>

<p>
<%= f.label :private_notes %><br>
<%= f.text_area :private_notes %>
</p>

<p>
<%= f.submit %>
</p>
Expand Down
32 changes: 31 additions & 1 deletion db/migrate/20140726092933_create_people.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
class CreatePeople < ActiveRecord::Migration
def change
create_table :people do |t|
t.string :name
# sorcery authentication data
t.string :login, :null => false
t.string :email, :null => false
t.string :crypted_password, :null => false
t.string :salt, :null => false

# basic data
t.string :first_name, :null => false
t.string :middle_name
t.string :last_name, :null => false

t.string :ssn
t.date :birthdate

t.string :address_line_1
t.string :address_line_2
t.string :address_line_3

t.string :telephone_mobile
t.string :telephone_office
t.string :telephone_private

# personnel data
t.string :personnel_number # may be empty when not yet assigned
t.date :first_work_day
t.float :working_hours_total, :null => false
t.float :working_hours_per_day, :null => false
t.integer :holidays, :null => false
t.integer :holidays_left, :null => false
t.float :hours, :null => false, :default => 0
t.float :overtime_hours, :null => false, :default => 0

t.text :public_job_description # visible for all
t.text :private_notes # only visible for HR

t.timestamps
end

Expand Down
29 changes: 25 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,31 @@
ActiveRecord::Schema.define(version: 20140726092933) do

create_table "people", force: true do |t|
t.string "name"
t.string "email", null: false
t.string "crypted_password", null: false
t.string "salt", null: false
t.string "login", null: false
t.string "email", null: false
t.string "crypted_password", null: false
t.string "salt", null: false
t.string "first_name", null: false
t.string "middle_name"
t.string "last_name", null: false
t.string "ssn"
t.date "birthdate"
t.string "address_line_1"
t.string "address_line_2"
t.string "address_line_3"
t.string "telephone_mobile"
t.string "telephone_office"
t.string "telephone_private"
t.string "personnel_number"
t.date "first_work_day"
t.float "working_hours_total", null: false
t.float "working_hours_per_day", null: false
t.integer "holidays", null: false
t.integer "holidays_left", null: false
t.float "hours", default: 0.0, null: false
t.float "overtime_hours", default: 0.0, null: false
t.text "public_job_description"
t.text "private_notes"
t.datetime "created_at"
t.datetime "updated_at"
end
Expand Down
41 changes: 39 additions & 2 deletions test/fixtures/people.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,50 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
name: Test One
login: test_one
email: test1@example.com
crypted_password: ''
salt: ''
first_name: One
middle_name: J
last_name: Simpson
ssn: 123456789
birthdate: 1970-01-01
address_line_1: At Home
address_line_2: 1234 HOME
telephone_mobile: +43664664664
telephone_office: 2000
telephone_private: +43123456789
personnel_number: 123
first_work_day: 2000-01-01
working_hours_total: 40
working_hours_per_day: 8
holidays: 25
holidays_left: 10
hours: 40
overtime_hours: 0
public_job_description: Should work
private_notes: nice

two:
name: Test Two
login: test_two
email: test2@example.com
crypted_password: ''
salt: ''
first_name: Old
last_name: Shatterhand
ssn: 987654312
birthdate: 1978-03-03
address_line_1: Somewhere
address_line_2: 4321 ELSE
telephone_mobile: +312314
telephone_office: 3000
personnel_number: 234
first_work_day: 2008-04-01
working_hours_total: 20
working_hours_per_day: 8
holidays: 20
holidays_left: 20
hours: 20
overtime_hours: 30
public_job_description: Should work hard

0 comments on commit be39fb0

Please sign in to comment.