Class: ODDB::State::Admin::AssignFachinfo

Inherits:
Global show all
Defined in:
src/state/admin/assign_fachinfo.rb

Defined Under Namespace

Classes: RegistrationFacade

Constant Summary

VIEW =
View::Admin::AssignFachinfo

Constants inherited from Global

HOME_STATE, ZONE

Constants inherited from Global

DIRECT_EVENT, GLOBAL_MAP, HOME_STATE, LIMITED, PRINT_STATES, READONLY_STATES, RESOLVE_STATES, REVERSE_MAP, VIEW, ZONE_NAVIGATION

Constants included from UmlautSort

FILTER_PAIRS

Instance Method Summary (collapse)

Methods inherited from Global

#zone_navigation

Methods inherited from Global

#_search_drugs, #_search_drugs_state, #_trigger, #add_to_interaction_basket, #allowed?, #atc_chooser, #checkout, #clear_interaction_basket, #creditable?, #direct_request_path, #doctorlist, #download, #export_csv, #extend, #fachinfo, #feedbacks, #help_navigation, #home_navigation, #home_state, #hospitallist, #interaction_basket, #limit_state, #limited?, #logout, #navigation, #notify, #password_reset, #paypal_return, #powerlink, #print, #proceed_download, #proceed_poweruser, #resolve, #resolve_state, #rss, #search, #show, #snapback_event, #sort, #sponsorlink, #suggest_address, #switch, #unique_email, #user_input, #user_navigation, #ywesee_contact, #zone_navigation, #zones

Methods included from LoginMethods

#autologin, #login

Methods included from UmlautSort

#sort_model, #umlaut_filter

Instance Method Details

- (Object) assign



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'src/state/admin/assign_fachinfo.rb', line 46

def assign
  keys = [:pointers, :pointer]
  input = user_input(keys, keys)
  pointers = input[:pointers].values
  if(pointers \
    && pointers.any? { |pointer| 
      !allowed?(pointer.resolve(@session))})
    @errors.store(:pointers, 
      create_error('e_not_allowed', :pointers, nil))
  end
  unless(error?)
    if(fi = @model.registration.fachinfo)
      pointers.each { |pointer|
        @session.app.update(pointer, {:fachinfo => fi.pointer}, unique_email)
      }
    end
  end
  self
end

- (Object) init



38
39
40
41
42
43
44
45
# File 'src/state/admin/assign_fachinfo.rb', line 38

def init
  super
  @model = RegistrationFacade.new(@model)
  if((match = /^[^\s]+/u.match(@model.name_base)) \
    && match[0].size >= 3)
    @model.registrations = named_registrations(match[0])
  end
end

- (Object) named_registrations(name)



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'src/state/admin/assign_fachinfo.rb', line 65

def named_registrations(name)
  if(name.size < 3)
    add_warning(:w_name_to_short,:name, name)
    []
  else
    seqs = @session.app.search_sequences(name.downcase)
    regs = seqs.collect { |seq| seq.registration }.uniq.select { |reg|
      allowed?(reg)
    }
    if(regs.size > 50)
      add_warning(:w_too_many_registrations, :name, nil)
      regs[0,50]
    else
      regs
    end
  end
end

- (Object) search_registrations



82
83
84
85
86
87
88
89
90
91
# File 'src/state/admin/assign_fachinfo.rb', line 82

def search_registrations
  name = @session.user_input(:search_query)
  if(name.is_a? String)
    @model.registrations = named_registrations(name)
  else
    err = create_error(:e_name_to_short, :name, name)
    @errors.store(name, err)
  end
  self
end