aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/admin_holiday_imports_controller.rb
blob: 8596936f0d53e8cafa4179ea6393e0dd1fc28c0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class AdminHolidayImportsController < AdminController

    def new
        @holiday_import = HolidayImport.new(holiday_import_params)
        @holiday_import.populate if @holiday_import.valid?
    end

    def create
        @holiday_import = HolidayImport.new(holiday_import_params)
        if @holiday_import.save
            notice = "Holidays successfully imported"
            redirect_to admin_holidays_path, :notice => notice
        else
            render :new
        end
    end

    private

    def holiday_import_params(key = :holiday_import)
        if params[key]
            params[key].slice(:holidays_attributes, :start_year, :end_year, :source, :ical_feed_url)
        else
            {}
        end
    end

end