2014-02-03 19:24:49 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2013-05-29 15:11:11 +00:00
|
|
|
class TaskbarController < ApplicationController
|
2015-05-07 11:23:55 +00:00
|
|
|
before_action :authentication_check
|
2013-05-29 15:11:11 +00:00
|
|
|
|
|
|
|
def index
|
2013-05-31 23:09:09 +00:00
|
|
|
|
2015-04-27 13:42:53 +00:00
|
|
|
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)
|
2013-05-31 23:09:09 +00:00
|
|
|
|
2013-05-29 15:11:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2013-05-31 23:09:09 +00:00
|
|
|
taskbar = Taskbar.find( params[:id] )
|
|
|
|
return if !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
|
2013-05-31 23:09:09 +00:00
|
|
|
taskbar = Taskbar.find( params[:id] )
|
|
|
|
return if !access(taskbar)
|
2013-05-29 15:11:11 +00:00
|
|
|
|
2013-05-31 23:09:09 +00:00
|
|
|
taskbar.update_attributes!( Taskbar.param_cleanup(params) )
|
2013-05-31 15:16:33 +00:00
|
|
|
model_update_render_item(taskbar)
|
2013-05-29 15:11:11 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2013-05-31 23:09:09 +00:00
|
|
|
taskbar = Taskbar.find( params[:id] )
|
|
|
|
return if !access(taskbar)
|
2013-05-29 15:11:11 +00:00
|
|
|
|
|
|
|
taskbar.destroy
|
2013-05-31 23:09:09 +00:00
|
|
|
model_destory_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
|
|
|
|
2013-06-12 15:59:58 +00:00
|
|
|
def access(taskbar)
|
|
|
|
if taskbar.user_id != current_user.id
|
2015-04-27 13:42:53 +00:00
|
|
|
render json: { error: 'Not allowed to access this task.' }, status: :unprocessable_entity
|
2013-06-12 15:59:58 +00:00
|
|
|
return false
|
2013-05-31 23:09:09 +00:00
|
|
|
end
|
2015-04-27 20:49:17 +00:00
|
|
|
true
|
2013-06-12 15:59:58 +00:00
|
|
|
end
|
2013-05-29 15:11:11 +00:00
|
|
|
end
|