app port from old version
This commit is contained in:
parent
cb7e47a466
commit
f8c03d6f5c
2
Gemfile
2
Gemfile
@ -33,5 +33,7 @@ group :development, :test do
|
|||||||
gem 'guard'
|
gem 'guard'
|
||||||
gem 'guard-rubocop'
|
gem 'guard-rubocop'
|
||||||
gem 'guard-minitest'
|
gem 'guard-minitest'
|
||||||
|
gem 'guard-livereload'
|
||||||
|
gem 'rack-livereload'
|
||||||
gem 'minitest-reporters'
|
gem 'minitest-reporters'
|
||||||
end
|
end
|
||||||
|
12
Gemfile.lock
12
Gemfile.lock
@ -59,6 +59,9 @@ GEM
|
|||||||
columnize (0.9.0)
|
columnize (0.9.0)
|
||||||
daemons (1.2.3)
|
daemons (1.2.3)
|
||||||
debug_inspector (0.0.2)
|
debug_inspector (0.0.2)
|
||||||
|
em-websocket (0.5.1)
|
||||||
|
eventmachine (>= 0.12.9)
|
||||||
|
http_parser.rb (~> 0.6.0)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
eventmachine (1.0.8)
|
eventmachine (1.0.8)
|
||||||
execjs (2.6.0)
|
execjs (2.6.0)
|
||||||
@ -76,6 +79,10 @@ GEM
|
|||||||
shellany (~> 0.0)
|
shellany (~> 0.0)
|
||||||
thor (>= 0.18.1)
|
thor (>= 0.18.1)
|
||||||
guard-compat (1.2.1)
|
guard-compat (1.2.1)
|
||||||
|
guard-livereload (2.4.0)
|
||||||
|
em-websocket (~> 0.5)
|
||||||
|
guard (~> 2.8)
|
||||||
|
multi_json (~> 1.8)
|
||||||
guard-minitest (2.4.4)
|
guard-minitest (2.4.4)
|
||||||
guard-compat (~> 1.2)
|
guard-compat (~> 1.2)
|
||||||
minitest (>= 3.0)
|
minitest (>= 3.0)
|
||||||
@ -95,6 +102,7 @@ GEM
|
|||||||
haml (~> 4.0.0)
|
haml (~> 4.0.0)
|
||||||
nokogiri (~> 1.6.0)
|
nokogiri (~> 1.6.0)
|
||||||
ruby_parser (~> 3.5)
|
ruby_parser (~> 3.5)
|
||||||
|
http_parser.rb (0.6.0)
|
||||||
i18n (0.7.0)
|
i18n (0.7.0)
|
||||||
jquery-rails (4.0.5)
|
jquery-rails (4.0.5)
|
||||||
rails-dom-testing (~> 1.0)
|
rails-dom-testing (~> 1.0)
|
||||||
@ -140,6 +148,8 @@ GEM
|
|||||||
pry-rails (0.3.4)
|
pry-rails (0.3.4)
|
||||||
pry (>= 0.9.10)
|
pry (>= 0.9.10)
|
||||||
rack (1.6.4)
|
rack (1.6.4)
|
||||||
|
rack-livereload (0.3.16)
|
||||||
|
rack
|
||||||
rack-test (0.6.3)
|
rack-test (0.6.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (4.2.4)
|
rails (4.2.4)
|
||||||
@ -231,6 +241,7 @@ DEPENDENCIES
|
|||||||
bcrypt (~> 3.1.7)
|
bcrypt (~> 3.1.7)
|
||||||
binding_of_caller
|
binding_of_caller
|
||||||
guard
|
guard
|
||||||
|
guard-livereload
|
||||||
guard-minitest
|
guard-minitest
|
||||||
guard-rubocop
|
guard-rubocop
|
||||||
haml-rails (~> 0.9)
|
haml-rails (~> 0.9)
|
||||||
@ -240,6 +251,7 @@ DEPENDENCIES
|
|||||||
mysql2 (~> 0.3.20)
|
mysql2 (~> 0.3.20)
|
||||||
pry-byebug
|
pry-byebug
|
||||||
pry-rails
|
pry-rails
|
||||||
|
rack-livereload
|
||||||
rails (~> 4.2.4)
|
rails (~> 4.2.4)
|
||||||
responders (~> 2.1.0)
|
responders (~> 2.1.0)
|
||||||
rubocop
|
rubocop
|
||||||
|
12
Guardfile
12
Guardfile
@ -27,3 +27,15 @@ guard :minitest do
|
|||||||
watch(%r{^app/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
|
watch(%r{^app/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
|
||||||
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/lib/#{m[1]}#{m[2]}_test.rb" }
|
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/lib/#{m[1]}#{m[2]}_test.rb" }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
guard 'livereload' do
|
||||||
|
watch(%r{app/views/.+\.(erb|haml|slim)$})
|
||||||
|
watch(%r{app/helpers/.+\.rb})
|
||||||
|
watch(%r{public/.+\.(css|js|html)})
|
||||||
|
watch(%r{config/locales/.+\.yml})
|
||||||
|
|
||||||
|
# Rails Assets Pipeline
|
||||||
|
watch(%r{(app|vendor)(/assets/\w+/(.+\.(css|js|html|png|jpg))).*}) do |m|
|
||||||
|
"/assets/#{m[3]}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -2,4 +2,6 @@ class ApplicationController < ActionController::Base
|
|||||||
# Prevent CSRF attacks by raising an exception.
|
# Prevent CSRF attacks by raising an exception.
|
||||||
# For APIs, you may want to use :null_session instead.
|
# For APIs, you may want to use :null_session instead.
|
||||||
protect_from_forgery with: :exception
|
protect_from_forgery with: :exception
|
||||||
|
|
||||||
|
respond_to :html, :json
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
class ChildrenController < ApplicationController
|
class ChildrenController < ApplicationController
|
||||||
|
def index
|
||||||
|
@children = Child.all.order(:last_name, :first_name)
|
||||||
|
respond_with @children
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
class StaffController < ApplicationController
|
class StaffController < ApplicationController
|
||||||
|
def index
|
||||||
|
@staff = Person.staff
|
||||||
|
respond_with @staff
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
|
def index
|
||||||
|
@users = Person.admins
|
||||||
|
respond_with @users
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
11
app/models/child.rb
Normal file
11
app/models/child.rb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
class Child < ActiveRecord::Base
|
||||||
|
has_many :parenthoods
|
||||||
|
has_many :parents, through: :parenthoods, source: :person
|
||||||
|
|
||||||
|
validates :first_name, presence: true
|
||||||
|
validates :last_name, presence: true
|
||||||
|
|
||||||
|
def name
|
||||||
|
"#{first_name} #{last_name}"
|
||||||
|
end
|
||||||
|
end
|
4
app/models/parenthood.rb
Normal file
4
app/models/parenthood.rb
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
class Parenthood < ActiveRecord::Base
|
||||||
|
belongs_to :person
|
||||||
|
belongs_to :child
|
||||||
|
end
|
25
app/models/person.rb
Normal file
25
app/models/person.rb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
class Person < ActiveRecord::Base
|
||||||
|
has_many :parenthoods
|
||||||
|
has_many :children, through: :parenthoods
|
||||||
|
|
||||||
|
validates :first_name, presence: true
|
||||||
|
validates :last_name, presence: true
|
||||||
|
|
||||||
|
scope :with_name, lambda { |name|
|
||||||
|
where("concat(first_name, ' ', last_name) RLIKE ?", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
scope :just_parents, lambda {
|
||||||
|
joins(:children)
|
||||||
|
.order(:first_name)
|
||||||
|
.uniq
|
||||||
|
}
|
||||||
|
|
||||||
|
scope :staff, -> { where(staff: true) }
|
||||||
|
|
||||||
|
scope :admins, -> { where(admin: true) }
|
||||||
|
|
||||||
|
def name
|
||||||
|
"#{first_name} #{last_name}"
|
||||||
|
end
|
||||||
|
end
|
8
app/views/children/index.haml
Normal file
8
app/views/children/index.haml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
%h1 Children
|
||||||
|
|
||||||
|
- @children.each do |child|
|
||||||
|
%ul
|
||||||
|
%li= child.name
|
||||||
|
%ul
|
||||||
|
- child.parents.each do |parent|
|
||||||
|
%li #{parent.name}: #{number_to_phone parent.phone}
|
11
app/views/parents/index.haml
Normal file
11
app/views/parents/index.haml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
%h1 Parents
|
||||||
|
|
||||||
|
- @parents.each do |parent|
|
||||||
|
%ul
|
||||||
|
%li= parent.name
|
||||||
|
%li= number_to_phone parent.phone
|
||||||
|
%li= mail_to parent.email
|
||||||
|
%li Children:
|
||||||
|
%ul
|
||||||
|
- parent.children.each do |child|
|
||||||
|
%li= child.name
|
4
app/views/staff/index.haml
Normal file
4
app/views/staff/index.haml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
%h1 Staff
|
||||||
|
%ul
|
||||||
|
- @staff.each do |staff|
|
||||||
|
%li= staff.name
|
5
app/views/users/index.haml
Normal file
5
app/views/users/index.haml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
%h1 Users
|
||||||
|
|
||||||
|
%ul
|
||||||
|
- @users.each do |user|
|
||||||
|
%li= user.name
|
@ -1,4 +1,4 @@
|
|||||||
a--
|
---
|
||||||
default: &default
|
default: &default
|
||||||
adapter: mysql2
|
adapter: mysql2
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
|
@ -38,4 +38,7 @@ Rails.application.configure do
|
|||||||
|
|
||||||
# Raises error for missing translations
|
# Raises error for missing translations
|
||||||
# config.action_view.raise_on_missing_translations = true
|
# config.action_view.raise_on_missing_translations = true
|
||||||
|
|
||||||
|
# Add Rack::LiveReload to the bottom of the middleware stack with the default options.
|
||||||
|
config.middleware.insert_after ActionDispatch::Static, Rack::LiveReload
|
||||||
end
|
end
|
||||||
|
50
db/schema.rb
Normal file
50
db/schema.rb
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# encoding: UTF-8
|
||||||
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
|
#
|
||||||
|
# Note that this schema.rb definition is the authoritative source for your
|
||||||
|
# database schema. If you need to create the application database on another
|
||||||
|
# system, you should be using db:schema:load, not running all the migrations
|
||||||
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||||
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||||
|
#
|
||||||
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
|
ActiveRecord::Schema.define(version: 20150913220116) do
|
||||||
|
|
||||||
|
create_table "children", force: :cascade do |t|
|
||||||
|
t.string "first_name", limit: 255
|
||||||
|
t.string "last_name", limit: 255
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "pages", force: :cascade do |t|
|
||||||
|
t.integer "user_id", limit: 4
|
||||||
|
t.integer "person_id", limit: 4
|
||||||
|
t.string "phone", limit: 255
|
||||||
|
t.string "to", limit: 255
|
||||||
|
t.string "message", limit: 255
|
||||||
|
t.string "status", limit: 255
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "parenthoods", force: :cascade do |t|
|
||||||
|
t.integer "person_id", limit: 4
|
||||||
|
t.integer "child_id", limit: 4
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "parenthoods", ["person_id", "child_id"], name: "parentship", using: :btree
|
||||||
|
|
||||||
|
create_table "people", force: :cascade do |t|
|
||||||
|
t.string "first_name", limit: 255
|
||||||
|
t.string "last_name", limit: 255
|
||||||
|
t.string "phone", limit: 255
|
||||||
|
t.string "email", limit: 255
|
||||||
|
t.boolean "admin"
|
||||||
|
t.boolean "staff"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "people", ["phone"], name: "index_people_on_phone", using: :btree
|
||||||
|
|
||||||
|
end
|
@ -2,7 +2,7 @@ require 'test_helper'
|
|||||||
|
|
||||||
class ParentsControllerTest < ActionController::TestCase
|
class ParentsControllerTest < ActionController::TestCase
|
||||||
def test_parents
|
def test_parents
|
||||||
xhr :get, :index
|
get :index
|
||||||
assert response.ok?
|
assert response.ok?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require File.expand_path '../../test_helper.rb', __FILE__
|
require 'test_helper'
|
||||||
|
|
||||||
class SecretsTest < ActiveSupport::TestCase
|
class SecretsTest < ActiveSupport::TestCase
|
||||||
def test_sanity
|
# def test_sanity
|
||||||
assert Secrets
|
# assert Secrets
|
||||||
end
|
# end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user