80 lines
1.3 KiB
Ruby
80 lines
1.3 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Public::KapsDaysController < ApplicationController
|
|
layout "public"
|
|
before_filter :auth_p_customer
|
|
|
|
def today
|
|
@kaps_day = current_p_customer.kaps_days.where(:date => Date.today).first
|
|
|
|
render :action => :show
|
|
end
|
|
|
|
|
|
def index
|
|
@kaps_days = current_p_customer.kaps_days.order("date DESC").all
|
|
|
|
|
|
end
|
|
|
|
def show
|
|
@kaps_day = current_p_customer.kaps_days.find(params[:id])
|
|
|
|
end
|
|
|
|
def new
|
|
|
|
|
|
@kaps_day = current_p_customer.kaps_days.new
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
|
|
@kaps_day = current_p_customer.kaps_days.find(params[:id])
|
|
end
|
|
|
|
def create
|
|
@kaps_day = current_p_customer.kaps_days.new(params.require(:kaps_day).permit!)
|
|
@kaps_day.p_customer = current_p_customer
|
|
|
|
if @kaps_day.save
|
|
@kaps_days = current_p_customer.kaps_days.order(:name).all
|
|
|
|
else
|
|
render action: "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@kaps_day = current_p_customer.kaps_days.find(params[:id])
|
|
|
|
|
|
if @kaps_day.update_attributes(params.require(:kaps_day).permit!)
|
|
|
|
@kaps_days = current_p_customer.kaps_days.order(:name).all
|
|
else
|
|
render action: "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@kaps_day = current_p_customer.kaps_days.find(params[:id])
|
|
@kaps_day.kapsmes.destroy_all
|
|
|
|
redirect_to public_kaps_day_path(@kaps_day)
|
|
|
|
|
|
end
|
|
end
|