72 lines
1.5 KiB
Ruby
72 lines
1.5 KiB
Ruby
class Admin::ContactActionsController < ApplicationController
|
|
layout "admin"
|
|
|
|
before_filter :auth_admin
|
|
|
|
def index
|
|
|
|
@contact_actions = ContactAction.order("created_at DESC").all
|
|
end
|
|
|
|
|
|
def show
|
|
@contact_action = ContactAction.find(params[:id])
|
|
|
|
@contact_action_actions = @contact_action.contact_action_actions
|
|
|
|
end
|
|
|
|
|
|
def new
|
|
@contact_action = ContactAction.new(:contact_id => params[:contact_id],:admin_id => current_admin.id, :action_at => Time.now)
|
|
|
|
end
|
|
|
|
def edit
|
|
@contact_action = ContactAction.find(params[:id])
|
|
@contact_action.action_at = @contact_action.action_at.in_time_zone("Paris")
|
|
end
|
|
|
|
def create
|
|
@contact_action = ContactAction.new(contact_action_params)
|
|
@contact = @contact_action.contact
|
|
|
|
if @contact_action.save
|
|
@contact_actions = @contact.contact_actions.order("action_at DESC").all
|
|
else
|
|
render :action => "new"
|
|
end
|
|
end
|
|
|
|
def update
|
|
@contact_action = ContactAction.find(params[:id])
|
|
@contact = @contact_action.contact
|
|
|
|
if @contact_action.update_attributes(contact_action_params)
|
|
@contact_actions = @contact.contact_actions.order("action_at DESC").all
|
|
else
|
|
render :action => "edit"
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
@contact_action = ContactAction.find(params[:id])
|
|
|
|
@contact_action.destroy
|
|
@contact = @contact_action.contact
|
|
@contact_actions = @contact.contact_actions.order("action_at DESC").all
|
|
|
|
end
|
|
|
|
private
|
|
def contact_action_params
|
|
params.require(:contact_action).permit!
|
|
end
|
|
|
|
|
|
|
|
end
|