闭社主体 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.

35 lines
744 B

  1. # frozen_string_literal: true
  2. class Admin::SettingsController < ApplicationController
  3. before_action :require_admin!
  4. layout 'admin'
  5. def index
  6. @settings = Setting.all_as_records
  7. end
  8. def update
  9. @setting = Setting.where(var: params[:id]).first_or_initialize(var: params[:id])
  10. value = settings_params[:value]
  11. # Special cases
  12. value = value == 'true' if @setting.var == 'open_registrations'
  13. if @setting.value != value
  14. @setting.value = value
  15. @setting.save
  16. end
  17. respond_to do |format|
  18. format.html { redirect_to admin_settings_path }
  19. format.json { respond_with_bip(@setting) }
  20. end
  21. end
  22. private
  23. def settings_params
  24. params.require(:setting).permit(:value)
  25. end
  26. end