trabajo-afectivo/app/controllers/taskbar_controller.rb

45 lines
1,022 B
Ruby
Raw Normal View History

2016-10-19 03:11:36 +00:00
# Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
2013-05-29 15:11:11 +00:00
class TaskbarController < ApplicationController
prepend_before_action :authentication_check
2013-05-29 15:11:11 +00:00
def index
current_user_tasks = Taskbar.where(user_id: current_user.id)
2013-05-29 15:11:11 +00:00
model_index_render_result(current_user_tasks)
end
def show
taskbar = Taskbar.find(params[:id])
access(taskbar)
2013-05-29 15:11:11 +00:00
model_show_render_item(taskbar)
end
def create
2015-04-27 14:53:29 +00:00
model_create_render(Taskbar, params)
2013-05-29 15:11:11 +00:00
end
def update
taskbar = Taskbar.find(params[:id])
access(taskbar)
2017-08-22 17:36:48 +00:00
taskbar.with_lock do
taskbar.update_attributes!(Taskbar.param_cleanup(params))
end
2013-05-31 15:16:33 +00:00
model_update_render_item(taskbar)
2013-05-29 15:11:11 +00:00
end
def destroy
taskbar = Taskbar.find(params[:id])
access(taskbar)
2017-08-22 17:36:48 +00:00
taskbar.with_lock do
taskbar.destroy
end
model_destroy_render_item()
2013-05-29 15:11:11 +00:00
end
2013-05-31 23:09:09 +00:00
private
2015-04-27 20:49:17 +00:00
def access(taskbar)
raise Exceptions::UnprocessableEntity, 'Not allowed to access this task.' if taskbar.user_id != current_user.id
end
2013-05-29 15:11:11 +00:00
end