calendar/app/controllers/admin/calendar_types_controller.rb

62 lines
1.4 KiB
Ruby

class Admin::CalendarTypesController < OrbitAdminController
# include AdminHelper
# GET /events
# GET /events.json
def initialize
super
@app_title = "calendar"
end
def index
@calendars = CalendarType.all rescue []
@calendar_type = CalendarType.new
respond_to do |format|
format.html # index.html.erb
format.json { render json: @calendars.to_json }
end
end
def new
@calendar = CalendarType.new
end
def create
calendar = CalendarType.new
category = Category.new
category.title_translations = calendar_type_params["title_translations"]
category.module_app_id = @module_app.id
category.save
calendar.update_attributes(calendar_type_params)
calendar.category = category
calendar.save
redirect_to admin_calendar_types_path
end
def update
calendar = CalendarType.find(params[:id]) rescue nil
if !calendar.nil?
calendar.update_attributes(calendar_type_params)
calendar.save
category = calendar.category
category.title_translations = calendar_type_params["title_translations"]
category.save
end
redirect_to admin_calendar_types_path
end
def list
@module_app_id = @module_app.id rescue nil
@calendars = CalendarType.all rescue []
render :layout => false
end
private
def calendar_type_params
params.require(:calendar_type).permit!
end
end