view · edit · sidebar · attach · print · history

20111024-remove-eancode-from-link-ebook-change-link-format--migrate_to_utf8-oddb_org

<< | Index | >>


  1. Insert Dose and remove ean code from link kindle ebook
  2. Replace admin 'bearbeiten' pointer format link oddb.org
  3. Replace FI links oddb.org
  4. Replace Drunken Link in FI view
  5. Recheck migrate_to_utf8 method

Goal/Estimate/Evaluation
  • Insert Dose ebook / 100% / 100%
  • Replace admin pointer links bearbeiten oddb.org / 100% / 100%
  • Replace FI link / 100% / 100%
  • Update migrate_to_utf8 / 80% /
Commit
ToDo Tommorrow
  • Check the number of saved objects

Insert Dose and remove ean code from link kindle ebook

Task

  • Update 'Preisgreich' link

Update

  • src/model/registration_observer.rb
    def article_codes
    ...
          if(pdose = pac.dose)
            cds.store(:article_dose, pdose.to_s)
          end

Reboot

  • oddb.org/ext/exporter/bin/exportd
  • oddb.org/bin/oddbd

Run

  • bin/admin
ch.oddb> Exporter.new(self).export_fachinfo_yaml

Result

  • data/downloads/facinfo.yaml
...
article_codes:
- :article_pcode: "880231"
  :article_size: 11 ml
  :article_ean13: "7680426940109"
  :article_dose: 396 mg/ml
...

Update

  • ebps/bin/decorators/ch_oddb_de.rb
      def self.decorate model
      ...
          #size_ean13s = codes.collect do |hash| [hash[:article_size], hash[:article_ean13]] end.compact
          size_ean13s = codes.collect do |hash| [hash[:article_size], hash[:article_dose], hash[:article_ean13]] end.compact
          unless size_ean13s.empty?
            chapter = Text::Chapter.new
            chapter.heading << 'Preisvergleich'
            size_ean13s.each do |size, dose, ean13|
              #chapter.add_paragraph Text::LinkedParagraph.new(href, model.title + " " + size.to_s + " " + ean13.to_s)
              chapter.add_paragraph Text::LinkedParagraph.new(href, model.title + " " + size.to_s + " " + dose.to_s)

Run

$ ruby1.9 -I lib bin/oddb_kindle config="etc/oddb_kindle.yml" 

Result

Replace admin 'bearbeiten' pointer format link oddb.org

Task

Update

  • src/state/global.rb
      def atc_class
        if model = @session.app.atc_class(@session.user_input(:atc_code))
          if @session.allowed?('edit', 'org.oddb.model.!atc_class.*')
            State::Admin::AtcClass.new(@session, model)
          else
            State::Admin::TransparentLogin.new(@session, model)
          end
        end
      end
  • src/util/validator.rb
    EVENTS = [
    ...
      :atc_class,

Access (twice, first login is required, second jump directly)

Result

  • success

Note

  • 'def atc_class' is corresponding to an event

Updates

  • src/view/drugs/result.rb
 def edit(model, session=@session)
    link = View::PointerLink.new(:code, model, session, self)
    ...
    link.href = @lookandfeel._event_url(:atc_class, {:atc_code => model.code})
    link
 end
  • src/view/drugs/atc_chooser.rb
 def edit(model, session=@session)
    link = View::PointerLink.new(:code, model, session, self)
    ...
    link.href = @lookandfeel._event_url(:atc_class, {:atc_code => model.code})
    link
 end

Commit

Replace FI links oddb.org

Task

  • Replace all the link in Fachinformation view without pointer

For example

Update

  • src/state/global.rb
      def fachinfo
        if (iksnr = @session.user_input(:reg) || @session.user_input(:swissmedicnr))           && (reg = @session.app.registration(iksnr))           && fachinfo = reg.fachinfo
          if @session.allowed?('edit', fachinfo)
            State::Drugs::RootFachinfo.new(@session, fachinfo)
          else
            State::Drugs::Fachinfo.new(@session, fachinfo)
          end
        else
          Http404.new(@session, nil)
        end
      end

Access

  1. http://oddb.masa.org/de/gcc/fachinfo/reg/50863/chapter/composition -> Normal view
  2. (login as admin)
  3. http://oddb.masa.org/de/gcc/fachinfo/reg/50863/chapter/composition -> Edit view

Result

  • Success

Updates

  • src/view/drugs/fachinfo.rb
 class FiChapterChooserLink < HtmlGrid::Link
   def init
    args = [
      :reg, @model.registrations.first.iksnr,
      :chapter, @name,
      #:pointer, @model.pointer,
    ]
    unless(@session.user_input(:chapter) == @name.to_s)
      if(@model.pointer.skeleton == [:create])
        self.href = @lookandfeel.event_url(:self, {:chapter => @name})
      else
        self.href = @lookandfeel._event_url(:fachinfo, args)
       #self.href = @lookandfeel._event_url(:resolve, args)
      end
    end
 ...

Result

  • All the links in fachinfo view except for Drunken are replaced

Note

  • One bug is found
  • Change Log is never saved in the database

Update

  • src/model/fachinfo.rb
    def add_change_log_item(email, chapter, language)
    ...
      self.odba_store
    end

Result

  • Change log is saved

Commit

Replace Drunken Link in FI view

Replace Drunken pointer link

Update

  • src/state/global.rb
      def print
        if pointer = @session.user_input(:pointer)
          if((model = pointer.resolve(@session.app))             && (klass = resolve_state(pointer, :print)))
            klass.new(@session, model)
          end
        elsif iksnr = @session.user_input(:fachinfo) and reg = @session.app.registration(iksnr) and fi = reg.fachinfo
          State::Drugs::FachinfoPrint.new(@session, fi)
        end
      end
  • src/util/validator.rb
    STRINGS = [
      :fachinfo,
  • src/view/drugs/facinfo.rb
 class FiChapterChooser < HtmlGrid::Composite
 ...
   def print(model, session=@session, key=:print)
     link = HtmlGrid::Link.new(key, model, session, self)
     link.set_attribute('title', @lookandfeel.lookup(:print_title))
     args = {
       :fachinfo  => model.registrations.first.iksnr,
     }
     link.href = @lookandfeel._event_url(:print, args)
     link
   end

Commit

Recheck migrate_to_utf8 method

Hypothesis

  • Not every data is saved after migrate_to_utf8

Update

  • src/util/oddbapp.rb
    def _migrate_to_utf8 queue, table, iconv, opts={}
    ...
      #_migrate_obj_to_utf8 obj, queue, table, iconv, opts
      obj = _migrate_obj_to_utf8 obj, queue, table, iconv, opts
      ...
         #obj.odba_store unless obj.odba_unsaved?
         obj.odba_store
  • src/model/company.rb
    def search_terms
      @name.force_encoding('utf-8')

Setup

  • restore database

Run

 ruby193 -I ../oddb/lib bin/oddbd > log.dat 2>&1
  • bin/admin
 ch.oddb> migrate_to_utf8

Result

  • Let's see tomorrow
view · edit · sidebar · attach · print · history
Page last modified on October 24, 2011, at 05:06 PM