闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
686 B

  1. # frozen_string_literal: true
  2. module ExportControllerConcern
  3. extend ActiveSupport::Concern
  4. included do
  5. before_action :authenticate_user!
  6. before_action :require_not_suspended!
  7. before_action :load_export
  8. skip_before_action :require_functional!
  9. end
  10. private
  11. def load_export
  12. @export = Export.new(current_account)
  13. end
  14. def send_export_file
  15. respond_to do |format|
  16. format.csv { send_data export_data, filename: export_filename }
  17. end
  18. end
  19. def export_data
  20. raise 'Override in controller'
  21. end
  22. def export_filename
  23. "#{controller_name}.csv"
  24. end
  25. def require_not_suspended!
  26. forbidden if current_account.suspended?
  27. end
  28. end