add Log resource
authorTom Clegg <tom@clinicalfuture.com>
Tue, 22 Jan 2013 20:33:32 +0000 (12:33 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Tue, 22 Jan 2013 20:33:32 +0000 (12:33 -0800)
12 files changed:
app/assets/javascripts/logs.js.coffee [new file with mode: 0644]
app/assets/stylesheets/logs.css.scss [new file with mode: 0644]
app/controllers/orvos/v1/logs_controller.rb [new file with mode: 0644]
app/helpers/logs_helper.rb [new file with mode: 0644]
app/models/log.rb [new file with mode: 0644]
config/routes.rb
db/migrate/20130122201442_create_logs.rb [new file with mode: 0644]
db/schema.rb
test/fixtures/logs.yml [new file with mode: 0644]
test/functional/logs_controller_test.rb [new file with mode: 0644]
test/unit/helpers/logs_helper_test.rb [new file with mode: 0644]
test/unit/log_test.rb [new file with mode: 0644]

diff --git a/app/assets/javascripts/logs.js.coffee b/app/assets/javascripts/logs.js.coffee
new file mode 100644 (file)
index 0000000..7615679
--- /dev/null
@@ -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/app/assets/stylesheets/logs.css.scss b/app/assets/stylesheets/logs.css.scss
new file mode 100644 (file)
index 0000000..4aaccac
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the Logs controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/orvos/v1/logs_controller.rb b/app/controllers/orvos/v1/logs_controller.rb
new file mode 100644 (file)
index 0000000..1860e5d
--- /dev/null
@@ -0,0 +1,2 @@
+class Orvos::V1::LogsController < ApplicationController
+end
diff --git a/app/helpers/logs_helper.rb b/app/helpers/logs_helper.rb
new file mode 100644 (file)
index 0000000..99736f0
--- /dev/null
@@ -0,0 +1,2 @@
+module LogsHelper
+end
diff --git a/app/models/log.rb b/app/models/log.rb
new file mode 100644 (file)
index 0000000..3b2af89
--- /dev/null
@@ -0,0 +1,15 @@
+class Log < ActiveRecord::Base
+  include AssignUuid
+  include KindAndEtag
+  include CommonApiTemplate
+  serialize :info, Hash
+
+  api_accessible :superuser, :extend => :common do |t|
+    t.add :object_kind
+    t.add :object_uuid
+    t.add :event_at
+    t.add :event_type
+    t.add :summary
+    t.add :info
+  end
+end
index 9f313b9d5abdb29fb5d84660390e3dc4e33bcaeb..d0e014b940cae2dddf9f40ee562e94f55fa3167f 100644 (file)
@@ -1,4 +1,6 @@
 Server::Application.routes.draw do
+  resources :logs
+
   resources :projects
 
   resources :specimens
diff --git a/db/migrate/20130122201442_create_logs.rb b/db/migrate/20130122201442_create_logs.rb
new file mode 100644 (file)
index 0000000..b3122bd
--- /dev/null
@@ -0,0 +1,28 @@
+class CreateLogs < ActiveRecord::Migration
+  def up
+    create_table :logs do |t|
+      t.string :uuid
+      t.string :created_by_client
+      t.string :created_by_user
+      t.string :modified_by_client
+      t.string :modified_by_user
+      t.string :object_kind
+      t.string :object_uuid
+      t.datetime :event_at
+      t.string :event_type
+      t.text :summary
+      t.text :info
+
+      t.timestamps
+    end
+    add_index :logs, :uuid, :unique => true
+    add_index :logs, :object_kind
+    add_index :logs, :object_uuid
+    add_index :logs, :event_type
+    add_index :logs, :event_at
+    add_index :logs, :summary
+  end
+
+  def down
+    drop_table :logs  end
+end
index 996ac186441b0715dec47e49384fca96c2c3523d..71a06b2f0bcf936abc0890423356ec3c9babafee 100644 (file)
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20130118002239) do
+ActiveRecord::Schema.define(:version => 20130122201442) do
 
   create_table "collections", :force => true do |t|
     t.string   "locator"
@@ -33,6 +33,29 @@ ActiveRecord::Schema.define(:version => 20130118002239) do
 
   add_index "collections", ["uuid"], :name => "index_collections_on_uuid", :unique => true
 
+  create_table "logs", :force => true do |t|
+    t.string   "uuid"
+    t.string   "created_by_client"
+    t.string   "created_by_user"
+    t.string   "modified_by_client"
+    t.string   "modified_by_user"
+    t.string   "object_kind"
+    t.string   "object_uuid"
+    t.datetime "event_at"
+    t.string   "event_type"
+    t.text     "summary"
+    t.text     "info"
+    t.datetime "created_at"
+    t.datetime "updated_at"
+  end
+
+  add_index "logs", ["event_at"], :name => "index_logs_on_event_at"
+  add_index "logs", ["event_type"], :name => "index_logs_on_event_type"
+  add_index "logs", ["object_kind"], :name => "index_logs_on_object_kind"
+  add_index "logs", ["object_uuid"], :name => "index_logs_on_object_uuid"
+  add_index "logs", ["summary"], :name => "index_logs_on_summary"
+  add_index "logs", ["uuid"], :name => "index_logs_on_uuid", :unique => true
+
   create_table "metadata", :force => true do |t|
     t.string   "uuid"
     t.string   "created_by_client"
diff --git a/test/fixtures/logs.yml b/test/fixtures/logs.yml
new file mode 100644 (file)
index 0000000..c892854
--- /dev/null
@@ -0,0 +1,27 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+  uuid: MyString
+  created_by_client: MyString
+  created_by_user: MyString
+  modified_by_client: MyString
+  modified_by_user: MyString
+  object_kind: MyString
+  object_uuid: MyString
+  event_at: 2013-01-22 12:14:42
+  event_type: MyString
+  summary: MyText
+  info: MyText
+
+two:
+  uuid: MyString
+  created_by_client: MyString
+  created_by_user: MyString
+  modified_by_client: MyString
+  modified_by_user: MyString
+  object_kind: MyString
+  object_uuid: MyString
+  event_at: 2013-01-22 12:14:42
+  event_type: MyString
+  summary: MyText
+  info: MyText
diff --git a/test/functional/logs_controller_test.rb b/test/functional/logs_controller_test.rb
new file mode 100644 (file)
index 0000000..bab4469
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class LogsControllerTest < ActionController::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end
diff --git a/test/unit/helpers/logs_helper_test.rb b/test/unit/helpers/logs_helper_test.rb
new file mode 100644 (file)
index 0000000..c165554
--- /dev/null
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class LogsHelperTest < ActionView::TestCase
+end
diff --git a/test/unit/log_test.rb b/test/unit/log_test.rb
new file mode 100644 (file)
index 0000000..f2afee2
--- /dev/null
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class LogTest < ActiveSupport::TestCase
+  # test "the truth" do
+  #   assert true
+  # end
+end