Class: ConcertoTemplateScheduling::SchedulesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- ConcertoTemplateScheduling::SchedulesController
- Defined in:
- app/controllers/concerto_template_scheduling/schedules_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /schedules POST /schedules.json.
-
#destroy ⇒ Object
DELETE /schedules/1 DELETE /schedules/1.json.
-
#edit ⇒ Object
GET /schedules/1/edit.
-
#index ⇒ Object
GET /schedules GET /schedules.json.
-
#new ⇒ Object
GET /schedules/new GET /schedules/new.json.
- #schedule_params ⇒ Object
-
#show ⇒ Object
GET /schedules/1 GET /schedules/1.json.
-
#update ⇒ Object
PUT /schedules/1 PUT /schedules/1.json.
Instance Method Details
#create ⇒ Object
POST /schedules POST /schedules.json
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/concerto_template_scheduling/schedules_controller.rb', line 58 def create @schedule = Schedule.new(schedule_params) auth! :action => :update, :object => @schedule.screen respond_to do |format| if @schedule.save process_notification(@schedule, {:screen_id => @schedule.screen_id, :screen_name => @schedule.screen.name, :template_id => @schedule.template.id, :template_name => @schedule.template.name }, :key => 'concerto_template_scheduling.schedule.create', :owner => current_user, :action => 'create') format.html { redirect_to @schedule, notice: 'Schedule was successfully created.' } format.json { render json: @schedule, status: :created, location: @schedule } else format.html { render action: "new" } format.json { render json: @schedule.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /schedules/1 DELETE /schedules/1.json
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'app/controllers/concerto_template_scheduling/schedules_controller.rb', line 99 def destroy @schedule = Schedule.find(params[:id]) auth! :action => :update, :object => @schedule.screen process_notification(@schedule, {:screen_id => @schedule.screen_id, :screen_name => @schedule.screen.name, :template_id => @schedule.template.id, :template_name => @schedule.template.name }, :key => 'concerto_template_scheduling.schedule.destroy', :owner => current_user, :action => 'destroy') @schedule.destroy respond_to do |format| format.html { redirect_to schedules_url } format.json { head :no_content } end end |
#edit ⇒ Object
GET /schedules/1/edit
51 52 53 54 |
# File 'app/controllers/concerto_template_scheduling/schedules_controller.rb', line 51 def edit @schedule = Schedule.find(params[:id]) auth! :action => :update, :object => @schedule.screen end |
#index ⇒ Object
GET /schedules GET /schedules.json
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/concerto_template_scheduling/schedules_controller.rb', line 10 def index @schedules = Schedule.all # ignore the schedules that belong to screens we cant read # or schedules where the template has been deleted @schedules.to_a.reject! { |s| !can?(:read, s.screen) || s.template.nil? } respond_to do |format| format.html # index.html.erb format.json { render json: @schedules } end end |
#new ⇒ Object
GET /schedules/new GET /schedules/new.json
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/concerto_template_scheduling/schedules_controller.rb', line 36 def new @schedule = Schedule.new if !params[:screen_id].nil? # TODO: Error handling @schedule.screen = Screen.find(params[:screen_id]) end auth! :action => :update, :object => @schedule.screen respond_to do |format| format.html # new.html.erb format.json { render json: @schedule } end end |
#schedule_params ⇒ Object
113 114 115 |
# File 'app/controllers/concerto_template_scheduling/schedules_controller.rb', line 113 def schedule_params params.require(:schedule).permit(*ConcertoTemplateScheduling::Schedule.form_attributes) end |
#show ⇒ Object
GET /schedules/1 GET /schedules/1.json
24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/concerto_template_scheduling/schedules_controller.rb', line 24 def show @schedule = Schedule.find(params[:id]) auth! :action => :read, :object => @schedule.screen respond_to do |format| format.html # show.html.erb format.json { render json: @schedule } end end |
#update ⇒ Object
PUT /schedules/1 PUT /schedules/1.json
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/controllers/concerto_template_scheduling/schedules_controller.rb', line 78 def update @schedule = Schedule.find(params[:id]) auth! :action => :update, :object => @schedule.screen respond_to do |format| if @schedule.update_attributes(schedule_params) process_notification(@schedule, {:screen_id => @schedule.screen_id, :screen_name => @schedule.screen.name, :template_id => @schedule.template.id, :template_name => @schedule.template.name }, :key => 'concerto_template_scheduling.schedule.update', :owner => current_user, :action => 'update') format.html { redirect_to @schedule, notice: 'Schedule was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @schedule.errors, status: :unprocessable_entity } end end end |