From 329465327cdfbb66220d5cee50d7b83f85cd3eba Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Thu, 27 Jun 2013 14:52:43 -0400 Subject: [PATCH] add Human resource --- .../app/assets/javascripts/humans.js.coffee | 3 +++ .../app/assets/stylesheets/humans.css.scss | 3 +++ .../app/controllers/humans_controller.rb | 2 ++ apps/workbench/app/helpers/humans_helper.rb | 2 ++ apps/workbench/app/models/human.rb | 2 ++ .../config/initializers/inflections.rb | 6 ++++-- apps/workbench/config/routes.rb | 3 +++ apps/workbench/test/fixtures/humans.yml | 11 +++++++++++ .../test/functional/humans_controller_test.rb | 7 +++++++ .../test/unit/helpers/humans_helper_test.rb | 4 ++++ apps/workbench/test/unit/human_test.rb | 7 +++++++ .../api/app/assets/javascripts/humans.js.coffee | 3 +++ .../api/app/assets/stylesheets/humans.css.scss | 3 +++ .../controllers/arvados/v1/humans_controller.rb | 2 ++ services/api/app/helpers/humans_helper.rb | 2 ++ services/api/app/models/human.rb | 10 ++++++++++ services/api/config/initializers/inflections.rb | 2 ++ services/api/config/routes.rb | 2 ++ .../db/migrate/20130627184333_create_humans.rb | 15 +++++++++++++++ services/api/db/schema.rb | 15 ++++++++++++++- services/api/test/fixtures/humans.yml | 17 +++++++++++++++++ .../test/functional/humans_controller_test.rb | 7 +++++++ .../api/test/unit/helpers/humans_helper_test.rb | 4 ++++ services/api/test/unit/human_test.rb | 7 +++++++ 24 files changed, 136 insertions(+), 3 deletions(-) create mode 100644 apps/workbench/app/assets/javascripts/humans.js.coffee create mode 100644 apps/workbench/app/assets/stylesheets/humans.css.scss create mode 100644 apps/workbench/app/controllers/humans_controller.rb create mode 100644 apps/workbench/app/helpers/humans_helper.rb create mode 100644 apps/workbench/app/models/human.rb create mode 100644 apps/workbench/test/fixtures/humans.yml create mode 100644 apps/workbench/test/functional/humans_controller_test.rb create mode 100644 apps/workbench/test/unit/helpers/humans_helper_test.rb create mode 100644 apps/workbench/test/unit/human_test.rb create mode 100644 services/api/app/assets/javascripts/humans.js.coffee create mode 100644 services/api/app/assets/stylesheets/humans.css.scss create mode 100644 services/api/app/controllers/arvados/v1/humans_controller.rb create mode 100644 services/api/app/helpers/humans_helper.rb create mode 100644 services/api/app/models/human.rb create mode 100644 services/api/db/migrate/20130627184333_create_humans.rb create mode 100644 services/api/test/fixtures/humans.yml create mode 100644 services/api/test/functional/humans_controller_test.rb create mode 100644 services/api/test/unit/helpers/humans_helper_test.rb create mode 100644 services/api/test/unit/human_test.rb diff --git a/apps/workbench/app/assets/javascripts/humans.js.coffee b/apps/workbench/app/assets/javascripts/humans.js.coffee new file mode 100644 index 0000000000..761567942f --- /dev/null +++ b/apps/workbench/app/assets/javascripts/humans.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/apps/workbench/app/assets/stylesheets/humans.css.scss b/apps/workbench/app/assets/stylesheets/humans.css.scss new file mode 100644 index 0000000000..f8afcdfeeb --- /dev/null +++ b/apps/workbench/app/assets/stylesheets/humans.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Humans controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/apps/workbench/app/controllers/humans_controller.rb b/apps/workbench/app/controllers/humans_controller.rb new file mode 100644 index 0000000000..e141655951 --- /dev/null +++ b/apps/workbench/app/controllers/humans_controller.rb @@ -0,0 +1,2 @@ +class HumansController < ApplicationController +end diff --git a/apps/workbench/app/helpers/humans_helper.rb b/apps/workbench/app/helpers/humans_helper.rb new file mode 100644 index 0000000000..ca84af0bff --- /dev/null +++ b/apps/workbench/app/helpers/humans_helper.rb @@ -0,0 +1,2 @@ +module HumansHelper +end diff --git a/apps/workbench/app/models/human.rb b/apps/workbench/app/models/human.rb new file mode 100644 index 0000000000..31653bd6c7 --- /dev/null +++ b/apps/workbench/app/models/human.rb @@ -0,0 +1,2 @@ +class Human < ArvadosBase +end diff --git a/apps/workbench/config/initializers/inflections.rb b/apps/workbench/config/initializers/inflections.rb index 15be67b59c..8f744968fc 100644 --- a/apps/workbench/config/initializers/inflections.rb +++ b/apps/workbench/config/initializers/inflections.rb @@ -15,6 +15,8 @@ # end ActiveSupport::Inflector.inflections do |inflect| - inflect.plural /^(specimen)$/i, '\1s' - inflect.singular /^(specimen)s/i, '\1' + inflect.plural /^([Ss]pecimen)$/i, '\1s' + inflect.singular /^([Ss]pecimen)s?/i, '\1' + inflect.plural /^([Hh]uman)$/i, '\1s' + inflect.singular /^([Hh]uman)s?/i, '\1' end diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb index 87e44728e9..f3cd099e7a 100644 --- a/apps/workbench/config/routes.rb +++ b/apps/workbench/config/routes.rb @@ -1,4 +1,7 @@ ArvadosWorkbench::Application.routes.draw do + resources :humans + + resources :traits diff --git a/apps/workbench/test/fixtures/humans.yml b/apps/workbench/test/fixtures/humans.yml new file mode 100644 index 0000000000..c63aac0b60 --- /dev/null +++ b/apps/workbench/test/fixtures/humans.yml @@ -0,0 +1,11 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +# This model initially had no columns defined. If you add columns to the +# model remove the '{}' from the fixture names and add the columns immediately +# below each fixture, per the syntax in the comments below +# +one: {} +# column: value +# +two: {} +# column: value diff --git a/apps/workbench/test/functional/humans_controller_test.rb b/apps/workbench/test/functional/humans_controller_test.rb new file mode 100644 index 0000000000..ae2b79d7e7 --- /dev/null +++ b/apps/workbench/test/functional/humans_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class HumansControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/apps/workbench/test/unit/helpers/humans_helper_test.rb b/apps/workbench/test/unit/helpers/humans_helper_test.rb new file mode 100644 index 0000000000..8c515d64f6 --- /dev/null +++ b/apps/workbench/test/unit/helpers/humans_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class HumansHelperTest < ActionView::TestCase +end diff --git a/apps/workbench/test/unit/human_test.rb b/apps/workbench/test/unit/human_test.rb new file mode 100644 index 0000000000..2863cbf7a2 --- /dev/null +++ b/apps/workbench/test/unit/human_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class HumanTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/services/api/app/assets/javascripts/humans.js.coffee b/services/api/app/assets/javascripts/humans.js.coffee new file mode 100644 index 0000000000..761567942f --- /dev/null +++ b/services/api/app/assets/javascripts/humans.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/services/api/app/assets/stylesheets/humans.css.scss b/services/api/app/assets/stylesheets/humans.css.scss new file mode 100644 index 0000000000..f8afcdfeeb --- /dev/null +++ b/services/api/app/assets/stylesheets/humans.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Humans controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/services/api/app/controllers/arvados/v1/humans_controller.rb b/services/api/app/controllers/arvados/v1/humans_controller.rb new file mode 100644 index 0000000000..61cfe69cf9 --- /dev/null +++ b/services/api/app/controllers/arvados/v1/humans_controller.rb @@ -0,0 +1,2 @@ +class Arvados::V1::HumansController < ApplicationController +end diff --git a/services/api/app/helpers/humans_helper.rb b/services/api/app/helpers/humans_helper.rb new file mode 100644 index 0000000000..ca84af0bff --- /dev/null +++ b/services/api/app/helpers/humans_helper.rb @@ -0,0 +1,2 @@ +module HumansHelper +end diff --git a/services/api/app/models/human.rb b/services/api/app/models/human.rb new file mode 100644 index 0000000000..f031915a8f --- /dev/null +++ b/services/api/app/models/human.rb @@ -0,0 +1,10 @@ +class Human < ArvadosModel + include AssignUuid + include KindAndEtag + include CommonApiTemplate + serialize :properties, Hash + + api_accessible :superuser, :extend => :common do |t| + t.add :properties + end +end diff --git a/services/api/config/initializers/inflections.rb b/services/api/config/initializers/inflections.rb index 719262b36a..79bca3af38 100644 --- a/services/api/config/initializers/inflections.rb +++ b/services/api/config/initializers/inflections.rb @@ -12,4 +12,6 @@ ActiveSupport::Inflector.inflections do |inflect| inflect.plural /^([Ss]pecimen)$/i, '\1s' inflect.singular /^([Ss]pecimen)s?/i, '\1' + inflect.plural /^([Hh]uman)$/i, '\1s' + inflect.singular /^([Hh]uman)s?/i, '\1' end diff --git a/services/api/config/routes.rb b/services/api/config/routes.rb index f50ae5a69b..faeb00b389 100644 --- a/services/api/config/routes.rb +++ b/services/api/config/routes.rb @@ -1,4 +1,5 @@ Server::Application.routes.draw do + resources :humans resources :traits resources :repositories resources :virtual_machines @@ -106,6 +107,7 @@ Server::Application.routes.draw do resources :virtual_machines resources :repositories resources :traits + resources :humans end end diff --git a/services/api/db/migrate/20130627184333_create_humans.rb b/services/api/db/migrate/20130627184333_create_humans.rb new file mode 100644 index 0000000000..5051658f72 --- /dev/null +++ b/services/api/db/migrate/20130627184333_create_humans.rb @@ -0,0 +1,15 @@ +class CreateHumans < ActiveRecord::Migration + def change + create_table :humans do |t| + t.string :uuid, :null => false + t.string :owner, :null => false + t.string :modified_by_client + t.string :modified_by_user + t.datetime :modified_at + t.text :properties + + t.timestamps + end + add_index :humans, :uuid, :unique => true + end +end diff --git a/services/api/db/schema.rb b/services/api/db/schema.rb index 11d1ec8067..34d1763579 100644 --- a/services/api/db/schema.rb +++ b/services/api/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130627154537) do +ActiveRecord::Schema.define(:version => 20130627184333) do create_table "api_client_authorizations", :force => true do |t| t.string "api_token", :null => false @@ -125,6 +125,19 @@ ActiveRecord::Schema.define(:version => 20130627154537) do add_index "groups", ["modified_at"], :name => "index_groups_on_modified_at" add_index "groups", ["uuid"], :name => "index_groups_on_uuid", :unique => true + create_table "humans", :force => true do |t| + t.string "uuid", :null => false + t.string "owner", :null => false + t.string "modified_by_client" + t.string "modified_by_user" + t.datetime "modified_at" + t.text "properties" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "humans", ["uuid"], :name => "index_humans_on_uuid", :unique => true + create_table "job_tasks", :force => true do |t| t.string "uuid" t.string "owner" diff --git a/services/api/test/fixtures/humans.yml b/services/api/test/fixtures/humans.yml new file mode 100644 index 0000000000..e93e9a5ec6 --- /dev/null +++ b/services/api/test/fixtures/humans.yml @@ -0,0 +1,17 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html + +one: + uuid: MyString + owner: MyString + modified_by_client: MyString + modified_by_user: MyString + modified_at: 2013-06-27 14:43:33 + properties: MyText + +two: + uuid: MyString + owner: MyString + modified_by_client: MyString + modified_by_user: MyString + modified_at: 2013-06-27 14:43:33 + properties: MyText diff --git a/services/api/test/functional/humans_controller_test.rb b/services/api/test/functional/humans_controller_test.rb new file mode 100644 index 0000000000..ae2b79d7e7 --- /dev/null +++ b/services/api/test/functional/humans_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class HumansControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/services/api/test/unit/helpers/humans_helper_test.rb b/services/api/test/unit/helpers/humans_helper_test.rb new file mode 100644 index 0000000000..8c515d64f6 --- /dev/null +++ b/services/api/test/unit/helpers/humans_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class HumansHelperTest < ActionView::TestCase +end diff --git a/services/api/test/unit/human_test.rb b/services/api/test/unit/human_test.rb new file mode 100644 index 0000000000..2863cbf7a2 --- /dev/null +++ b/services/api/test/unit/human_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class HumanTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end -- 2.30.2