Run rubocop --fix-layout and remove encoding comments

This commit is contained in:
Patrick Gansterer 2021-03-01 15:27:26 +01:00
parent fa63e6e81d
commit ea2862fdef
283 changed files with 1164 additions and 1969 deletions

View file

@ -22,5 +22,4 @@ class Api::V1::ArticleCategoriesController < Api::V1::BaseController
def scope
ArticleCategory.all
end
end

View file

@ -51,26 +51,26 @@ class Api::V1::BaseController < ApplicationController
def not_found_handler(e)
# remove where-clauses from error message (not suitable for end-users)
msg = e.message.try {|m| m.sub(/\s*\[.*?\]\s*$/, '')} || 'Not found'
render status: 404, json: {error: 'not_found', error_description: msg}
msg = e.message.try { |m| m.sub(/\s*\[.*?\]\s*$/, '') } || 'Not found'
render status: 404, json: { error: 'not_found', error_description: msg }
end
def not_acceptable_handler(e)
msg = e.message || 'Data not acceptable'
render status: 422, json: {error: 'not_acceptable', error_description: msg}
render status: 422, json: { error: 'not_acceptable', error_description: msg }
end
def doorkeeper_unauthorized_render_options(error:)
{json: {error: error.name, error_description: error.description}}
{ json: { error: error.name, error_description: error.description } }
end
def doorkeeper_forbidden_render_options(error:)
{json: {error: error.name, error_description: error.description}}
{ json: { error: error.name, error_description: error.description } }
end
def permission_required_handler(e)
msg = e.message || 'Forbidden, user has no access'
render status: 403, json: {error: 'forbidden', error_description: msg}
render status: 403, json: { error: 'forbidden', error_description: msg }
end
# @todo something with ApplicationHelper#show_user

View file

@ -1,9 +1,7 @@
class Api::V1::ConfigsController < Api::V1::BaseController
before_action ->{ doorkeeper_authorize! 'config:user', 'config:read', 'config:write' }
before_action -> { doorkeeper_authorize! 'config:user', 'config:read', 'config:write' }
def show
render json: FoodsoftConfig, serializer: ConfigSerializer, root: 'config'
end
end

View file

@ -22,5 +22,4 @@ class Api::V1::FinancialTransactionClassesController < Api::V1::BaseController
def scope
FinancialTransactionClass.all
end
end

View file

@ -22,5 +22,4 @@ class Api::V1::FinancialTransactionTypesController < Api::V1::BaseController
def scope
FinancialTransactionType.includes(:bank_account, :financial_transaction_class)
end
end

View file

@ -1,7 +1,7 @@
class Api::V1::FinancialTransactionsController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'finance:read', 'finance:write' }
before_action -> { doorkeeper_authorize! 'finance:read', 'finance:write' }
def index
render_collection search_scope
@ -20,5 +20,4 @@ class Api::V1::FinancialTransactionsController < Api::V1::BaseController
def ransack_auth_object
:finance
end
end

View file

@ -1,5 +1,4 @@
class Api::V1::NavigationsController < Api::V1::BaseController
def show
# we don't use active_model_serializers here, because source is a Hash
render json: { navigation: transform(navigation) }
@ -20,5 +19,4 @@ class Api::V1::NavigationsController < Api::V1::BaseController
r
end
end
end

View file

@ -1,7 +1,7 @@
class Api::V1::OrderArticlesController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'orders:read', 'orders:write' }
before_action -> { doorkeeper_authorize! 'orders:read', 'orders:write' }
def index
render_collection search_scope

View file

@ -1,7 +1,7 @@
class Api::V1::OrdersController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'orders:read', 'orders:write' }
before_action -> { doorkeeper_authorize! 'orders:read', 'orders:write' }
def index
render_collection search_scope

View file

@ -1,7 +1,7 @@
class Api::V1::User::FinancialTransactionsController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'finance:user' }
before_action -> { doorkeeper_authorize! 'finance:user' }
before_action :require_ordergroup
before_action :require_minimum_balance, only: [:create]
before_action -> { require_config_enabled :use_self_service }, only: [:create]
@ -29,5 +29,4 @@ class Api::V1::User::FinancialTransactionsController < Api::V1::BaseController
def create_params
params.require(:financial_transaction).permit(:amount, :financial_transaction_type_id, :note)
end
end

View file

@ -1,7 +1,7 @@
class Api::V1::User::GroupOrderArticlesController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'group_orders:user' }
before_action -> { doorkeeper_authorize! 'group_orders:user' }
before_action :require_ordergroup
before_action :require_minimum_balance, only: [:create, :update] # destroy is ok
@ -62,10 +62,10 @@ class Api::V1::User::GroupOrderArticlesController < Api::V1::BaseController
end
def scope
GroupOrderArticle.
joins(:group_order).
includes(order_article: :article, group_order: :order).
where(group_orders: { ordergroup_id: current_ordergroup.id })
GroupOrderArticle
.joins(:group_order)
.includes(order_article: :article, group_order: :order)
.where(group_orders: { ordergroup_id: current_ordergroup.id })
end
def scope_for_update

View file

@ -1,6 +1,5 @@
class Api::V1::User::OrdergroupController < Api::V1::BaseController
before_action ->{ doorkeeper_authorize! 'finance:user' }, only: [:financial_overview]
before_action -> { doorkeeper_authorize! 'finance:user' }, only: [:financial_overview]
def financial_overview
ordergroup = Ordergroup.include_transaction_class_sum.find(current_ordergroup.id)
@ -19,5 +18,4 @@ class Api::V1::User::OrdergroupController < Api::V1::BaseController
}
}
end
end

View file

@ -1,9 +1,7 @@
class Api::V1::User::UsersController < Api::V1::BaseController
before_action ->{ doorkeeper_authorize! 'user:read', 'user:write' }
before_action -> { doorkeeper_authorize! 'user:read', 'user:write' }
def show
render json: current_user
end
end