Class: ODDB::Html::State::Global

Inherits:
SBSM::State
  • Object
show all
Includes:
PayPal::Checkout
Defined in:
lib/oddb/html/state/global.rb,
lib/oddb/html/state/global_predefine.rb

Constant Summary collapse

LIMIT =
false
GLOBAL_MAP =
{
  :atc_browser => Drugs::AtcBrowser,
  :login       => Drugs::Login,
}

Instance Attribute Summary collapse

Attributes included from LoginMethods

#desired_input

Instance Method Summary collapse

Methods included from PayPal::Checkout

#ajax_autofill, #checkout, #checkout_keys, #checkout_mandatory, #collect, #create_user

Methods included from LoginMethods

#login_

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mth, *args) ⇒ Object



155
156
157
158
159
160
161
# File 'lib/oddb/html/state/global.rb', line 155

def method_missing(mth, *args)
  if(mth.to_s[0] == ?_)
    self
  else
    super
  end
end

Instance Attribute Details

#passed_turing_testObject (readonly)

Returns the value of attribute passed_turing_test.



20
21
22
# File 'lib/oddb/html/state/global.rb', line 20

def passed_turing_test
  @passed_turing_test
end

Instance Method Details

#_download(file) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/oddb/html/state/global.rb', line 31

def _download(file)
  if match = /(.+)_(.+).csv/.match(file)
    packages = _search_local match[1].tr('-', ' '), match[2]
    packages.filename = file
    Drugs::DownloadExport.new(@session, packages)
  end
end

#compareObject



26
27
28
29
30
# File 'lib/oddb/html/state/global.rb', line 26

def compare
  if(code = @session.user_input(:cid))
    _compare(code)
  end
end

#explain_ddd_priceObject



38
39
40
41
42
43
# File 'lib/oddb/html/state/global.rb', line 38

def explain_ddd_price
  if((code = @session.user_input(:cid)) \
     && (idx = @session.user_input(:offset)))
    _explain_ddd_price(code, idx.to_i)
  end
end

#explain_priceObject



44
45
46
47
48
# File 'lib/oddb/html/state/global.rb', line 44

def explain_price
  if(code = @session.user_input(:cid))
    _explain_price(code)
  end
end

#fachinfoObject



49
50
51
52
53
# File 'lib/oddb/html/state/global.rb', line 49

def fachinfo
  if(uid = @session.user_input(:uid))
    _fachinfo(uid)
  end
end

#feedbackObject



54
55
56
57
58
# File 'lib/oddb/html/state/global.rb', line 54

def feedback
  if(code = @session.user_input(:cid))
    (code)
  end
end

#homeObject



59
60
61
# File 'lib/oddb/html/state/global.rb', line 59

def home
  State::Drugs::Init.new @session, nil
end

#limit_stateObject



65
66
67
# File 'lib/oddb/html/state/global.rb', line 65

def limit_state
  State::Limit.new(@session, nil)
end

#limited?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/oddb/html/state/global.rb', line 62

def limited?
  self.class.const_get(:LIMIT)
end

#logoutObject



68
69
70
71
# File 'lib/oddb/html/state/global.rb', line 68

def logout
  @session.logout
  home
end


152
153
154
# File 'lib/oddb/html/state/global.rb', line 152

def navigation
  []
end

#packageObject



72
73
74
75
76
# File 'lib/oddb/html/state/global.rb', line 72

def package
  if(code = @session.user_input(:cid))
    _package(code)
  end
end

#package_infosObject



77
78
79
80
81
# File 'lib/oddb/html/state/global.rb', line 77

def package_infos
  if(code = @session.user_input(:cid))
    _package_infos(code)
  end
end

#partitioned_keys(keys) ⇒ Object



82
83
84
85
86
# File 'lib/oddb/html/state/global.rb', line 82

def partitioned_keys(keys)
  keys.partition { |key|
    /^[a-z]$/.match(key)
  }
end

#patinfoObject



87
88
89
90
91
# File 'lib/oddb/html/state/global.rb', line 87

def patinfo
  if(uid = @session.user_input(:uid))
    _patinfo(uid)
  end
end

#proceed_exportObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/oddb/html/state/global.rb', line 92

def proceed_export
  query = @session.persistent_user_input(:query)
  dstype = @session.persistent_user_input(:dstype) || ODDB.config.default_dstype
  result = _search_local(query, dstype)
  filename = sprintf('%s_%s.csv', query.tr(' ', '-'), dstype)
  if @session.allowed?('download', "#{ODDB.config.auth_domain}.#{filename}")
    result.filename = filename
    Drugs::DownloadExport.new @session, result
  else
    lines = result.size
    price = ODDB.config.prices["org.oddb.de.export.cvs"].to_f
    unless(lines > 0 && price > 0)
      @errors.store :days, create_error(:e_empty_result, :query, query)
      self
    else
      invoice = ODDB::Business::Invoice.new
      item = invoice.add(:export, filename, lines, '', price)
      State::RegisterExport.new(@session, invoice)
    end
  end
end

#proceed_poweruserObject



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/oddb/html/state/global.rb', line 113

def proceed_poweruser
  days = @session.user_input(:days).to_i
  total = ODDB.config.prices["org.oddb.de.view.#{days}"].to_f 
  unless(days > 0 && total > 0)
    @errors.store :days, create_error(:e_missing_days, :days, 0)
    self
  else
    invoice = ODDB::Business::Invoice.new
    item = invoice.add(:poweruser, "unlimited access", days, 
                       @session.lookandfeel.lookup(:days), total / days)
    State::RegisterPowerUser.new(@session, invoice)
  end
=begin
    if(usr = @session.user_input(:pointer))
      State::User::RenewPowerUser.new(@session, invoice)
    else
      State::User::RegisterPowerUser.new(@session, invoice)
    end
  end
=end
end

#productObject

if(usr = @session.user_input(:pointer))

    State::User::RenewPowerUser.new(@session, invoice)
  else
    State::User::RegisterPowerUser.new(@session, invoice)
  end
end


134
135
136
137
138
# File 'lib/oddb/html/state/global.rb', line 134

def product
  if(uid = @session.user_input(:uid))
    _product(uid)
  end
end

#productsObject



139
140
141
# File 'lib/oddb/html/state/global.rb', line 139

def products
  _products(@session.persistent_user_input(:range))
end

#remote_infosObject



142
143
144
145
146
# File 'lib/oddb/html/state/global.rb', line 142

def remote_infos
  if(id = @session.user_input(:uid))
    _remote_infos(id)
  end
end

#sequenceObject



147
148
149
150
151
# File 'lib/oddb/html/state/global.rb', line 147

def sequence
  if(uid = @session.user_input(:uid))
    _sequence(uid)
  end
end