Sha256: 32af0ad0fd2b679b2eed386ca1b66c9c5c07c5aadf12d999e262c58a0d558bc5

Contents?: true

Size: 1.74 KB

Versions: 12

Compression:

Stored size: 1.74 KB

Contents

class WhowishWordEmailController < ActionController::Base
  
  before_filter :compact_policy,:check_whowish_word_admin
  
  def check_whowish_word_admin
    $whowish_word_admin = session[:whowish_word_admin]
  end
  
  def compact_policy
    response.headers['P3P'] = 'policyref="/w3c/p3p.xml", CP="'+COMPACT_POLICY+'"'
  end
  
  layout "whowish_word_blank"

  def index

  end

  def add

    email = WhowishWordEmail.new
    email.page_id = params[:page_id].strip
    email.word_id = params[:word_id].strip
    email.content = params[:content].strip
    email.locale = "en"

    email.save

    ActionView::Base.whowish_word[entity.page_id] = {} if !ActionView::Base.whowish_word[entity.page_id]
    ActionView::Base.whowish_word[entity.page_id][entity.word_id.to_sym] = entity.content

    render :json=>{:ok=>true,:html=>(render_to_string :partial=>"row",:locals=>{:entity=>email,:is_new=>false})}
  end

  def edit

    entity = WhowishWordEmail.first(:conditions=>{:id=>params[:id]})

    if !entity
      render :json=>{:ok=>false,:error_message=>"The email record does not exist."}
      return
    end

    entity.page_id = params[:page_id].strip
    entity.word_id = params[:word_id].strip
    entity.content = params[:content].strip
    entity.locale = "en"

    ActionView::Base.whowish_word[entity.page_id] = {} if !ActionView::Base.whowish_word[entity.page_id]
    ActionView::Base.whowish_word[entity.page_id][entity.word_id.to_sym] = entity.content

    entity.save

    render :json=>{:ok=>true}
  end

  def delete
    if !WhowishWordEmail.delete(params[:id])
      render :json=>{:ok=>false,:error_message=>"error while delete location"}
      return
    end

    render :json=>{:ok=>true}
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
whowish_word-0.2.1 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.2.0 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.9 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.8 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.7 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.6 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.5 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.4 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.3 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.2 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.1 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb
whowish_word-0.1.0 lib/legacy/whowish_word/lib/app/controllers/whowish_word_email_controller.rb