Sha256: 0db1f0178f08f7adb54e61d7a42483f1d64271ea0166814e1c696598a2a1c561

Contents?: true

Size: 930 Bytes

Versions: 20

Compression:

Stored size: 930 Bytes

Contents

class E9Crm::ContactEmailsController < E9Crm::ResourcesController
  defaults

  respond_to :js, :html

  def create
    create! do |success, failure|
      success.html { redirect_to :admin_sent_email }
      success.js
    end
  end

  protected

  def build_resource
    get_resource_ivar || begin
      object = if params[resource_instance_name]
        ContactEmail.new(params[resource_instance_name] || {})
      else
        ContactEmail.new_from_template(template, :contact_ids => params[:uids])
      end

      object.from_email = object.from_email.presence || current_user.email

      object.valid?

      set_resource_ivar(object)
    end
  end

  # throw record_not_found if there's no template.  #new requires email_template_id
  # be passed in params (and also contact_ids)
  def template
    @_template ||= EmailTemplate.find(params[:etid])
  end

  def determine_layout
    request.xhr? ? false : super
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
e9_crm-0.1.34 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.33 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.32 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.31 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.30 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.29 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.28 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.27 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.26 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.25 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.24 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.23 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.22 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.21 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.20 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.19 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.18 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.17 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.16 app/controllers/e9_crm/contact_emails_controller.rb
e9_crm-0.1.14 app/controllers/e9_crm/contact_emails_controller.rb