class Public::AcceptedOffersController < ApplicationController
  layout "public"

  before_filter :auth_customer
  before_filter :check_enabled

  def download_devis
    @accepted_offer = AcceptedOffer.find(params[:id])
    if(@accepted_offer.customer.id != current_customer.id)
      flash[:error] = "Vous n'avez pas la permission de télécharger cette offre"
      redirect_back_or_default :root
    else
       @accepted_offer.state = :devis_downloaded
       @accepted_offer.save
      send_file @accepted_offer.devis.file.path
    end
  end

  def index
      @accepted_offer = AcceptedOffer.find(params[:id])
  end

end
