Module: ODDB::Html::State::Viral::Admin

Includes:
SBSM::ViralState
Defined in:
lib/oddb/html/state/viral/admin.rb

Instance Method Summary collapse

Instance Method Details

#_package(code) ⇒ Object



60
61
62
63
64
# File 'lib/oddb/html/state/viral/admin.rb', line 60

def _package(code)
  if(package = _package_by_code(code))
    State::Drugs::Admin::Package.new(@session, package)
  end
end

#_product(uid) ⇒ Object



65
66
67
68
69
# File 'lib/oddb/html/state/viral/admin.rb', line 65

def _product(uid)
  if(product = ODDB::Drugs::Product.find_by_uid(uid))
    State::Drugs::Admin::Product.new(@session, product)
  end
end

#_sequence(uid) ⇒ Object



70
71
72
73
74
# File 'lib/oddb/html/state/viral/admin.rb', line 70

def _sequence(uid)
  if(sequence = ODDB::Drugs::Sequence.find_by_uid(uid))
    State::Drugs::Admin::Sequence.new(@session, sequence)
  end
end

#atc_assignObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/oddb/html/state/viral/admin.rb', line 16

def atc_assign
  email = @session.user.email
  newstate = search
  code = user_input(:code)
  model = newstate.model
  if(atc = ODDB::Drugs::Atc.find_by_code(code))
    packages = 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
    }
    ## do a completely new search to get everything sorted properly
    model.query = nil
    newstate = newstate.search
  else
    @errors.store :atc_assign, create_error(:e_unknown_atc, :atc_assign, code)
  end
  newstate
end

#limited?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/oddb/html/state/viral/admin.rb', line 38

def limited?
  false
end

#new_packageObject



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/oddb/html/state/viral/admin.rb', line 41

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_sequenceObject



52
53
54
55
56
57
58
59
# File 'lib/oddb/html/state/viral/admin.rb', line 52

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