Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/controllers/account/entropies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ class Account::EntropiesController < ApplicationController

def update
Current.account.entropy.update!(entropy_params)
redirect_to account_settings_path, notice: "Account updated"

respond_to do |format|
format.html { redirect_to account_settings_path, notice: "Account updated" }
format.json { head :no_content }
end
end

private
Expand Down
16 changes: 13 additions & 3 deletions app/controllers/account/exports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,20 @@ class Account::ExportsController < ApplicationController
CURRENT_EXPORT_LIMIT = 10

def show
respond_to do |format|
format.html
format.json { @export ? render(:show) : head(:not_found) }
end
end

def create
Current.account.exports.create!(user: Current.user).build_later
redirect_to account_settings_path, notice: "Export started. You'll receive an email when it's ready."
@export = Current.account.exports.create!(user: Current.user)
@export.build_later

respond_to do |format|
format.html { redirect_to account_settings_path, notice: "Export started. You'll receive an email when it's ready." }
format.json { render :show, status: :created }
end
end

private
Expand All @@ -23,6 +32,7 @@ def ensure_export_limit_not_exceeded
end

def set_export
@export = Current.account.exports.completed.find_by(id: params[:id], user: Current.user)
scope = request.format.json? ? Current.account.exports : Current.account.exports.completed
@export = scope.find_by(id: params[:id], user: Current.user)
end
end
18 changes: 15 additions & 3 deletions app/controllers/account/join_codes_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Account::JoinCodesController < ApplicationController
wrap_parameters :account_join_code

before_action :set_join_code
before_action :ensure_admin, only: %i[ update destroy ]

Expand All @@ -10,15 +12,25 @@ def edit

def update
if @join_code.update(join_code_params)
redirect_to account_join_code_path
respond_to do |format|
format.html { redirect_to account_join_code_path }
format.json { head :no_content }
end
else
render :edit, status: :unprocessable_entity
respond_to do |format|
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @join_code.errors, status: :unprocessable_entity }
end
end
end

def destroy
@join_code.reset
redirect_to account_join_code_path

respond_to do |format|
format.html { redirect_to account_join_code_path }
format.json { head :no_content }
end
end

private
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/account/settings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Account::SettingsController < ApplicationController
wrap_parameters :account

before_action :ensure_admin, only: :update
before_action :set_account

Expand All @@ -8,7 +10,11 @@ def show

def update
@account.update!(account_params)
redirect_to account_settings_path

respond_to do |format|
format.html { redirect_to account_settings_path }
format.json { head :no_content }
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/boards/columns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create

respond_to do |format|
format.turbo_stream
format.json { head :created, location: board_column_path(@board, @column, format: :json) }
format.json { render :show, status: :created, location: board_column_path(@board, @column, format: :json) }
end
end

Expand Down
7 changes: 7 additions & 0 deletions app/controllers/boards/entropies_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
class Boards::EntropiesController < ApplicationController
wrap_parameters :board

include BoardScoped

before_action :ensure_permission_to_admin_board

def update
@board.update!(entropy_params)

respond_to do |format|
format.turbo_stream
format.json { head :no_content }
end
end

private
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/boards/involvements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ class Boards::InvolvementsController < ApplicationController

def update
@board.access_for(Current.user).update!(involvement: params[:involvement])

respond_to do |format|
format.html
format.turbo_stream
format.json { head :no_content }
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/boards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def create

respond_to do |format|
format.html { redirect_to board_path(@board) }
format.json { head :created, location: board_path(@board, format: :json) }
format.json { render :show, status: :created, location: board_path(@board, format: :json) }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cards/comments/reactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def create

respond_to do |format|
format.turbo_stream { render "reactions/create" }
format.json { head :created }
format.json { render "reactions/show", status: :created }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cards/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def create

respond_to do |format|
format.turbo_stream
format.json { head :created, location: card_comment_path(@card, @comment, format: :json) }
format.json { render :show, status: :created, location: card_comment_path(@card, @comment, format: :json) }
end
end

Expand Down
16 changes: 11 additions & 5 deletions app/controllers/cards/publishes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ class Cards::PublishesController < ApplicationController
def create
@card.publish

if add_another_param?
card = @board.cards.create!(status: :drafted)
redirect_to card_draft_path(card), notice: "Card added"
else
redirect_to @card.board
respond_to do |format|
format.html do
if add_another_param?
card = @board.cards.create!(status: :drafted)
redirect_to card_draft_path(card), notice: "Card added"
else
redirect_to @card.board
end
end
Comment thread
jeremy marked this conversation as resolved.

format.json { head :created }
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/cards/reactions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def create

respond_to do |format|
format.turbo_stream { render "reactions/create" }
format.json { head :created }
format.json { render "reactions/show", status: :created }
end
end

Expand Down
10 changes: 10 additions & 0 deletions app/controllers/cards/readings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ class Cards::ReadingsController < ApplicationController
def create
@notification = @card.read_by(Current.user)
record_board_access

respond_to do |format|
format.turbo_stream
format.json { head :created }
end
end

def destroy
@notification = @card.unread_by(Current.user)
record_board_access

respond_to do |format|
format.turbo_stream
format.json { head :no_content }
end
end

private
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/cards/steps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ class Cards::StepsController < ApplicationController

before_action :set_step, only: %i[ show edit update destroy ]

def index
fresh_when etag: @card.steps
Comment thread
jeremy marked this conversation as resolved.
end
Comment thread
jeremy marked this conversation as resolved.

def create
@step = @card.steps.create!(step_params)

respond_to do |format|
format.turbo_stream
format.json { head :created, location: card_step_path(@card, @step, format: :json) }
format.json { render :show, status: :created, location: card_step_path(@card, @step, format: :json) }
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/cards_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def create
end

format.json do
card = @board.cards.create! card_params.merge(creator: Current.user, status: "published")
head :created, location: card_path(card, format: :json)
@card = @board.cards.create! card_params.merge(creator: Current.user, status: "published")
render :show, status: :created, location: card_path(@card, format: :json)
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions app/controllers/columns/left_positions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ class Columns::LeftPositionsController < ApplicationController
def create
@left_column = @column.left_column
@column.move_left

respond_to do |format|
format.turbo_stream
format.json { head :created }
end
end
end
5 changes: 5 additions & 0 deletions app/controllers/columns/right_positions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ class Columns::RightPositionsController < ApplicationController
def create
@right_column = @column.right_column
@column.move_right

respond_to do |format|
format.turbo_stream
format.json { head :created }
end
end
end
11 changes: 9 additions & 2 deletions app/controllers/my/access_tokens_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class My::AccessTokensController < ApplicationController
skip_before_action :require_account

def index
@access_tokens = my_access_tokens.order(created_at: :desc)
end
Expand All @@ -24,14 +26,19 @@ def create

format.json do
render status: :created, json: \
{ token: access_token.token, description: access_token.description, permission: access_token.permission }
{ id: access_token.id, token: access_token.token, description: access_token.description,
permission: access_token.permission, created_at: access_token.created_at.utc }
Comment thread
jeremy marked this conversation as resolved.
end
end
end

def destroy
my_access_tokens.find(params[:id]).destroy!
redirect_to my_access_tokens_path

respond_to do |format|
format.html { redirect_to my_access_tokens_path }
format.json { head :no_content }
end
end

private
Expand Down
8 changes: 7 additions & 1 deletion app/controllers/notifications/settings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Notifications::SettingsController < ApplicationController
wrap_parameters :user_settings

before_action :set_settings

def show
Expand All @@ -7,7 +9,11 @@ def show

def update
@settings.update!(settings_params)
redirect_to notifications_settings_path, notice: "Settings updated"

respond_to do |format|
format.html { redirect_to notifications_settings_path, notice: "Settings updated" }
format.json { head :no_content }
end
end

private
Expand Down
18 changes: 15 additions & 3 deletions app/controllers/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ def show
@query = params[:q].blank? ? nil : params[:q]

if card = Current.user.accessible_cards.find_by_id(@query)
@card = card
respond_to do |format|
format.html { @card = card }
format.json { set_page_and_extract_portion_from Current.user.accessible_cards.where(id: card.id) }
Comment thread
jeremy marked this conversation as resolved.
end
else
set_page_and_extract_portion_from Current.user.search(@query)
@recent_search_queries = Current.user.search_queries.order(updated_at: :desc).limit(10)
respond_to do |format|
format.html do
set_page_and_extract_portion_from Current.user.search(@query)
@recent_search_queries = Current.user.search_queries.order(updated_at: :desc).limit(10)
end
Comment thread
jeremy marked this conversation as resolved.

format.json do
set_page_and_extract_portion_from \
Current.user.accessible_cards.mentioning(@query, user: Current.user).distinct.latest.preloaded
Comment thread
jeremy marked this conversation as resolved.
end
end
end
end
end
6 changes: 5 additions & 1 deletion app/controllers/users/avatars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ def show

def destroy
@user.avatar.destroy
redirect_to @user

respond_to do |format|
format.html { redirect_to @user }
format.json { head :no_content }
end
end

private
Expand Down
13 changes: 11 additions & 2 deletions app/controllers/users/push_subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ def index
end

def create
@push_subscriptions.create_with(user_agent: request.user_agent).create_or_find_by!(push_subscription_params)
subscription = @push_subscriptions.create_with(user_agent: request.user_agent).create_or_find_by!(push_subscription_params)

respond_to do |format|
format.html { head :no_content }
format.json { head :created }
end
Comment thread
jeremy marked this conversation as resolved.
end

def destroy
@push_subscriptions.destroy_by(id: params[:id])
redirect_to user_push_subscriptions_url

respond_to do |format|
format.html { redirect_to user_push_subscriptions_url }
format.json { head :no_content }
end
end

private
Expand Down
Loading