Skip to content

Commit

Permalink
Run rubocop --fix-layout and remove encoding comments
Browse files Browse the repository at this point in the history
  • Loading branch information
paroga committed Mar 2, 2021
1 parent fa63e6e commit ea2862f
Show file tree
Hide file tree
Showing 283 changed files with 1,164 additions and 1,969 deletions.
524 changes: 17 additions & 507 deletions .rubocop_todo.yml

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ gem 'uglifier', '>= 1.0.3'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby


gem 'jquery-rails'
gem 'select2-rails'
gem 'rails_tokeninput'
Expand Down Expand Up @@ -67,10 +66,9 @@ gem 'foodsoft_links', path: 'plugins/links'
gem 'foodsoft_polls', path: 'plugins/polls'

# plugins not enabled by default
#gem 'foodsoft_current_orders', path: 'plugins/current_orders'
#gem 'foodsoft_printer', path: 'plugins/printer'
#gem 'foodsoft_uservoice', path: 'plugins/uservoice'

# gem 'foodsoft_current_orders', path: 'plugins/current_orders'
# gem 'foodsoft_printer', path: 'plugins/printer'
# gem 'foodsoft_uservoice', path: 'plugins/uservoice'

group :development do
gem 'sqlite3', '~> 1.3.6'
Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ def index
@groups = Group.where(deleted_at: nil).order('created_on DESC').limit(10)
@users = User.order('created_on DESC').limit(10)
end

end
6 changes: 2 additions & 4 deletions app/controllers/admin/configs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class Admin::ConfigsController < Admin::BaseController

before_action :get_tabs, only: [:show, :list]

def show
Expand All @@ -11,7 +10,7 @@ def list
@current_tab = 'list'
@cfg = FoodsoftConfig
@dfl = FoodsoftConfig.config
@keys = FoodsoftConfig.keys.select {|k| FoodsoftConfig.allowed_key?(k)}.sort
@keys = FoodsoftConfig.keys.select { |k| FoodsoftConfig.allowed_key?(k) }.sort
end

def update
Expand Down Expand Up @@ -56,10 +55,9 @@ def parse_recurring_selects!(config)

def convert_config_value(value)
if value.is_a? ActionController::Parameters
value.transform_values{ |v| convert_config_value(v) }.to_hash
value.transform_values { |v| convert_config_value(v) }.to_hash
else
value
end
end

end
1 change: 0 additions & 1 deletion app/controllers/admin/finances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ def update_transaction_types
@financial_transaction_classes = FinancialTransactionClass.includes(:financial_transaction_types).order('name ASC')
render :layout => false
end

end
1 change: 0 additions & 1 deletion app/controllers/admin/ordergroups_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
class Admin::OrdergroupsController < Admin::BaseController
inherit_resources

Expand Down
1 change: 0 additions & 1 deletion app/controllers/admin/workgroups_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
class Admin::WorkgroupsController < Admin::BaseController
inherit_resources

Expand Down
1 change: 0 additions & 1 deletion app/controllers/api/v1/article_categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ def default_per_page
def scope
ArticleCategory.all
end

end
12 changes: 6 additions & 6 deletions app/controllers/api/v1/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,26 @@ def skip_session

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
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/api/v1/configs_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ def default_per_page
def scope
FinancialTransactionClass.all
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,4 @@ def default_per_page
def scope
FinancialTransactionType.includes(:bank_account, :financial_transaction_class)
end

end
3 changes: 1 addition & 2 deletions app/controllers/api/v1/financial_transactions_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,5 +20,4 @@ def scope
def ransack_auth_object
:finance
end

end
2 changes: 0 additions & 2 deletions app/controllers/api/v1/navigations_controller.rb
Original file line number Diff line number Diff line change
@@ -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) }
Expand All @@ -20,5 +19,4 @@ def transform(items)
r
end
end

end
2 changes: 1 addition & 1 deletion app/controllers/api/v1/order_articles_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/orders_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
Expand Down Expand Up @@ -29,5 +29,4 @@ def scope
def create_params
params.require(:financial_transaction).permit(:amount, :financial_transaction_type_id, :note)
end

end
10 changes: 5 additions & 5 deletions app/controllers/api/v1/user/group_order_articles_controller.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -62,10 +62,10 @@ def max_per_page
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
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/api/v1/user/ordergroup_controller.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -19,5 +18,4 @@ def financial_overview
}
}
end

end
4 changes: 1 addition & 3 deletions app/controllers/api/v1/user/users_controller.rb
Original file line number Diff line number Diff line change
@@ -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
9 changes: 3 additions & 6 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# encoding: utf-8
class ApplicationController < ActionController::Base
include Concerns::FoodcoopScope
include Concerns::Auth
Expand All @@ -8,11 +7,10 @@ class ApplicationController < ActionController::Base
helper_method :available_locales

protect_from_forgery
before_action :authenticate, :set_user_last_activity, :store_controller, :items_per_page
before_action :authenticate, :set_user_last_activity, :store_controller, :items_per_page
after_action :remove_controller
around_action :set_time_zone, :set_currency


# Returns the controller handling the current request.
def self.current
Thread.current[:application_controller]
Expand Down Expand Up @@ -90,10 +88,9 @@ def set_currency
old_currency = ::I18n.t('number.currency.format.unit')
new_currency = FoodsoftConfig[:currency_unit] || ''
new_currency += "\u202f" if FoodsoftConfig[:currency_space]
::I18n.backend.store_translations(::I18n.locale, number: {currency: {format: {unit: new_currency}}})
::I18n.backend.store_translations(::I18n.locale, number: { currency: { format: { unit: new_currency } } })
yield
ensure
::I18n.backend.store_translations(::I18n.locale, number: {currency: {format: {unit: old_currency}}})
::I18n.backend.store_translations(::I18n.locale, number: { currency: { format: { unit: old_currency } } })
end

end
2 changes: 0 additions & 2 deletions app/controllers/article_categories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class ArticleCategoriesController < ApplicationController

inherit_resources # Build default REST Actions via plugin

before_action :authenticate_article_meta
Expand All @@ -23,5 +22,4 @@ def destroy
def collection
@article_categories = ArticleCategory.order('name')
end

end
Loading

0 comments on commit ea2862f

Please sign in to comment.