application_channel_controller.rb 788 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. class ApplicationChannelController < ApplicationController
  2. # Extending controllers has to define following constants:
  3. # PERMISSION = "admin.channel_xyz"
  4. # AREA = "XYZ::Account"
  5. def index
  6. render json: channels_data
  7. end
  8. def show
  9. model_show_render(Channel, params)
  10. end
  11. def create
  12. model_create_render(Channel, channel_params)
  13. end
  14. def update
  15. model_update_render(Channel, channel_params)
  16. end
  17. def enable
  18. channel.update!(active: true)
  19. render json: channel
  20. end
  21. def disable
  22. channel.update!(active: false)
  23. render json: channel
  24. end
  25. def destroy
  26. channel.destroy!
  27. render json: {}
  28. end
  29. private
  30. def channel
  31. @channel ||= Channel.lookup(id: params[:id])
  32. end
  33. def channel_params
  34. params.permit!.to_s
  35. end
  36. end