82 lines
1.5 KiB
Ruby
Executable File
82 lines
1.5 KiB
Ruby
Executable File
class Admin::AnnoncesController < ApplicationController
|
|
layout "admin"
|
|
|
|
before_filter :auth_admin
|
|
|
|
|
|
def index
|
|
|
|
|
|
end
|
|
|
|
|
|
def show
|
|
@annonce = Annonce.find(params[:id])
|
|
@no_search = true
|
|
session[:mail_prev] = public_annonce_path(@annonce)
|
|
|
|
params[:p] = @annonce.customer.mlm_token.upcase if !cookies[:mlm_token] and @annonce.customer.credits_boughts(Date.today) > 0
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
params[:step] = "info"
|
|
@annonce = current_customer.annonces.find(params[:id])
|
|
@no_search = true
|
|
|
|
@create = true if params[:create]
|
|
end
|
|
|
|
|
|
def update
|
|
params[:step] = "info"
|
|
@create = true if params[:create]
|
|
@annonce = Annonce.find(params[:id])
|
|
|
|
|
|
if params[:annonce][:refused] == "NULL"
|
|
@annonce.refused = nil
|
|
@annonce.save
|
|
params[:annonce][:refused] =nil
|
|
end
|
|
|
|
respond_to do |format|
|
|
if @annonce.update_attributes(params.require(:annonce).permit!)
|
|
|
|
|
|
format.html {
|
|
redirect_to public_my_account_path
|
|
}
|
|
format.js
|
|
|
|
else
|
|
|
|
format.html { render :action => "edit" }
|
|
format.js { render :action => "edit" }
|
|
end
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@annonce = current_customer.annonces.find(params[:id])
|
|
@annonce.enabled = nil
|
|
@annonce.save
|
|
|
|
redirect_to public_my_account_path, :notice => "Votre annonce a bien été désactivée"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|