<< | Index | >>
Refer to http://dev.ywesee.com/wiki.php/Choddb/Bagxml
Link
Update
def hospital if ean = @session.user_input(:ean) and model = @session.app.hospital(ean) State::Hospitals::Hospital.new(@session, model) end end
def hospital if ean = @session.user_input(:ean) and model = @session.app.hospital(ean) State::Hospitals::RootHospital.new(@session, model) end end
EVENTS = [ :hospital,
Update
def vcard doctor = if ean_or_oid = @session.user_input(:doctor) @session.search_doctor(ean_or_oid) or @session.search_doctors(ean_or_oid).first elsif pointer = @session.user_input(:pointer) pointer.resolve(@session) endhospital = if ean = @session.user_input(:hospital)
@session.app.hospital(ean)
elsif pointer = @session.user_input(:pointer)
pointer.resolve(@session)
end
if doctor State::Doctors::VCard.new(@session, doctor)elsif hospital
State::Hospitals::VCard.new(@session, hospital)
end
end
STRINGS = [ :hospital,
def vcard(model) link = View::PointerLink.new(:vcard, model, @session, self) link.href = @lookandfeel._event_url(:vcard, {:hospital => model.ean13}) link end
Commit
Update
def search_hospital(ean) @persistent_user_input[:ean] ||= ean @app.hospital(ean) end
def suggest_address ... else doctor = if oid_or_ean = @session.user_input(:doctor) @session.search_doctor(oid_or_ean) || @session.search_doctors(oid_or_ean).first endhospital = if ean = @session.user_input(:hospital)
@session.search_hospital(ean)
end
if (doctor and addr = doctor.address(@session.user_input(:address)))
or (hospital and addr = hospital.address(@session.user_input(:address)))
SuggestAddress.new(@session, addr) end end end
button = HtmlGrid::Button.new(:correct, model, @session, self)args = if ean = @session.user_input(:ean) and hospital = @session.search_hospital(ean) \
and address = hospital.addresses.index(model)
[
:hospital, ean,
:address, address,
:zone, @session.zone,
]
elsif ean = @session.user_input(:ean) and doctors = @session.search_doctors(ean) and doctor = doctors.first and address = doctor.addresses.index(model) [ :doctor, ean, :address, address, :zone, @session.zone, ]
Note
Update
def init if(addr = @model.address_instance or addr = @model.address_pointer.resolve(@session)) @active_address = AddressWrapper.new(addr)@parent = if ean_or_oid = @session.persistent_user_input(:ean) || @session.persistent_user_input(:oid) \\
and parent = @session.search_doctor(ean_or_oid) || @session.search_doctors(ean_or_oid).first
parent
elsif ean = @session.persistent_user_input(:ean) and parent = @session.search_hospital(ean_or_oid)
parent
else pointer = @model.address_pointer pointer.parent.resolve(@session) end select_zone(@parent) @active_address.email_suggestion = @parent.email end super end
def address_suggestionif (ean_or_oid = @session.user_input(:doctor) and (doctor = @session.search_doctor(ean_or_oid) || @session.search_doctors(ean_or_oid).first)) \\
or (ean = @session.user_input(:hospital) and hospital = @session.search_hospital(ean))
if oid = @session.user_input(:oid) and model = @session.app.address_suggestion(oid)
State::Admin::TransparentLogin.new(@session, model) end end end
def address_suggestionif (ean_or_oid = @session.user_input(:doctor) and (doctor = @session.search_doctor(ean_or_oid) || @session.search_doctors(ean_or_oid).first)) \\
or (ean = @session.user_input(:hospital) and hospital = @session.search_hospital(ean))
if oid = @session.user_input(:oid) and model = @session.app.address_suggestion(oid)
State::Admin::AddressSuggestion.new(@session, model) end end end
def save_suggestion@parent = if ean_or_oid = @session.persistent_user_input(:oid) and parent = (@session.search_doctor(ean_or_oid) || @session.search_doctors(ean_or_oid).first)
parent
elsif ean = @session.persistent_user_input(:ean) and parent = @session.search_hospital(ean)
parent
else @model.parent(@session) end def send_notification(suggestion)url = if @parent.is_a?(ODDB::Doctor)
@session.lookandfeel._event_url(:address_suggestion, [:doctor, (@parent.ean13 || @parent.oid), :oid, suggestion.oid])
elsif @parent.is_a?(ODDB::Hospital)
@session.lookandfeel._event_url(:address_suggestion, [:hospital, @parent.ean13, :oid, suggestion.oid])
else @session.lookandfeel._event_url(:resolve, {:pointer => suggestion.pointer}) end
Commit
View
Question
Problem
Solution
Update
attr_accessor :url, :parent
def save_suggestion ...input.store(:parent, @parent)
unless error? ...input.store(:url, @url)
@session.app.update(pointer, input, unique_email) end
def parent_class(model)obj = model.parent || begin
ptr = model.address_pointer ptr.parent.resolve(@session) end @lookandfeel.lookup(obj.class) end def time(model) if(time = model.time) link = PointerLink.new(:time, model, @session,self) fmt = @lookandfeel.lookup(:time_format_long) link.value = time.strftime(fmt)link.href = model.url if model.url
link end enddef name(model)
link = View::PointerLink.new(:name, model, @session, self)
link.href = model.url if model.url
link
end
Link
Check
ch.oddb> companies.values.map{|c| c.ean13}.length -> 740 ch.oddb> companies.values.map{|c| c.ean13}.compact.length -> 456 ch.oddb> companies.values.map{|c| c.ean13}.compact.uniq.length -> 384 ch.oddb> open('/home/masa/work/company_ean.dat', 'w'){|out| out.print companies.values.map{|c| c.ean13}.compact.join("\n")
Note