Class: ODDB::Html::State::Drugs::Feedback

Inherits:
Global
  • Object
show all
Includes:
Util::NeedAllInput
Defined in:
lib/oddb/html/state/drugs/feedback.rb

Defined Under Namespace

Classes: Feedbackable

Constant Summary collapse

LIMIT =
true
VIEW =
View::Drugs::Feedback

Constants inherited from Global

Global::GLOBAL_MAP

Instance Attribute Summary collapse

Attributes included from LoginMethods

#desired_input

Instance Method Summary collapse

Methods included from Util::NeedAllInput

#user_input

Methods inherited from Global

transparent_login

Methods included from Events

#_compare, #_complete, #_explain_ddd_price, #_explain_price, #_fachinfo, #_package, #_package_by_code, #_package_infos, #_patinfo, #_products, #_remote, #_remote_comparables, #_remote_infos, #_remote_package, #_remote_packages, #_search, #_search_append_products, #_search_append_sequences, #_search_by, #_search_local, #_search_remote, #_tax_factor, #compare_remote, #ddd, #limited?, #navigation, #search

Methods inherited from Global

#_download, #compare, #explain_ddd_price, #explain_price, #fachinfo, #feedback, #home, #limit_state, #limited?, #logout, #method_missing, #navigation, #package, #package_infos, #partitioned_keys, #patinfo, #proceed_export, #proceed_poweruser, #product, #products, #remote_infos, #sequence

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 in the class ODDB::Html::State::Global

Instance Attribute Details

#passed_turing_testObject (readonly)

Returns the value of attribute passed_turing_test.



32
33
34
# File 'lib/oddb/html/state/drugs/feedback.rb', line 32

def passed_turing_test
  @passed_turing_test
end

Instance Method Details

#_feedback(code) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/oddb/html/state/drugs/feedback.rb', line 47

def (code)
  if(@model.code(:cid, ODDB.config.country) == code)
    self
  else
    super
  end
end

#direct_eventObject



40
41
42
43
44
45
46
# File 'lib/oddb/html/state/drugs/feedback.rb', line 40

def direct_event
  direct_event = [:feedback]
  if(code = @model.code(:cid, ODDB.config.country))
    direct_event.push([:cid, code.value])
  end
  direct_event
end

#initObject



33
34
35
36
37
38
39
# File 'lib/oddb/html/state/drugs/feedback.rb', line 33

def init
  ## disable captcha
  @passed_turing_test = true
  ##
  @model = Feedbackable.new(@model)
  super
end

#updateObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/oddb/html/state/drugs/feedback.rb', line 54

def update
  mandatory = [:name, :email, :email_public, :item_good_experience, 
    :item_recommended, :item_good_impression, :item_helps]
  unless @passed_turing_test
    mandatory.push :captcha
  end
  keys = mandatory + [:message]
  hash = user_input(keys, mandatory)
  if(@passed_turing_test)
    # do nothing
  elsif((candidates = hash[:captcha]) && candidates.any? { |key, word| 
    @session.lookandfeel.captcha.valid_answer? key, word })
    @passed_turing_test = true
  else
    @errors.store(:captcha, create_error('e_failed_turing_test', 
      :captcha, nil))
  end
  unless(error?)
    feedback = @model.current
    info_key = (@model.created?) ? :feedback_changed : :feedback_saved
    
    hash.each { |key, value|
      writer = "#{key}="
      if(feedback.respond_to? writer)
        feedback.send writer, value
      end
    }
    feedback.time = Time.now
    feedback.item = @model.item
    feedback.save

    @session.update_feedback_rss_feed
    @infos = [info_key]
  end
  self
end