Add JSON response format to entropy endpoints (#2673)
* Add JSON response format to entropy endpoints Add account settings JSON endpoint returning account info including auto_postpone_period. Add auto_postpone_period to board JSON responses. Add JSON update support to both account and board entropy controllers. * Add auto_postpone_period to all board response examples in API docs * Use auto_postpone_period_in_days in JSON responses and API docs * Use valid period values in permission tests
This commit is contained in:
@@ -4,11 +4,12 @@ class Account::EntropiesController < ApplicationController
|
||||
before_action :ensure_admin
|
||||
|
||||
def update
|
||||
Current.account.entropy.update!(entropy_params)
|
||||
@account = Current.account
|
||||
@account.entropy.update!(entropy_params)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to account_settings_path, notice: "Account updated" }
|
||||
format.json { head :no_content }
|
||||
format.json { render "account/settings/show", status: :ok }
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
head :unprocessable_entity
|
||||
|
||||
@@ -5,7 +5,10 @@ class Account::SettingsController < ApplicationController
|
||||
before_action :set_account
|
||||
|
||||
def show
|
||||
@users = @account.users.active.alphabetically.includes(:identity)
|
||||
respond_to do |format|
|
||||
format.html { @users = @account.users.active.alphabetically.includes(:identity) }
|
||||
format.json
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
@@ -10,7 +10,7 @@ class Boards::EntropiesController < ApplicationController
|
||||
|
||||
respond_to do |format|
|
||||
format.turbo_stream
|
||||
format.json { head :no_content }
|
||||
format.json { render "boards/show", status: :ok }
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
head :unprocessable_entity
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
json.(Current.account, :name)
|
||||
json.(@account, :id, :name, :cards_count)
|
||||
json.created_at @account.created_at.utc
|
||||
json.auto_postpone_period_in_days @account.entropy.auto_postpone_period_in_days
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
json.cache! board do
|
||||
json.(board, :id, :name, :all_access)
|
||||
json.created_at board.created_at.utc
|
||||
json.auto_postpone_period_in_days board.auto_postpone_period_in_days
|
||||
json.url board_url(board)
|
||||
|
||||
json.creator board.creator, partial: "users/user", as: :user
|
||||
|
||||
Reference in New Issue
Block a user