taskbar_controller.rb 949 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class TaskbarController < ApplicationController
  3. before_action :authentication_check
  4. def index
  5. current_user_tasks = Taskbar.where(user_id: current_user.id)
  6. model_index_render_result(current_user_tasks)
  7. end
  8. def show
  9. taskbar = Taskbar.find(params[:id])
  10. access(taskbar)
  11. model_show_render_item(taskbar)
  12. end
  13. def create
  14. model_create_render(Taskbar, params)
  15. end
  16. def update
  17. taskbar = Taskbar.find(params[:id])
  18. access(taskbar)
  19. taskbar.update_attributes!(Taskbar.param_cleanup(params))
  20. model_update_render_item(taskbar)
  21. end
  22. def destroy
  23. taskbar = Taskbar.find(params[:id])
  24. access(taskbar)
  25. taskbar.destroy
  26. model_destory_render_item()
  27. end
  28. private
  29. def access(taskbar)
  30. raise Exceptions::UnprocessableEntity, 'Not allowed to access this task.' if taskbar.user_id != current_user.id
  31. end
  32. end