Commit 0cf47e00 authored by jasonych99's avatar jasonych99
Browse files

Add Report Label - BE

parent 22b3ab5b
......@@ -204,6 +204,7 @@ module Chemotion
requires :splSettings, type: Array[Hash], coerce_with: ->(val) { JSON.parse(val) }
requires :rxnSettings, type: Array[Hash], coerce_with: ->(val) { JSON.parse(val) }
requires :configs, type: Array[Hash], coerce_with: ->(val) { JSON.parse(val) }
requires :molSerials, type: Array[Hash], coerce_with: ->(val) { JSON.parse(val) }
requires :imgFormat, type: String, default: 'png', values: %w(png eps emf)
requires :fileName, type: String, default: "ELN_Report_" + Time.now.strftime("%Y-%m-%dT%H-%M-%S")
requires :template, type: String, default: "standard"
......@@ -213,6 +214,7 @@ module Chemotion
spl_settings = hashize(params[:splSettings])
rxn_settings = hashize(params[:rxnSettings])
configs = hashize(params[:configs])
mol_serials = params[:molSerials].map(&:to_hash)
attributes = {
file_name: params[:fileName],
......@@ -220,6 +222,7 @@ module Chemotion
configs: configs,
sample_settings: spl_settings,
reaction_settings: rxn_settings,
mol_serials: mol_serials,
objects: params[:objTags],
img_format: params[:imgFormat],
template: params[:template],
......
......@@ -5,6 +5,7 @@ class Report < ActiveRecord::Base
serialize :sample_settings, Hash
serialize :reaction_settings, Hash
serialize :objects, Array
serialize :mol_serials, Array
has_many :reports_users
has_many :users, through: :reports_users
......
class ReportSerializer < ActiveModel::Serializer
attributes :id, :file_name, :file_description,
:configs, :sample_settings, :reaction_settings,
:downloadable, :unread, :template, :img_format, :objects
:configs, :sample_settings, :reaction_settings, :mol_serials,
:downloadable, :unread, :template, :img_format, :objects
def downloadable
@downloadable ||= object.file_path.present?
......
class AddMolSerialsToReport < ActiveRecord::Migration
def change
add_column :reports, :mol_serials, :text, default: []
end
end
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170908105401) do
ActiveRecord::Schema.define(version: 20170928124229) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -391,7 +391,7 @@ ActiveRecord::Schema.define(version: 20170908105401) do
create_table "molecules", force: :cascade do |t|
t.string "inchikey"
t.string "inchistring"
t.float "density"
t.float "density", default: 0.0
t.float "molecular_weight"
t.binary "molfile"
t.float "melting_point"
......@@ -524,6 +524,7 @@ ActiveRecord::Schema.define(version: 20170908105401) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "template", default: "standard"
t.text "mol_serials", default: "--- []\n"
end
add_index "reports", ["author_id"], name: "index_reports_on_author_id", using: :btree
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment