Class: PublicHolidaysController

Inherits:
ApplicationController show all
Defined in:
app/controllers/public_holidays_controller.rb

Constant Summary

Constants included from Localization

Localization::LOCALIZED_STRINGS

Instance Method Summary collapse

Methods inherited from ApplicationController

in_place_edit_for, #initialize

Methods included from ApplicationHelper

#back_or_link_to, #detour?, #detour_to, #display_notice, #h, #image_button_to, #image_detour_to, #image_link_to, #image_link_to_remote, #insert, #record, #resolution_image, #t, #update_task, #with_detour

Methods included from Localization

#l, load_localized_strings, #valid_language?

Constructor Details

This class inherits a constructor from ApplicationController

Instance Method Details

#createObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/public_holidays_controller.rb', line 23

def create
  @public_holiday = PublicHoliday.new(params[:public_holiday])
  if @public_holiday.save
    flash[:notice] = 'PublicHoliday was successfully created.'
    redirect_to :action => 'list'
  else
    render :action => 'new'
  end
end

#destroyObject



47
48
49
50
# File 'app/controllers/public_holidays_controller.rb', line 47

def destroy
  PublicHoliday.find(params[:id]).destroy
  redirect_to :action => 'list'
end

#editObject



33
34
35
# File 'app/controllers/public_holidays_controller.rb', line 33

def edit
  @public_holiday = PublicHoliday.find(params[:id])
end

#indexObject



2
3
4
5
# File 'app/controllers/public_holidays_controller.rb', line 2

def index
  list
  render :action => 'list'
end

#listObject



11
12
13
# File 'app/controllers/public_holidays_controller.rb', line 11

def list
  @public_holiday_pages, @public_holidays = paginate :public_holidays, :per_page => 10
end

#markObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/public_holidays_controller.rb', line 52

def mark
  if params[:public_holiday]
    on = params[:public_holiday][:on]
    marked = params[:public_holiday][:marked] == '1'
    @public_holiday = PublicHoliday.find(:first, :conditions => {:on => on})
    if marked
      if @public_holiday.nil?
        PublicHoliday.create!(:on => on)
      end
    else
      if @public_holiday
        @public_holiday.destroy
      end
    end
  end
  back_or_redirect_to :controller => 'works', :action => :daily_work_sheet
end

#newObject



19
20
21
# File 'app/controllers/public_holidays_controller.rb', line 19

def new
  @public_holiday = PublicHoliday.new
end

#showObject



15
16
17
# File 'app/controllers/public_holidays_controller.rb', line 15

def show
  @public_holiday = PublicHoliday.find(params[:id])
end

#updateObject



37
38
39
40
41
42
43
44
45
# File 'app/controllers/public_holidays_controller.rb', line 37

def update
  @public_holiday = PublicHoliday.find(params[:id])
  if @public_holiday.update_attributes(params[:public_holiday])
    flash[:notice] = 'PublicHoliday was successfully updated.'
    redirect_to :action => 'show', :id => @public_holiday
  else
    render :action => 'edit'
  end
end