Module: ODDB::Html::State::Viral::Admin
- Includes:
- SBSM::ViralState
- Defined in:
- lib/oddb/html/state/viral/admin.rb
Instance Method Summary collapse
- #_package(code) ⇒ Object
- #_product(uid) ⇒ Object
- #_sequence(uid) ⇒ Object
- #atc_assign ⇒ Object
- #limited? ⇒ Boolean
- #new_package ⇒ Object
- #new_sequence ⇒ Object
Instance Method Details
#_package(code) ⇒ Object
57 58 59 60 61 |
# File 'lib/oddb/html/state/viral/admin.rb', line 57 def _package(code) if(package = _package_by_code(code)) State::Drugs::Admin::Package.new(@session, package) end end |
#_product(uid) ⇒ Object
62 63 64 65 66 |
# File 'lib/oddb/html/state/viral/admin.rb', line 62 def _product(uid) if(product = ODDB::Drugs::Product.find_by_uid(uid)) State::Drugs::Admin::Product.new(@session, product) end end |
#_sequence(uid) ⇒ Object
67 68 69 70 71 |
# File 'lib/oddb/html/state/viral/admin.rb', line 67 def _sequence(uid) if(sequence = ODDB::Drugs::Sequence.find_by_uid(uid)) State::Drugs::Admin::Sequence.new(@session, sequence) end end |
#atc_assign ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/oddb/html/state/viral/admin.rb', line 16 def atc_assign email = @session.user.email newstate = search code = user_input(:code) if(atc = ODDB::Drugs::Atc.find_by_code(code)) packages = newstate.model.find { |list| list.atc.nil? } packages.each { |package| if((seq = package.sequence) && seq.atc.nil?) seq.atc = atc seq.data_origins[:atc] = email seq.save end } packages.atc = atc else @errors.store :atc_assign, create_error(:e_unknown_atc, :atc_assign, code) end newstate end |
#limited? ⇒ Boolean
35 36 37 |
# File 'lib/oddb/html/state/viral/admin.rb', line 35 def limited? false end |
#new_package ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/oddb/html/state/viral/admin.rb', line 38 def new_package if((uid = @session.user_input(:uid)) \ && (sequence = ODDB::Drugs::Sequence.find_by_uid(uid))) pac = ODDB::Drugs::Package.new pac.sequence = Util::UnsavedHelper.new(sequence) part = ODDB::Drugs::Part.new part.package = Util::UnsavedHelper.new(pac) pac.parts.push part Drugs::Admin::NewPackage.new(@session, pac) end end |
#new_sequence ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/oddb/html/state/viral/admin.rb', line 49 def new_sequence if((uid = @session.user_input(:uid)) \ && (product = ODDB::Drugs::Product.find_by_uid(uid))) seq = ODDB::Drugs::Sequence.new seq.product = Util::UnsavedHelper.new(product) Drugs::Admin::NewSequence.new(@session, seq) end end |