Sha256: 09910dc6c6ab14cc09526657d126b69d1fb457defa1025d1462df68e4c631735

Contents?: true

Size: 1 KB

Versions: 10

Compression:

Stored size: 1 KB

Contents

class E9Crm::EmailTemplatesController < E9Crm::ResourcesController
  defaults
  include E9Rails::Controllers::Orderable
  self.should_paginate_index = false

  filter_access_to :select, :require => :read, :context => :admin

  before_filter :handle_unacceptable_mimetype, :only => :show

  respond_to :json, :only => :show
  respond_to :html, :except => :show

  def select
    index!
  end

  def show
    unless params[:contact_id] =~ /\d+/ && @contact = Contact.find_by_id(params[:contact_id])
      head :status => 404
    else
      object           = resource
      object.contact   = @contact
      object.recipient = params[:user_id] =~ /\d+/ && @contact.users.find_by_id(params[:user_id]) || @contact.primary_user

      render :json => object
    end
  end

  protected

  def collection
    @email_templates ||= end_of_association_chain.order(:name).all
  end

  def default_ordered_on
    'name'
  end

  def default_ordered_dir
    'ASC'
  end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
e9_crm-0.1.26 app/controllers/e9_crm/email_templates.controller.rb
e9_crm-0.1.25 app/controllers/e9_crm/email_templates.controller.rb
e9_crm-0.1.24 app/controllers/e9_crm/email_templates.controller.rb
e9_crm-0.1.23 app/controllers/e9_crm/email_templates.controller.rb
e9_crm-0.1.22 app/controllers/e9_crm/email_templates.controller.rb
e9_crm-0.1.21 app/controllers/e9_crm/email_templates.controller.rb
e9_crm-0.1.20 app/controllers/e9_crm/email_templates.controller.rb
e9_crm-0.1.19 app/controllers/e9_crm/email_templates.controller.rb
e9_crm-0.1.18 app/controllers/e9_crm/email_templates.controller.rb
e9_crm-0.1.17 app/controllers/e9_crm/email_templates.controller.rb