calendars_controller.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Copyright (C) 2012-2016 Zammad Foundation, http://zammad-foundation.org/
  2. class CalendarsController < ApplicationController
  3. prepend_before_action -> { authentication_check(permission: 'admin.calendar') }, only: %i[init index show create update destroy]
  4. prepend_before_action -> { authentication_check(permission: 'admin') }, only: %i[timezones]
  5. def init
  6. assets = {}
  7. record_ids = []
  8. Calendar.all.order(:name, :created_at).each do |calendar|
  9. record_ids.push calendar.id
  10. assets = calendar.assets(assets)
  11. end
  12. ical_feeds = Calendar.ical_feeds
  13. timezones = Calendar.timezones
  14. render json: {
  15. record_ids: record_ids,
  16. ical_feeds: ical_feeds,
  17. timezones: timezones,
  18. assets: assets,
  19. }, status: :ok
  20. end
  21. def index
  22. model_index_render(Calendar, params)
  23. end
  24. def show
  25. model_show_render(Calendar, params)
  26. end
  27. def create
  28. model_create_render(Calendar, params)
  29. end
  30. def update
  31. model_update_render(Calendar, params)
  32. end
  33. def destroy
  34. model_destroy_render(Calendar, params)
  35. end
  36. def timezones
  37. render json: {
  38. timezones: Calendar.timezones
  39. }
  40. end
  41. end