adds step tiny_mce asset relation

This commit is contained in:
zmagod 2017-04-19 17:22:57 +02:00
parent 37be04c09c
commit 0757563d02
6 changed files with 64 additions and 29 deletions

View file

@ -5,12 +5,13 @@ class TinyMceAssetsController < ApplicationController
image = Asset.create(file: params[:file],
created_by: current_user,
team: current_team)
image.file.reprocess_without_delay!(:full)
image.file.reprocess_without_delay!(:original)
byebug
render json: {
image: {
url: view_context.image_url(image.url(:full))
url: view_context.image_url(image.url(:original))
}
}, content_type: 'text/html'
end
end

View file

@ -0,0 +1,4 @@
class StepTinyMceAsset < ActiveRecord::Base
belongs_to :step
belongs_to :asset
end

View file

@ -0,0 +1,11 @@
class CreateStepTinyMceAssets < ActiveRecord::Migration
def change
create_table :step_tiny_mce_assets do |t|
t.references :step, index: true, foreign_key: true
t.references :asset, index: true, foreign_key: true
t.boolean :edited, default: false
t.timestamps null: false
end
end
end

View file

@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170321131116) do
ActiveRecord::Schema.define(version: 20170419143608) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -60,12 +60,13 @@ ActiveRecord::Schema.define(version: 20170321131116) do
t.integer "lock_ttl"
t.integer "version", default: 1
t.boolean "file_processing"
t.integer "team_id"
end
add_index "assets", ["created_at"], name: "index_assets_on_created_at", using: :btree
add_index "assets", ["created_by_id"], name: "index_assets_on_created_by_id", using: :btree
add_index "assets", ["file_file_name"], name: "index_assets_on_file_file_name", using: :gist
add_index "assets", ["last_modified_by_id"], name: "index_assets_on_last_modified_by_id", using: :btree
add_index "assets", ["team_id"], name: "index_assets_on_team_id", using: :btree
create_table "checklist_items", force: :cascade do |t|
t.string "text", null: false
@ -75,7 +76,7 @@ ActiveRecord::Schema.define(version: 20170321131116) do
t.datetime "updated_at", null: false
t.integer "created_by_id"
t.integer "last_modified_by_id"
t.integer "position", default: 0, null: false
t.integer "position"
end
add_index "checklist_items", ["checklist_id"], name: "index_checklist_items_on_checklist_id", using: :btree
@ -93,6 +94,7 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "checklists", ["created_by_id"], name: "index_checklists_on_created_by_id", using: :btree
add_index "checklists", ["last_modified_by_id"], name: "index_checklists_on_last_modified_by_id", using: :btree
add_index "checklists", ["step_id"], name: "index_checklists_on_step_id", using: :btree
create_table "comments", force: :cascade do |t|
t.string "message", null: false
@ -107,6 +109,7 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "comments", ["associated_id"], name: "index_comments_on_associated_id", using: :btree
add_index "comments", ["created_at"], name: "index_comments_on_created_at", using: :btree
add_index "comments", ["last_modified_by_id"], name: "index_comments_on_last_modified_by_id", using: :btree
add_index "comments", ["type"], name: "index_comments_on_type", using: :btree
add_index "comments", ["user_id"], name: "index_comments_on_user_id", using: :btree
create_table "connections", force: :cascade do |t|
@ -170,11 +173,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "experiments", ["project_id"], name: "index_experiments_on_project_id", using: :btree
add_index "experiments", ["restored_by_id"], name: "index_experiments_on_restored_by_id", using: :btree
create_table "logs", force: :cascade do |t|
t.integer "team_id", null: false
t.string "message", null: false
end
create_table "my_module_groups", force: :cascade do |t|
t.string "name", null: false
t.datetime "created_at", null: false
@ -185,7 +183,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "my_module_groups", ["created_by_id"], name: "index_my_module_groups_on_created_by_id", using: :btree
add_index "my_module_groups", ["experiment_id"], name: "index_my_module_groups_on_experiment_id", using: :btree
add_index "my_module_groups", ["name"], name: "index_my_module_groups_on_name", using: :gist
create_table "my_module_tags", force: :cascade do |t|
t.integer "my_module_id"
@ -225,7 +222,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "my_modules", ["experiment_id"], name: "index_my_modules_on_experiment_id", using: :btree
add_index "my_modules", ["last_modified_by_id"], name: "index_my_modules_on_last_modified_by_id", using: :btree
add_index "my_modules", ["my_module_group_id"], name: "index_my_modules_on_my_module_group_id", using: :btree
add_index "my_modules", ["name"], name: "index_my_modules_on_name", using: :gist
add_index "my_modules", ["restored_by_id"], name: "index_my_modules_on_restored_by_id", using: :btree
create_table "notifications", force: :cascade do |t|
@ -258,7 +254,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "projects", ["archived_by_id"], name: "index_projects_on_archived_by_id", using: :btree
add_index "projects", ["created_by_id"], name: "index_projects_on_created_by_id", using: :btree
add_index "projects", ["last_modified_by_id"], name: "index_projects_on_last_modified_by_id", using: :btree
add_index "projects", ["name"], name: "index_projects_on_name", using: :gist
add_index "projects", ["restored_by_id"], name: "index_projects_on_restored_by_id", using: :btree
add_index "projects", ["team_id"], name: "index_projects_on_team_id", using: :btree
@ -270,7 +265,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
t.integer "team_id", null: false
end
add_index "protocol_keywords", ["name"], name: "index_protocol_keywords_on_name", using: :btree
add_index "protocol_keywords", ["team_id"], name: "index_protocol_keywords_on_team_id", using: :btree
create_table "protocol_protocol_keywords", force: :cascade do |t|
@ -303,11 +297,9 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "protocols", ["added_by_id"], name: "index_protocols_on_added_by_id", using: :btree
add_index "protocols", ["archived_by_id"], name: "index_protocols_on_archived_by_id", using: :btree
add_index "protocols", ["authors"], name: "index_protocols_on_authors", using: :btree
add_index "protocols", ["description"], name: "index_protocols_on_description", using: :btree
add_index "protocols", ["my_module_id"], name: "index_protocols_on_my_module_id", using: :btree
add_index "protocols", ["name"], name: "index_protocols_on_name", using: :btree
add_index "protocols", ["parent_id"], name: "index_protocols_on_parent_id", using: :btree
add_index "protocols", ["protocol_type"], name: "index_protocols_on_protocol_type", using: :btree
add_index "protocols", ["restored_by_id"], name: "index_protocols_on_restored_by_id", using: :btree
add_index "protocols", ["team_id"], name: "index_protocols_on_team_id", using: :btree
@ -393,7 +385,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "results", ["created_at"], name: "index_results_on_created_at", using: :btree
add_index "results", ["last_modified_by_id"], name: "index_results_on_last_modified_by_id", using: :btree
add_index "results", ["my_module_id"], name: "index_results_on_my_module_id", using: :btree
add_index "results", ["name"], name: "index_results_on_name", using: :gist
add_index "results", ["restored_by_id"], name: "index_results_on_restored_by_id", using: :btree
add_index "results", ["user_id"], name: "index_results_on_user_id", using: :btree
@ -458,7 +449,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
end
add_index "samples", ["last_modified_by_id"], name: "index_samples_on_last_modified_by_id", using: :btree
add_index "samples", ["name"], name: "index_samples_on_name", using: :gist
add_index "samples", ["sample_group_id"], name: "index_samples_on_sample_group_id", using: :btree
add_index "samples", ["sample_type_id"], name: "index_samples_on_sample_type_id", using: :btree
add_index "samples", ["team_id"], name: "index_samples_on_team_id", using: :btree
@ -496,6 +486,17 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "step_tables", ["step_id", "table_id"], name: "index_step_tables_on_step_id_and_table_id", unique: true, using: :btree
create_table "step_tiny_mce_assets", force: :cascade do |t|
t.integer "step_id"
t.integer "asset_id"
t.boolean "edited", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "step_tiny_mce_assets", ["asset_id"], name: "index_step_tiny_mce_assets_on_asset_id", using: :btree
add_index "step_tiny_mce_assets", ["step_id"], name: "index_step_tiny_mce_assets_on_step_id", using: :btree
create_table "steps", force: :cascade do |t|
t.string "name"
t.string "description"
@ -511,7 +512,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "steps", ["created_at"], name: "index_steps_on_created_at", using: :btree
add_index "steps", ["last_modified_by_id"], name: "index_steps_on_last_modified_by_id", using: :btree
add_index "steps", ["name"], name: "index_steps_on_name", using: :gist
add_index "steps", ["position"], name: "index_steps_on_position", using: :btree
add_index "steps", ["protocol_id"], name: "index_steps_on_protocol_id", using: :btree
add_index "steps", ["user_id"], name: "index_steps_on_user_id", using: :btree
@ -524,12 +524,14 @@ ActiveRecord::Schema.define(version: 20170321131116) do
t.integer "last_modified_by_id"
t.tsvector "data_vector"
t.string "name", default: ""
t.integer "team_id"
end
add_index "tables", ["created_at"], name: "index_tables_on_created_at", using: :btree
add_index "tables", ["created_by_id"], name: "index_tables_on_created_by_id", using: :btree
add_index "tables", ["data_vector"], name: "index_tables_on_data_vector", using: :gin
add_index "tables", ["last_modified_by_id"], name: "index_tables_on_last_modified_by_id", using: :btree
add_index "tables", ["team_id"], name: "index_tables_on_team_id", using: :btree
create_table "tags", force: :cascade do |t|
t.string "name", null: false
@ -543,7 +545,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "tags", ["created_by_id"], name: "index_tags_on_created_by_id", using: :btree
add_index "tags", ["last_modified_by_id"], name: "index_tags_on_last_modified_by_id", using: :btree
add_index "tags", ["name"], name: "index_tags_on_name", using: :gist
add_index "tags", ["project_id"], name: "index_tags_on_project_id", using: :btree
create_table "teams", force: :cascade do |t|
@ -601,11 +602,11 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "user_notifications", ["user_id"], name: "index_user_notifications_on_user_id", using: :btree
create_table "user_projects", force: :cascade do |t|
t.integer "role", default: 0
t.integer "user_id", null: false
t.integer "project_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "role"
t.integer "user_id", null: false
t.integer "project_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "assigned_by_id"
end
@ -671,7 +672,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["full_name"], name: "index_users_on_full_name", using: :btree
add_index "users", ["invitation_token"], name: "index_users_on_invitation_token", unique: true, using: :btree
add_index "users", ["invitations_count"], name: "index_users_on_invitations_count", using: :btree
add_index "users", ["invited_by_id"], name: "index_users_on_invited_by_id", using: :btree
@ -735,7 +735,6 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_foreign_key "experiments", "users", column: "created_by_id"
add_foreign_key "experiments", "users", column: "last_modified_by_id"
add_foreign_key "experiments", "users", column: "restored_by_id"
add_foreign_key "logs", "teams"
add_foreign_key "my_module_groups", "experiments"
add_foreign_key "my_module_groups", "users", column: "created_by_id"
add_foreign_key "my_module_tags", "users", column: "created_by_id"
@ -802,6 +801,8 @@ ActiveRecord::Schema.define(version: 20170321131116) do
add_foreign_key "step_assets", "steps"
add_foreign_key "step_tables", "steps"
add_foreign_key "step_tables", "tables"
add_foreign_key "step_tiny_mce_assets", "assets"
add_foreign_key "step_tiny_mce_assets", "steps"
add_foreign_key "steps", "protocols"
add_foreign_key "steps", "users"
add_foreign_key "steps", "users", column: "last_modified_by_id"

11
test/fixtures/step_tiny_mce_assets.yml vendored Normal file
View file

@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
step_id:
asset_id:
edited: false
two:
step_id:
asset_id:
edited: false

View file

@ -0,0 +1,7 @@
require 'test_helper'
class StepTinyMceAssetTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end