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

@ -29,491 +29,6 @@ Gemspec/RequiredRubyVersion:
- 'plugins/uservoice/foodsoft_uservoice.gemspec' - 'plugins/uservoice/foodsoft_uservoice.gemspec'
- 'plugins/wiki/foodsoft_wiki.gemspec' - 'plugins/wiki/foodsoft_wiki.gemspec'
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: outdent, indent
Layout/AccessModifierIndentation:
Exclude:
- 'app/controllers/finance/financial_links_controller.rb'
- 'app/models/invite.rb'
- 'db/migrate/20130622095040_move_weekly_tasks.rb'
# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Exclude:
- 'app/controllers/finance/balancing_controller.rb'
- 'app/controllers/foodcoop/workgroups_controller.rb'
- 'app/helpers/deliveries_helper.rb'
- 'app/helpers/stockit_helper.rb'
- 'db/migrate/20140102170431_add_result_computed_to_group_order_articles.rb'
- 'plugins/discourse/app/controllers/discourse_login_controller.rb'
- 'plugins/discourse/app/controllers/discourse_sso_controller.rb'
- 'plugins/messages/lib/foodsoft_messages/user_link.rb'
- 'plugins/polls/app/controllers/polls_controller.rb'
- 'spec/models/user_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_element, with_fixed_indentation
Layout/ArrayAlignment:
Exclude:
- 'lib/render_pdf.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith.
# SupportedStylesAlignWith: either, start_of_block, start_of_line
Layout/BlockAlignment:
Exclude:
- 'db/migrate/008_create_orders.rb'
- 'db/migrate/20090120184410_road_to_version_three.rb'
- 'spec/api/v1/user/group_order_articles_spec.rb'
# Offense count: 86
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
# SupportedStyles: case, end
Layout/CaseIndentation:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Layout/ClosingParenthesisIndentation:
Exclude:
- 'app/helpers/stockit_helper.rb'
- 'app/models/group_order_article.rb'
- 'app/models/shared_article.rb'
- 'db/seeds/minimal.seeds.rb'
# Offense count: 4
# Cop supports --auto-correct.
Layout/CommentIndentation:
Exclude:
- 'app/controllers/concerns/auth_api.rb'
- 'app/controllers/finance/financial_transactions_controller.rb'
- 'app/documents/order_fax.rb'
- 'db/migrate/20090120184410_road_to_version_three.rb'
# Offense count: 51
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: leading, trailing
Layout/DotPosition:
Exclude:
- 'app/controllers/api/v1/user/group_order_articles_controller.rb'
- 'app/controllers/stockit_controller.rb'
- 'app/documents/order_fax.rb'
- 'app/models/order.rb'
- 'app/models/stock_article.rb'
- 'app/models/task.rb'
- 'lib/order_pdf.rb'
- 'plugins/current_orders/app/controllers/current_orders/group_orders_controller.rb'
- 'plugins/current_orders/app/controllers/current_orders/ordergroups_controller.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_articles.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb'
# Offense count: 3
# Cop supports --auto-correct.
Layout/ElseAlignment:
Exclude:
- 'app/helpers/group_orders_helper.rb'
# Offense count: 70
# Cop supports --auto-correct.
Layout/EmptyLineAfterGuardClause:
Enabled: false
# Offense count: 38
# Cop supports --auto-correct.
Layout/EmptyLineAfterMagicComment:
Enabled: false
# Offense count: 15
# Cop supports --auto-correct.
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Layout/EmptyLineBetweenDefs:
Exclude:
- 'app/helpers/finance/invoices_helper.rb'
- 'app/helpers/orders_helper.rb'
- 'app/models/group_order.rb'
- 'app/models/ordergroup.rb'
- 'app/models/task.rb'
- 'db/migrate/20181201000400_create_supplier_categories.rb'
- 'db/migrate/20181204000000_clear_invalid_invoices_from_orders.rb'
- 'db/migrate/20181204070000_create_stock_events.rb'
- 'lib/api/errors.rb'
- 'lib/foodsoft/expansion_variables.rb'
- 'lib/token_verifier.rb'
- 'plugins/wiki/app/helpers/pages_helper.rb'
- 'spec/support/shared_database.rb'
# Offense count: 55
# Cop supports --auto-correct.
Layout/EmptyLines:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: around, only_before
Layout/EmptyLinesAroundAccessModifier:
Exclude:
- 'db/migrate/20130622095040_move_weekly_tasks.rb'
# Offense count: 85
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Enabled: false
# Offense count: 147
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
Layout/EmptyLinesAroundClassBody:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
Layout/EmptyLinesAroundExceptionHandlingKeywords:
Exclude:
- 'app/controllers/articles_controller.rb'
- 'app/controllers/finance/balancing_controller.rb'
- 'plugins/wiki/app/controllers/pages_controller.rb'
# Offense count: 2
# Cop supports --auto-correct.
Layout/EmptyLinesAroundMethodBody:
Exclude:
- 'app/helpers/application_helper.rb'
- 'db/migrate/002_create_groups.rb'
# Offense count: 37
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
Layout/EmptyLinesAroundModuleBody:
Enabled: false
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Exclude:
- 'app/controllers/articles_controller.rb'
- 'app/controllers/concerns/auth.rb'
- 'app/controllers/concerns/send_order_pdf.rb'
- 'app/controllers/finance/financial_transactions_controller.rb'
- 'app/controllers/home_controller.rb'
- 'app/controllers/orders_controller.rb'
- 'app/helpers/group_orders_helper.rb'
- 'plugins/wiki/app/controllers/pages_controller.rb'
# Offense count: 57
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstArgumentIndentation:
Exclude:
- 'app/models/group_order_article.rb'
- 'app/models/shared_article.rb'
- 'db/seeds/minimal.seeds.rb'
- 'plugins/current_orders/app/controllers/current_orders/articles_controller.rb'
- 'plugins/current_orders/app/controllers/current_orders/ordergroups_controller.rb'
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Layout/FirstArrayElementIndentation:
Exclude:
- 'db/seeds/small.en.seeds.rb'
- 'db/seeds/small.nl.seeds.rb'
- 'lib/financial_transactions_csv.rb'
- 'lib/order_csv.rb'
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/FirstHashElementIndentation:
Exclude:
- 'app/controllers/finance/financial_transactions_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/models/group_order.rb'
- 'db/migrate/20130718183101_migrate_user_settings.rb'
- 'lib/bank_account_information_importer.rb'
# Offense count: 83
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Enabled: false
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, indented_internal_methods
Layout/IndentationConsistency:
Exclude:
- 'db/migrate/003_create_suppliers.rb'
- 'db/migrate/007_create_article_prices.rb'
- 'db/migrate/008_create_orders.rb'
- 'db/migrate/010_user_password_reset.rb'
- 'db/migrate/20090120184410_road_to_version_three.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IndentationWidth, EnforcedStyle.
# SupportedStyles: spaces, tabs
Layout/IndentationStyle:
Exclude:
- 'db/migrate/010_user_password_reset.rb'
# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'app/helpers/admin/configs_helper.rb'
- 'app/helpers/group_orders_helper.rb'
- 'app/models/user.rb'
- 'db/migrate/003_create_suppliers.rb'
- 'db/migrate/007_create_article_prices.rb'
- 'db/migrate/008_create_orders.rb'
- 'db/migrate/20090120184410_road_to_version_three.rb'
- 'lib/tasks/multicoops.rake'
- 'spec/api/v1/user/group_order_articles_spec.rb'
- 'spec/spec_helper.rb'
# Offense count: 39
# Cop supports --auto-correct.
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
Layout/LeadingCommentSpace:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Layout/LeadingEmptyLines:
Exclude:
- 'db/migrate/20090120184410_road_to_version_three.rb'
- 'db/seeds/seed_helper.rb'
- 'lib/order_txt.rb'
- 'spec/support/integration.rb'
- 'spec/support/session_helper.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'app/helpers/stockit_helper.rb'
# Offense count: 42
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'app/controllers/stockit_controller.rb'
- 'app/models/order.rb'
- 'app/models/ordergroup.rb'
- 'app/models/stock_article.rb'
- 'app/models/task.rb'
- 'lib/foodsoft/expansion_variables.rb'
- 'lib/order_pdf.rb'
- 'plugins/current_orders/app/controllers/current_orders/group_orders_controller.rb'
- 'plugins/current_orders/app/controllers/current_orders/ordergroups_controller.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb'
- 'spec/api/v1/user/group_order_articles_spec.rb'
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- 'app/helpers/orders_helper.rb'
- 'app/inputs/date_picker_time_input.rb'
- 'app/models/ordergroup.rb'
- 'app/models/task.rb'
- 'lib/apple_bar.rb'
# Offense count: 1
# Cop supports --auto-correct.
Layout/RescueEnsureAlignment:
Exclude:
- 'app/controllers/suppliers_controller.rb'
# Offense count: 9
# Cop supports --auto-correct.
Layout/SpaceAfterColon:
Exclude:
- 'app/controllers/styles_controller.rb'
- 'spec/integration/articles_spec.rb'
- 'spec/integration/balancing_spec.rb'
- 'spec/integration/order_spec.rb'
- 'spec/integration/receive_spec.rb'
- 'spec/integration/supplier_spec.rb'
- 'spec/models/order_article_spec.rb'
- 'spec/models/ordergroup_spec.rb'
# Offense count: 110
# Cop supports --auto-correct.
Layout/SpaceAfterComma:
Enabled: false
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleInsidePipes.
# SupportedStylesInsidePipes: space, no_space
Layout/SpaceAroundBlockParameters:
Exclude:
- 'app/models/group_order_article.rb'
- 'db/migrate/008_create_orders.rb'
# Offense count: 50
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: false
# Offense count: 109
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
# SupportedStylesForExponentOperator: space, no_space
Layout/SpaceAroundOperators:
Enabled: false
# Offense count: 73
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceBeforeBlockBraces:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
Layout/SpaceBeforeComma:
Exclude:
- 'db/migrate/016_add_shared_lists_connection.rb'
- 'lib/render_pdf.rb'
# Offense count: 1
# Cop supports --auto-correct.
Layout/SpaceBeforeComment:
Exclude:
- 'plugins/wiki/lib/foodsoft_wiki/wiki_parser.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceBeforeFirstArg:
Exclude:
- 'app/controllers/application_controller.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: require_no_space, require_space
Layout/SpaceInLambdaLiteral:
Exclude:
- 'plugins/messages/app/models/message.rb'
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBrackets: space, no_space
Layout/SpaceInsideArrayLiteralBrackets:
Exclude:
- 'app/helpers/orders_helper.rb'
- 'config/application.rb'
- 'config/environments/production.rb'
- 'db/migrate/20130718183100_create_settings.rb'
# Offense count: 148
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideBlockBraces:
Enabled: false
# Offense count: 374
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideHashLiteralBraces:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/SpaceInsideParens:
Exclude:
- 'app/helpers/group_orders_helper.rb'
- 'db/migrate/006_create_articles.rb'
- 'spec/api/v1/user/group_order_articles_spec.rb'
# Offense count: 14
# Cop supports --auto-correct.
Layout/SpaceInsidePercentLiteralDelimiters:
Exclude:
- 'lib/tasks/foodsoft_setup.rake'
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBrackets: space, no_space
Layout/SpaceInsideReferenceBrackets:
Exclude:
- 'lib/bank_account_information_importer.rb'
- 'lib/foodsoft_config.rb'
- 'spec/api/v1/user/ordergroup_spec.rb'
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'app/models/ordergroup.rb'
- 'config/initializers/bullet.rb'
- 'config/initializers/new_rails_defaults.rb'
- 'db/migrate/20130718183101_migrate_user_settings.rb'
- 'lib/apple_bar.rb'
- 'lib/tasks/foodsoft_setup.rake'
- 'spec/support/faker.rb'
# Offense count: 111
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Enabled: false
# Offense count: 8 # Offense count: 8
Lint/AmbiguousBlockAssociation: Lint/AmbiguousBlockAssociation:
Exclude: Exclude:
@ -529,13 +44,12 @@ Lint/AmbiguousOperator:
- 'app/mailers/mailer.rb' - 'app/mailers/mailer.rb'
- 'spec/models/order_article_spec.rb' - 'spec/models/order_article_spec.rb'
# Offense count: 3 # Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.
Lint/AmbiguousRegexpLiteral: Lint/AmbiguousRegexpLiteral:
Exclude: Exclude:
- 'app/models/article_category.rb' - 'app/models/article_category.rb'
- 'lib/foodsoft/expansion_variables.rb' - 'lib/foodsoft/expansion_variables.rb'
- 'lib/foodsoft_config.rb'
# Offense count: 40 # Offense count: 40
# Configuration parameters: AllowSafeAssignment. # Configuration parameters: AllowSafeAssignment.
@ -626,7 +140,7 @@ Lint/ParenthesesAsGroupedExpression:
- 'spec/lib/token_verifier_spec.rb' - 'spec/lib/token_verifier_spec.rb'
- 'spec/models/order_article_spec.rb' - 'spec/models/order_article_spec.rb'
# Offense count: 2 # Offense count: 1
Lint/ReturnInVoidContext: Lint/ReturnInVoidContext:
Exclude: Exclude:
- 'lib/foodsoft_config.rb' - 'lib/foodsoft_config.rb'
@ -721,12 +235,11 @@ Lint/UnusedMethodArgument:
- 'lib/render_pdf.rb' - 'lib/render_pdf.rb'
- 'plugins/wiki/lib/foodsoft_wiki/mailer.rb' - 'plugins/wiki/lib/foodsoft_wiki/mailer.rb'
# Offense count: 3 # Offense count: 2
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. # Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier: Lint/UselessAccessModifier:
Exclude: Exclude:
- 'lib/foodsoft_config.rb'
- 'lib/token_verifier.rb' - 'lib/token_verifier.rb'
- 'plugins/messages/app/models/messagegroup.rb' - 'plugins/messages/app/models/messagegroup.rb'
@ -746,6 +259,12 @@ Lint/UselessAssignment:
- 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb' - 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb'
- 'spec/lib/foodsoft_config_spec.rb' - 'spec/lib/foodsoft_config_spec.rb'
# Offense count: 1
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'lib/foodsoft_config.rb'
# Offense count: 158 # Offense count: 158
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize: Metrics/AbcSize:
@ -1082,7 +601,7 @@ RSpec/MultipleMemoizedHelpers:
RSpec/NestedGroups: RSpec/NestedGroups:
Max: 6 Max: 6
# Offense count: 32 # Offense count: 31
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle. # Configuration parameters: EnforcedStyle.
# SupportedStyles: not_to, to_not # SupportedStyles: not_to, to_not
@ -1092,7 +611,6 @@ RSpec/NotToNot:
- 'spec/api/v1/user/group_order_articles_spec.rb' - 'spec/api/v1/user/group_order_articles_spec.rb'
- 'spec/integration/balancing_spec.rb' - 'spec/integration/balancing_spec.rb'
- 'spec/integration/login_spec.rb' - 'spec/integration/login_spec.rb'
- 'spec/integration/order_spec.rb'
- 'spec/integration/receive_spec.rb' - 'spec/integration/receive_spec.rb'
- 'spec/integration/session_spec.rb' - 'spec/integration/session_spec.rb'
- 'spec/lib/token_verifier_spec.rb' - 'spec/lib/token_verifier_spec.rb'
@ -1520,14 +1038,13 @@ Security/YAMLLoad:
- 'lib/foodsoft_config.rb' - 'lib/foodsoft_config.rb'
- 'spec/api/v1/swagger_spec.rb' - 'spec/api/v1/swagger_spec.rb'
# Offense count: 4 # Offense count: 3
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle. # Configuration parameters: EnforcedStyle.
# SupportedStyles: prefer_alias, prefer_alias_method # SupportedStyles: prefer_alias, prefer_alias_method
Style/Alias: Style/Alias:
Exclude: Exclude:
- 'config/initializers/session_store.rb' - 'config/initializers/session_store.rb'
- 'lib/foodsoft_config.rb'
- 'plugins/discourse/lib/foodsoft_discourse/redirect_to_login.rb' - 'plugins/discourse/lib/foodsoft_discourse/redirect_to_login.rb'
- 'plugins/printer/lib/foodsoft_printer/order_printer_jobs.rb' - 'plugins/printer/lib/foodsoft_printer/order_printer_jobs.rb'
@ -1685,7 +1202,7 @@ Style/DefWithParentheses:
Exclude: Exclude:
- 'app/models/user.rb' - 'app/models/user.rb'
# Offense count: 306 # Offense count: 307
Style/Documentation: Style/Documentation:
Enabled: false Enabled: false
@ -1735,11 +1252,6 @@ Style/EmptyMethod:
- 'db/migrate/20140318173000_delete_empty_group_order_articles.rb' - 'db/migrate/20140318173000_delete_empty_group_order_articles.rb'
- 'lib/bank_account_connector.rb' - 'lib/bank_account_connector.rb'
# Offense count: 40
# Cop supports --auto-correct.
Style/Encoding:
Enabled: false
# Offense count: 21 # Offense count: 21
# Cop supports --auto-correct. # Cop supports --auto-correct.
Style/ExpandPathArguments: Style/ExpandPathArguments:
@ -1809,7 +1321,7 @@ Style/GlobalStdStream:
- 'lib/tasks/foodsoft.rake' - 'lib/tasks/foodsoft.rake'
- 'lib/tasks/foodsoft_setup.rake' - 'lib/tasks/foodsoft_setup.rake'
# Offense count: 63 # Offense count: 62
# Configuration parameters: MinBodyLength. # Configuration parameters: MinBodyLength.
Style/GuardClause: Style/GuardClause:
Enabled: false Enabled: false
@ -1822,7 +1334,7 @@ Style/HashAsLastArrayItem:
Exclude: Exclude:
- 'app/models/order.rb' - 'app/models/order.rb'
# Offense count: 7 # Offense count: 6
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AllowSplatArgument. # Configuration parameters: AllowSplatArgument.
Style/HashConversion: Style/HashConversion:
@ -1831,7 +1343,6 @@ Style/HashConversion:
- 'app/models/article.rb' - 'app/models/article.rb'
- 'app/models/order.rb' - 'app/models/order.rb'
- 'lib/bank_account_information_importer.rb' - 'lib/bank_account_information_importer.rb'
- 'lib/foodsoft_config.rb'
- 'plugins/wiki/app/controllers/pages_controller.rb' - 'plugins/wiki/app/controllers/pages_controller.rb'
- 'spec/api/v1/user/ordergroup_spec.rb' - 'spec/api/v1/user/ordergroup_spec.rb'
@ -2201,7 +1712,7 @@ Style/RedundantRegexpEscape:
- 'plugins/documents/app/controllers/documents_controller.rb' - 'plugins/documents/app/controllers/documents_controller.rb'
- 'plugins/wiki/app/models/page.rb' - 'plugins/wiki/app/models/page.rb'
# Offense count: 18 # Offense count: 15
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues. # Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn: Style/RedundantReturn:
@ -2216,7 +1727,6 @@ Style/RedundantReturn:
- 'app/models/periodic_task_group.rb' - 'app/models/periodic_task_group.rb'
- 'app/models/supplier.rb' - 'app/models/supplier.rb'
- 'lib/bank_transaction_reference.rb' - 'lib/bank_transaction_reference.rb'
- 'lib/foodsoft_config.rb'
# Offense count: 85 # Offense count: 85
# Cop supports --auto-correct. # Cop supports --auto-correct.
@ -2435,9 +1945,9 @@ Style/ZeroLengthPredicate:
- 'plugins/current_orders/app/documents/multiple_orders_by_articles.rb' - 'plugins/current_orders/app/documents/multiple_orders_by_articles.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb' - 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb'
# Offense count: 436 # Offense count: 447
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https # URISchemes: http, https
Layout/LineLength: Layout/LineLength:
Max: 414 Max: 420

View file

@ -9,7 +9,6 @@ gem 'uglifier', '>= 1.0.3'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes # See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby gem 'therubyracer', platforms: :ruby
gem 'jquery-rails' gem 'jquery-rails'
gem 'select2-rails' gem 'select2-rails'
gem 'rails_tokeninput' gem 'rails_tokeninput'
@ -71,7 +70,6 @@ gem 'foodsoft_polls', path: 'plugins/polls'
# gem 'foodsoft_printer', path: 'plugins/printer' # gem 'foodsoft_printer', path: 'plugins/printer'
# gem 'foodsoft_uservoice', path: 'plugins/uservoice' # gem 'foodsoft_uservoice', path: 'plugins/uservoice'
group :development do group :development do
gem 'sqlite3', '~> 1.3.6' gem 'sqlite3', '~> 1.3.6'
gem 'mailcatcher' gem 'mailcatcher'

View file

@ -6,5 +6,4 @@ class Admin::BaseController < ApplicationController
@groups = Group.where(deleted_at: nil).order('created_on DESC').limit(10) @groups = Group.where(deleted_at: nil).order('created_on DESC').limit(10)
@users = User.order('created_on DESC').limit(10) @users = User.order('created_on DESC').limit(10)
end end
end end

View file

@ -1,5 +1,4 @@
class Admin::ConfigsController < Admin::BaseController class Admin::ConfigsController < Admin::BaseController
before_action :get_tabs, only: [:show, :list] before_action :get_tabs, only: [:show, :list]
def show def show
@ -61,5 +60,4 @@ class Admin::ConfigsController < Admin::BaseController
value value
end end
end end
end end

View file

@ -15,5 +15,4 @@ class Admin::FinancesController < Admin::BaseController
@financial_transaction_classes = FinancialTransactionClass.includes(:financial_transaction_types).order('name ASC') @financial_transaction_classes = FinancialTransactionClass.includes(:financial_transaction_types).order('name ASC')
render :layout => false render :layout => false
end end
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class Admin::OrdergroupsController < Admin::BaseController class Admin::OrdergroupsController < Admin::BaseController
inherit_resources inherit_resources

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class Admin::WorkgroupsController < Admin::BaseController class Admin::WorkgroupsController < Admin::BaseController
inherit_resources inherit_resources

View file

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

View file

@ -1,9 +1,7 @@
class Api::V1::ConfigsController < Api::V1::BaseController 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 def show
render json: FoodsoftConfig, serializer: ConfigSerializer, root: 'config' render json: FoodsoftConfig, serializer: ConfigSerializer, root: 'config'
end end
end end

View file

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

View file

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

View file

@ -20,5 +20,4 @@ class Api::V1::FinancialTransactionsController < Api::V1::BaseController
def ransack_auth_object def ransack_auth_object
:finance :finance
end end
end end

View file

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

View file

@ -29,5 +29,4 @@ class Api::V1::User::FinancialTransactionsController < Api::V1::BaseController
def create_params def create_params
params.require(:financial_transaction).permit(:amount, :financial_transaction_type_id, :note) params.require(:financial_transaction).permit(:amount, :financial_transaction_type_id, :note)
end end
end end

View file

@ -62,10 +62,10 @@ class Api::V1::User::GroupOrderArticlesController < Api::V1::BaseController
end end
def scope def scope
GroupOrderArticle. GroupOrderArticle
joins(:group_order). .joins(:group_order)
includes(order_article: :article, group_order: :order). .includes(order_article: :article, group_order: :order)
where(group_orders: { ordergroup_id: current_ordergroup.id }) .where(group_orders: { ordergroup_id: current_ordergroup.id })
end end
def scope_for_update def scope_for_update

View file

@ -1,5 +1,4 @@
class Api::V1::User::OrdergroupController < Api::V1::BaseController 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 def financial_overview
@ -19,5 +18,4 @@ class Api::V1::User::OrdergroupController < Api::V1::BaseController
} }
} }
end end
end end

View file

@ -1,9 +1,7 @@
class Api::V1::User::UsersController < Api::V1::BaseController 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 def show
render json: current_user render json: current_user
end end
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
include Concerns::FoodcoopScope include Concerns::FoodcoopScope
include Concerns::Auth include Concerns::Auth
@ -12,7 +11,6 @@ class ApplicationController < ActionController::Base
after_action :remove_controller after_action :remove_controller
around_action :set_time_zone, :set_currency around_action :set_time_zone, :set_currency
# Returns the controller handling the current request. # Returns the controller handling the current request.
def self.current def self.current
Thread.current[:application_controller] Thread.current[:application_controller]
@ -95,5 +93,4 @@ class ApplicationController < ActionController::Base
ensure 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
end end

View file

@ -1,5 +1,4 @@
class ArticleCategoriesController < ApplicationController class ArticleCategoriesController < ApplicationController
inherit_resources # Build default REST Actions via plugin inherit_resources # Build default REST Actions via plugin
before_action :authenticate_article_meta before_action :authenticate_article_meta
@ -23,5 +22,4 @@ class ArticleCategoriesController < ApplicationController
def collection def collection
@article_categories = ArticleCategory.order('name') @article_categories = ArticleCategory.order('name')
end end
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class ArticlesController < ApplicationController class ArticlesController < ApplicationController
before_action :authenticate_article_meta, :find_supplier before_action :authenticate_article_meta, :find_supplier
@ -117,6 +116,7 @@ class ArticlesController < ApplicationController
# makes different actions on selected articles # makes different actions on selected articles
def update_selected def update_selected
raise I18n.t('articles.controller.error_nosel') if params[:selected_articles].nil? raise I18n.t('articles.controller.error_nosel') if params[:selected_articles].nil?
articles = Article.find(params[:selected_articles]) articles = Article.find(params[:selected_articles])
Article.transaction do Article.transaction do
case params[:selected_action] case params[:selected_action]
@ -135,7 +135,6 @@ class ArticlesController < ApplicationController
end end
# action succeded # action succeded
redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page]) redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page])
rescue => error rescue => error
redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page]), redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page]),
:alert => I18n.t('errors.general_msg', :msg => error) :alert => I18n.t('errors.general_msg', :msg => error)

View file

@ -137,6 +137,7 @@ module Concerns::Auth
# @see https://github.com/doorkeeper-gem/doorkeeper/issues/71#issuecomment-5471317 # @see https://github.com/doorkeeper-gem/doorkeeper/issues/71#issuecomment-5471317
def expire_access_tokens def expire_access_tokens
return unless @current_user return unless @current_user
Doorkeeper::AccessToken.transaction do Doorkeeper::AccessToken.transaction do
token_scope = Doorkeeper::AccessToken.where(revoked_at: nil, resource_owner_id: @current_user.id) token_scope = Doorkeeper::AccessToken.where(revoked_at: nil, resource_owner_id: @current_user.id)
token_scope.each do |token| token_scope.each do |token|
@ -149,5 +150,4 @@ module Concerns::Auth
def redirect_to_login(options = {}) def redirect_to_login(options = {})
redirect_to login_url, options redirect_to login_url, options
end end
end end

View file

@ -54,5 +54,4 @@ module Concerns::CollectionScope
def ransack_auth_object def ransack_auth_object
nil nil
end end
end end

View file

@ -32,5 +32,4 @@ module Concerns::FoodcoopScope
def default_url_options(options = {}) def default_url_options(options = {})
super().merge({ foodcoop: FoodsoftConfig.scope }) super().merge({ foodcoop: FoodsoftConfig.scope })
end end
end end

View file

@ -47,5 +47,4 @@ module Concerns::Locale
locale = session[:locale] = ::I18n.locale locale = session[:locale] = ::I18n.locale
logger.info("Set locale to #{locale}") logger.info("Set locale to #{locale}")
end end
end end

View file

@ -13,5 +13,4 @@ module Concerns::SendOrderPdf
pdf = klass.new order pdf = klass.new order
send_data pdf.to_pdf, filename: pdf.filename, type: 'application/pdf' send_data pdf.to_pdf, filename: pdf.filename, type: 'application/pdf'
end end
end end

View file

@ -1,6 +1,4 @@
# encoding: utf-8
class DeliveriesController < ApplicationController class DeliveriesController < ApplicationController
before_action :find_supplier, :exclude => :fill_new_stock_article_form before_action :find_supplier, :exclude => :fill_new_stock_article_form
def index def index
@ -68,5 +66,4 @@ class DeliveriesController < ApplicationController
render :layout => false render :layout => false
end end
end end

View file

@ -1,5 +1,4 @@
class FeedbackController < ApplicationController class FeedbackController < ApplicationController
def new def new
end end
@ -11,5 +10,4 @@ class FeedbackController < ApplicationController
render :action => 'new' render :action => 'new'
end end
end end
end end

View file

@ -1,6 +1,4 @@
# encoding: utf-8
class Finance::BalancingController < Finance::BaseController class Finance::BalancingController < Finance::BaseController
def index def index
@orders = Order.finished.page(params[:page]).per(@per_page).order('ends DESC') @orders = Order.finished.page(params[:page]).per(@per_page).order('ends DESC')
end end
@ -84,7 +82,6 @@ class Finance::BalancingController < Finance::BaseController
@type = FinancialTransactionType.find_by_id(params.permit(:type)[:type]) @type = FinancialTransactionType.find_by_id(params.permit(:type)[:type])
@order.close!(@current_user, @type) @order.close!(@current_user, @type)
redirect_to finance_order_index_url, notice: t('finance.balancing.close.notice') redirect_to finance_order_index_url, notice: t('finance.balancing.close.notice')
rescue => error rescue => error
redirect_to new_finance_order_url(order_id: @order.id), alert: t('finance.balancing.close.alert', message: error.message) redirect_to new_finance_order_url(order_id: @order.id), alert: t('finance.balancing.close.alert', message: error.message)
end end
@ -110,5 +107,4 @@ class Finance::BalancingController < Finance::BaseController
rescue => error rescue => error
redirect_to finance_order_index_url, alert: t('errors.general_msg', msg: error.message) redirect_to finance_order_index_url, alert: t('errors.general_msg', msg: error.message)
end end
end end

View file

@ -1,5 +1,4 @@
class Finance::BankAccountsController < Finance::BaseController class Finance::BankAccountsController < Finance::BaseController
def index def index
@bank_accounts = BankAccount.order('name') @bank_accounts = BankAccount.order('name')
redirect_to finance_bank_account_transactions_url(@bank_accounts.first) if @bank_accounts.count == 1 redirect_to finance_bank_account_transactions_url(@bank_accounts.first) if @bank_accounts.count == 1
@ -39,6 +38,7 @@ class Finance::BankAccountsController < Finance::BaseController
needs_redirect = true needs_redirect = true
ensure ensure
return unless needs_redirect return unless needs_redirect
redirect_path = finance_bank_account_transactions_url(@bank_account) redirect_path = finance_bank_account_transactions_url(@bank_account)
if request.post? if request.post?
@js_redirect = redirect_path @js_redirect = redirect_path
@ -46,5 +46,4 @@ class Finance::BankAccountsController < Finance::BaseController
redirect_to redirect_path redirect_to redirect_path
end end
end end
end end

View file

@ -128,5 +128,4 @@ private
JOIN bank_transactions b ON a.iban = b.iban AND b.financial_link_id = #{financial_link_id.to_i} JOIN bank_transactions b ON a.iban = b.iban AND b.financial_link_id = #{financial_link_id.to_i}
SQL SQL
end end
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class Finance::FinancialTransactionsController < ApplicationController class Finance::FinancialTransactionsController < ApplicationController
before_action :authenticate_finance before_action :authenticate_finance
before_action :find_ordergroup, :except => [:new_collection, :create_collection, :index_collection] before_action :find_ordergroup, :except => [:new_collection, :create_collection, :index_collection]
@ -79,6 +78,7 @@ class Finance::FinancialTransactionsController < ApplicationController
def create_collection def create_collection
raise I18n.t('finance.financial_transactions.controller.create_collection.error_note_required') if params[:note].blank? raise I18n.t('finance.financial_transactions.controller.create_collection.error_note_required') if params[:note].blank?
type = FinancialTransactionType.find_by_id(params[:type_id]) type = FinancialTransactionType.find_by_id(params[:type_id])
financial_link = nil financial_link = nil
@ -131,5 +131,4 @@ class Finance::FinancialTransactionsController < ApplicationController
@foodcoop = true @foodcoop = true
end end
end end
end end

View file

@ -1,5 +1,4 @@
class Finance::OrdergroupsController < Finance::BaseController class Finance::OrdergroupsController < Finance::BaseController
def index def index
m = /^(?<col>name|sum_of_class_\d+)(?<reverse>_reverse)?$/.match params["sort"] m = /^(?<col>name|sum_of_class_\d+)(?<reverse>_reverse)?$/.match params["sort"]
if m if m

View file

@ -1,5 +1,4 @@
class Foodcoop::OrdergroupsController < ApplicationController class Foodcoop::OrdergroupsController < ApplicationController
def index def index
@ordergroups = Ordergroup.undeleted.order('name') @ordergroups = Ordergroup.undeleted.order('name')

View file

@ -1,5 +1,4 @@
class Foodcoop::UsersController < ApplicationController class Foodcoop::UsersController < ApplicationController
def index def index
@users = User.undeleted.natural_order @users = User.undeleted.natural_order
@ -17,5 +16,4 @@ class Foodcoop::UsersController < ApplicationController
format.js { render :layout => false } # index.js.erb format.js { render :layout => false } # index.js.erb
end end
end end
end end

View file

@ -1,5 +1,4 @@
class Foodcoop::WorkgroupsController < ApplicationController class Foodcoop::WorkgroupsController < ApplicationController
before_action :authenticate_membership_or_admin, before_action :authenticate_membership_or_admin,
:except => [:index] :except => [:index]

View file

@ -1,5 +1,4 @@
class GroupOrderArticlesController < ApplicationController class GroupOrderArticlesController < ApplicationController
before_action :authenticate_finance before_action :authenticate_finance
before_action :find_group_order_article, except: [:new, :create] before_action :find_group_order_article, except: [:new, :create]

View file

@ -107,5 +107,4 @@ class GroupOrdersController < ApplicationController
def order_id_param def order_id_param
params[:order_id] || (params[:group_order] && params[:group_order][:order_id]) params[:order_id] || (params[:group_order] && params[:group_order][:order_id])
end end
end end

View file

@ -1,6 +1,4 @@
# encoding: utf-8
class HomeController < ApplicationController class HomeController < ApplicationController
def index def index
# unaccepted tasks # unaccepted tasks
@unaccepted_tasks = Task.order(:due_date).unaccepted_tasks_for(current_user) @unaccepted_tasks = Task.order(:due_date).unaccepted_tasks_for(current_user)
@ -88,5 +86,4 @@ class HomeController < ApplicationController
params.require(:user).require(:ordergroup).permit(:contact_address) params.require(:user).require(:ordergroup).permit(:contact_address)
end end
end end
end end

View file

@ -1,5 +1,4 @@
class InvitesController < ApplicationController class InvitesController < ApplicationController
before_action :authenticate_membership_or_admin_for_invites before_action :authenticate_membership_or_admin_for_invites
before_action -> { require_config_disabled :disable_invite } before_action -> { require_config_disabled :disable_invite }

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class LoginController < ApplicationController class LoginController < ApplicationController
skip_before_action :authenticate # no authentication since this is the login page skip_before_action :authenticate # no authentication since this is the login page
before_action :validate_token, :only => [:new_password, :update_password] before_action :validate_token, :only => [:new_password, :update_password]

View file

@ -1,5 +1,4 @@
class OrderCommentsController < ApplicationController class OrderCommentsController < ApplicationController
def new def new
@order = Order.find(params[:order_id]) @order = Order.find(params[:order_id])
@order_comment = @order.comments.build(:user => current_user) @order_comment = @order.comments.build(:user => current_user)

View file

@ -1,4 +1,3 @@
# encoding: utf-8
# #
# Controller for managing orders, i.e. all actions that require the "orders" role. # Controller for managing orders, i.e. all actions that require the "orders" role.
# Normal ordering actions of members of order groups is handled by the OrderingController. # Normal ordering actions of members of order groups is handled by the OrderingController.
@ -163,6 +162,7 @@ class OrdersController < ApplicationController
def update_order_amounts def update_order_amounts
return if not params[:order_articles] return if not params[:order_articles]
# where to leave remainder during redistribution # where to leave remainder during redistribution
rest_to = [] rest_to = []
rest_to << :tolerance if params[:rest_to_tolerance] rest_to << :tolerance if params[:rest_to_tolerance]
@ -193,6 +193,7 @@ class OrdersController < ApplicationController
end end
end end
return nil if counts[0] == 0 return nil if counts[0] == 0
notice = [] notice = []
notice << I18n.t('orders.update_order_amounts.msg1', count: counts[0], units: cunits[0]) notice << I18n.t('orders.update_order_amounts.msg1', count: counts[0], units: cunits[0])
notice << I18n.t('orders.update_order_amounts.msg2', count: counts[1], units: cunits[1]) if params[:rest_to_tolerance] notice << I18n.t('orders.update_order_amounts.msg2', count: counts[1], units: cunits[1]) if params[:rest_to_tolerance]
@ -206,5 +207,4 @@ class OrdersController < ApplicationController
def remove_empty_article def remove_empty_article
params[:order][:article_ids].reject!(&:blank?) if params[:order] && params[:order][:article_ids] params[:order][:article_ids].reject!(&:blank?) if params[:order] && params[:order][:article_ids]
end end
end end

View file

@ -1,5 +1,4 @@
class PickupsController < ApplicationController class PickupsController < ApplicationController
before_action :authenticate_pickups before_action :authenticate_pickups
def index def index

View file

@ -1,5 +1,4 @@
class SessionsController < ApplicationController class SessionsController < ApplicationController
skip_before_action :authenticate skip_before_action :authenticate
layout 'login' layout 'login'
@ -30,5 +29,4 @@ class SessionsController < ApplicationController
def redirect_to_foodcoop def redirect_to_foodcoop
redirect_to root_path redirect_to root_path
end end
end end

View file

@ -1,8 +1,7 @@
class StockitController < ApplicationController class StockitController < ApplicationController
def index def index
@stock_articles = StockArticle.undeleted.includes(:supplier, :article_category). @stock_articles = StockArticle.undeleted.includes(:supplier, :article_category)
order('suppliers.name, article_categories.name, articles.name') .order('suppliers.name, article_categories.name, articles.name')
end end
def index_on_stock_article_create # See publish/subscribe design pattern in /doc. def index_on_stock_article_create # See publish/subscribe design pattern in /doc.

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class SuppliersController < ApplicationController class SuppliersController < ApplicationController
before_action :authenticate_suppliers, :except => [:index, :list] before_action :authenticate_suppliers, :except => [:index, :list]
helper :deliveries helper :deliveries
@ -74,5 +73,4 @@ class SuppliersController < ApplicationController
:iban, :custom_fields, :delivery_days, :order_howto, :note, :supplier_category_id, :iban, :custom_fields, :delivery_days, :order_howto, :note, :supplier_category_id,
:shared_supplier_id, :min_order_quantity, :shared_sync_method) :shared_supplier_id, :min_order_quantity, :shared_sync_method)
end end
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class TasksController < ApplicationController class TasksController < ApplicationController
# auto_complete_for :user, :nick # auto_complete_for :user, :nick
@ -122,5 +121,4 @@ class TasksController < ApplicationController
.require(:task) .require(:task)
.permit(:name, :description, :duration, :user_list, :required_users, :workgroup_id, :due_date, :done) .permit(:name, :description, :duration, :user_list, :required_users, :workgroup_id, :due_date, :done)
end end
end end

View file

@ -1,5 +1,4 @@
class UsersController < ApplicationController class UsersController < ApplicationController
# Currently used to display users nick and ids for autocomplete # Currently used to display users nick and ids for autocomplete
def index def index
@users = User.undeleted.natural_search(params[:q]) @users = User.undeleted.natural_search(params[:q])
@ -7,5 +6,4 @@ class UsersController < ApplicationController
format.json { render :json => @users.map(&:token_attributes).to_json } format.json { render :json => @users.map(&:token_attributes).to_json }
end end
end end
end end

View file

@ -1,6 +1,4 @@
# encoding: utf-8
class OrderByArticles < OrderPdf class OrderByArticles < OrderPdf
def filename def filename
I18n.t('documents.order_by_articles.filename', :name => order.name, :date => order.ends.to_date) + '.pdf' I18n.t('documents.order_by_articles.filename', :name => order.name, :date => order.ends.to_date) + '.pdf'
end end

View file

@ -1,6 +1,4 @@
# encoding: utf-8
class OrderByGroups < OrderPdf class OrderByGroups < OrderPdf
def filename def filename
I18n.t('documents.order_by_groups.filename', :name => order.name, :date => order.ends.to_date) + '.pdf' I18n.t('documents.order_by_groups.filename', :name => order.name, :date => order.ends.to_date) + '.pdf'
end end
@ -33,6 +31,7 @@ class OrderByGroups < OrderPdf
number_to_currency(goa.total_price)] number_to_currency(goa.total_price)]
end end
next unless rows.length > 1 next unless rows.length > 1
rows << [nil, nil, nil, nil, nil, number_to_currency(oa_total)] rows << [nil, nil, nil, nil, nil, number_to_currency(oa_total)]
if has_transport if has_transport
rows << [GroupOrder.human_attribute_name(:transport), nil, nil, nil, nil, number_to_currency(oa_transport)] rows << [GroupOrder.human_attribute_name(:transport), nil, nil, nil, nil, number_to_currency(oa_transport)]
@ -64,5 +63,4 @@ class OrderByGroups < OrderPdf
end end
end end
end end
end end

View file

@ -1,6 +1,4 @@
# encoding: utf-8
class OrderFax < OrderPdf class OrderFax < OrderPdf
BATCH_SIZE = 250 BATCH_SIZE = 250
def filename def filename
@ -94,14 +92,13 @@ class OrderFax < OrderPdf
private private
def order_articles def order_articles
order.order_articles.ordered. order.order_articles.ordered
joins(:article). .joins(:article)
order('articles.order_number').order('articles.name'). .order('articles.order_number').order('articles.name')
preload(:article, :article_price) .preload(:article, :article_price)
end end
def each_order_article def each_order_article
order_articles.find_each_with_order(batch_size: BATCH_SIZE) { |oa| yield oa } order_articles.find_each_with_order(batch_size: BATCH_SIZE) { |oa| yield oa }
end end
end end

View file

@ -1,5 +1,4 @@
class OrderMatrix < OrderPdf class OrderMatrix < OrderPdf
HEADER_ROTATE = -30 HEADER_ROTATE = -30
PLACEHOLDER_CHAR = 'X' PLACEHOLDER_CHAR = 'X'
@ -113,5 +112,4 @@ class OrderMatrix < OrderPdf
first_page = false first_page = false
end end
end end
end end

View file

@ -11,6 +11,7 @@ module Admin::ConfigsHelper
# @todo find way to pass current value to time_zone input without using default # @todo find way to pass current value to time_zone input without using default
def config_input(form, key, options = {}, &block) def config_input(form, key, options = {}, &block)
return unless @cfg.allowed_key? key return unless @cfg.allowed_key? key
options[:label] ||= config_input_label(form, key) options[:label] ||= config_input_label(form, key)
options[:required] ||= false options[:required] ||= false
options[:input_html] ||= {} options[:input_html] ||= {}
@ -47,6 +48,7 @@ module Admin::ConfigsHelper
# @todo find out how to pass +checked_value+ and +unchecked_value+ to +input_field+ # @todo find out how to pass +checked_value+ and +unchecked_value+ to +input_field+
def config_input_field(form, key, options = {}) def config_input_field(form, key, options = {})
return unless @cfg.allowed_key? :key return unless @cfg.allowed_key? :key
options[:required] ||= false options[:required] ||= false
config_input_field_options form, key, options config_input_field_options form, key, options
config_input_tooltip_options form, key, options config_input_tooltip_options form, key, options

View file

@ -1,4 +1,3 @@
# encoding: utf-8
# #
# Methods added to this helper will be available to all templates in the application. # Methods added to this helper will be available to all templates in the application.
module ApplicationHelper module ApplicationHelper
@ -58,7 +57,6 @@ module ApplicationHelper
links.join.html_safe links.join.html_safe
end end
end end
end end
def sort_link_helper(text, key, options = {}) def sort_link_helper(text, key, options = {})
@ -78,7 +76,6 @@ module ApplicationHelper
:class => class_name :class => class_name
} }
# Url options # Url options
key += "_reverse" if params[:sort] == key key += "_reverse" if params[:sort] == key
per_page = options[:per_page] || @per_page per_page = options[:per_page] || @per_page
@ -200,6 +197,7 @@ module ApplicationHelper
# http://railsapps.github.io/twitter-bootstrap-rails.html # http://railsapps.github.io/twitter-bootstrap-rails.html
def base_errors resource def base_errors resource
return '' if resource.errors.empty? || resource.errors[:base].empty? return '' if resource.errors.empty? || resource.errors[:base].empty?
messages = resource.errors[:base].map { |msg| content_tag(:li, msg) }.join messages = resource.errors[:base].map { |msg| content_tag(:li, msg) }.join
render :partial => 'shared/base_errors', :locals => { :error_messages => messages } render :partial => 'shared/base_errors', :locals => { :error_messages => messages }
end end
@ -230,6 +228,7 @@ module ApplicationHelper
# allow truncate to add title when tooltip option is given # allow truncate to add title when tooltip option is given
def truncate(text, options = {}, &block) def truncate(text, options = {}, &block)
return text if !text || text.length <= (options[:length] || 30) return text if !text || text.length <= (options[:length] || 30)
text_truncated = super(text, options, &block) text_truncated = super(text, options, &block)
if options[:tooltip] if options[:tooltip]
content_tag :span, text_truncated, title: text content_tag :span, text_truncated, title: text
@ -264,5 +263,4 @@ module ApplicationHelper
stylesheet_link_tag foodcoop_css_path, media: 'all' stylesheet_link_tag foodcoop_css_path, media: 'all'
end end
end end
end end

View file

@ -1,8 +1,8 @@
module ArticlesHelper module ArticlesHelper
# useful for highlighting attributes, when synchronizing articles # useful for highlighting attributes, when synchronizing articles
def highlight_new(unequal_attributes, attribute) def highlight_new(unequal_attributes, attribute)
return unless unequal_attributes return unless unequal_attributes
unequal_attributes.has_key?(attribute) ? "background-color: yellow" : "" unequal_attributes.has_key?(attribute) ? "background-color: yellow" : ""
end end

View file

@ -1,5 +1,4 @@
module DeliveriesHelper module DeliveriesHelper
def link_to_invoice(delivery) def link_to_invoice(delivery)
if delivery.invoice if delivery.invoice
link_to number_to_currency(delivery.invoice.amount), [:finance, delivery.invoice], link_to number_to_currency(delivery.invoice.amount), [:finance, delivery.invoice],
@ -25,9 +24,9 @@ module DeliveriesHelper
def stock_change_remove_link(stock_change_form) def stock_change_remove_link(stock_change_form)
return link_to t('deliveries.stock_change_fields.remove_article'), "#", :class => 'remove_new_stock_change btn btn-small' if stock_change_form.object.new_record? return link_to t('deliveries.stock_change_fields.remove_article'), "#", :class => 'remove_new_stock_change btn btn-small' if stock_change_form.object.new_record?
output = stock_change_form.hidden_field :_destroy output = stock_change_form.hidden_field :_destroy
output += link_to t('deliveries.stock_change_fields.remove_article'), "#", :class => 'destroy_stock_change btn btn-small' output += link_to t('deliveries.stock_change_fields.remove_article'), "#", :class => 'destroy_stock_change btn btn-small'
return output.html_safe return output.html_safe
end end
end end

View file

@ -2,6 +2,7 @@ module Finance::InvoicesHelper
def format_delivery_item delivery def format_delivery_item delivery
format_date(delivery.date) format_date(delivery.date)
end end
def format_order_item order def format_order_item order
"#{format_date(order.ends)} (#{number_to_currency(order.sum)})" "#{format_date(order.ends)} (#{number_to_currency(order.sum)})"
end end

View file

@ -1,5 +1,4 @@
module GroupOrderArticlesHelper module GroupOrderArticlesHelper
# return an edit field for a GroupOrderArticle result # return an edit field for a GroupOrderArticle result
def group_order_article_edit_result(goa) def group_order_article_edit_result(goa)
result = number_with_precision goa.result, strip_insignificant_zeros: true result = number_with_precision goa.result, strip_insignificant_zeros: true
@ -11,5 +10,4 @@ module GroupOrderArticlesHelper
end end
end end
end end
end end

View file

@ -1,8 +1,6 @@
module OrderArticlesHelper module OrderArticlesHelper
def article_label_with_unit(article) def article_label_with_unit(article)
pkg_info = pkg_helper(article, plain: true) pkg_info = pkg_helper(article, plain: true)
"#{article.name} (#{[article.unit, pkg_info].reject(&:blank?).join(' ')})" "#{article.name} (#{[article.unit, pkg_info].reject(&:blank?).join(' ')})"
end end
end end

View file

@ -1,6 +1,4 @@
# encoding: utf-8
module OrdersHelper module OrdersHelper
def update_articles_link(order, text, view, options = {}) def update_articles_link(order, text, view, options = {})
options = { remote: true, id: "view_#{view}_btn", class: '' }.merge(options) options = { remote: true, id: "view_#{view}_btn", class: '' }.merge(options)
options[:class] += ' active' if view.to_s == @view.to_s options[:class] += ' active' if view.to_s == @view.to_s
@ -51,6 +49,7 @@ module OrdersHelper
# @return [String] Text showing unit and unit quantity when applicable. # @return [String] Text showing unit and unit quantity when applicable.
def pkg_helper(article, options = {}) def pkg_helper(article, options = {})
return '' if !article || article.unit_quantity == 1 return '' if !article || article.unit_quantity == 1
uq_text = "× #{article.unit_quantity}" uq_text = "× #{article.unit_quantity}"
uq_text = content_tag(:span, uq_text, class: 'hidden-phone') if options[:soft_uq] uq_text = content_tag(:span, uq_text, class: 'hidden-phone') if options[:soft_uq]
if options[:plain] if options[:plain]
@ -61,6 +60,7 @@ module OrdersHelper
pkg_helper_icon(uq_text, tag: :span) pkg_helper_icon(uq_text, tag: :span)
end end
end end
# @param c [Symbol, String] Tag to use # @param c [Symbol, String] Tag to use
# @option options [String] :class CSS class(es) (in addition to +package+) # @option options [String] :class CSS class(es) (in addition to +package+)
# @return [String] Icon used for displaying the unit quantity # @return [String] Icon used for displaying the unit quantity
@ -75,6 +75,7 @@ module OrdersHelper
def article_price_change_hint(order_article, gross = false) def article_price_change_hint(order_article, gross = false)
return nil if order_article.article.price == order_article.price.price return nil if order_article.article.price == order_article.price.price
title = "#{t('helpers.orders.old_price')}: #{number_to_currency order_article.article.price}" title = "#{t('helpers.orders.old_price')}: #{number_to_currency order_article.article.price}"
title += " / #{number_to_currency order_article.article.gross_price}" if gross title += " / #{number_to_currency order_article.article.gross_price}" if gross
content_tag(:i, nil, class: 'icon-asterisk', title: j(title)).html_safe content_tag(:i, nil, class: 'icon-asterisk', title: j(title)).html_safe

View file

@ -1,5 +1,4 @@
module PathHelper module PathHelper
def finance_group_transactions_path(ordergroup) def finance_group_transactions_path(ordergroup)
if ordergroup if ordergroup
finance_ordergroup_transactions_path(ordergroup) finance_ordergroup_transactions_path(ordergroup)
@ -7,5 +6,4 @@ module PathHelper
finance_foodcoop_financial_transactions_path finance_foodcoop_financial_transactions_path
end end
end end
end end

View file

@ -1,5 +1,4 @@
module SharedHelper module SharedHelper
# provide input_html for password autocompletion # provide input_html for password autocompletion
def autocomplete_flag_to_password_html(password_autocomplete) def autocomplete_flag_to_password_html(password_autocomplete)
case password_autocomplete case password_autocomplete
@ -9,5 +8,4 @@ module SharedHelper
else {} else {}
end end
end end
end end

View file

@ -19,8 +19,6 @@ module StockitHelper
t('simple_form.hints.stock_article.edit_stock_article.price', t('simple_form.hints.stock_article.edit_stock_article.price',
:stock_article_copy_link => link_to(t('stockit.form.copy_stock_article'), :stock_article_copy_link => link_to(t('stockit.form.copy_stock_article'),
stock_article_copy_path(stock_article), stock_article_copy_path(stock_article),
:remote => true :remote => true))
)
)
end end
end end

View file

@ -1,5 +1,4 @@
module SuppliersHelper module SuppliersHelper
def associated_supplier_names(shared_supplier) def associated_supplier_names(shared_supplier)
"(#{shared_supplier.suppliers.map(&:name).join(', ')})" "(#{shared_supplier.suppliers.map(&:name).join(', ')})"
end end

View file

@ -1,5 +1,4 @@
module TasksHelper module TasksHelper
def task_assignments(task) def task_assignments(task)
task.assignments.map do |ass| task.assignments.map do |ass|
content_tag :span, show_user(ass.user), :class => (ass.accepted? ? 'accepted' : 'unaccepted') content_tag :span, show_user(ass.user), :class => (ass.accepted? ? 'accepted' : 'unaccepted')

View file

@ -1,5 +1,3 @@
# encoding: utf-8
class DeltaInput < SimpleForm::Inputs::StringInput class DeltaInput < SimpleForm::Inputs::StringInput
# for now, need to pass id or it won't work # for now, need to pass id or it won't work
def input(wrapper_options) def input(wrapper_options)

View file

@ -1,5 +1,4 @@
class BounceMailReceiver class BounceMailReceiver
def self.regexp def self.regexp
/bounce\+(?<local>.*)=(?<domain>[^=]+)/ /bounce\+(?<local>.*)=(?<domain>[^=]+)/
end end
@ -16,5 +15,4 @@ class BounceMailReceiver
attachment_mime: 'message/rfc822', attachment_mime: 'message/rfc822',
attachment_data: data attachment_data: data
end end
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
# ActionMailer class that handles all emails for Foodsoft. # ActionMailer class that handles all emails for Foodsoft.
class Mailer < ActionMailer::Base class Mailer < ActionMailer::Base
# XXX Quick fix to allow the use of show_user. Proper take would be one of # XXX Quick fix to allow the use of show_user. Proper take would be one of
@ -180,5 +179,4 @@ class Mailer < ActionMailer::Base
address.display_name = name address.display_name = name
address.format address.format
end end
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class Article < ApplicationRecord class Article < ApplicationRecord
include PriceCalculation include PriceCalculation
@ -250,5 +249,4 @@ class Article < ApplicationRecord
errors.add :name, :taken_with_unit if matches.where(unit: unit, unit_quantity: unit_quantity).any? errors.add :name, :taken_with_unit if matches.where(unit: unit, unit_quantity: unit_quantity).any?
end end
end end
end end

View file

@ -1,6 +1,5 @@
# Article category # Article category
class ArticleCategory < ApplicationRecord class ArticleCategory < ApplicationRecord
# @!attribute name # @!attribute name
# @return [String] Title of the category. # @return [String] Title of the category.
# @!attrubute description # @!attrubute description
@ -34,6 +33,7 @@ class ArticleCategory < ApplicationRecord
# TODO more intelligence like remembering earlier associations (global and/or per-supplier) # TODO more intelligence like remembering earlier associations (global and/or per-supplier)
def self.find_match(category) def self.find_match(category)
return if category.blank? || category.length < 3 return if category.blank? || category.length < 3
c = nil c = nil
## exact match - not needed, will be returned by next query as well ## exact match - not needed, will be returned by next query as well
# c ||= ArticleCategory.where(name: category).first # c ||= ArticleCategory.where(name: category).first
@ -52,5 +52,4 @@ class ArticleCategory < ApplicationRecord
def check_for_associated_articles def check_for_associated_articles
raise I18n.t('activerecord.errors.has_many_left', collection: Article.model_name.human) if articles.undeleted.exists? raise I18n.t('activerecord.errors.has_many_left', collection: Article.model_name.human) if articles.undeleted.exists?
end end
end end

View file

@ -27,5 +27,4 @@ class ArticlePrice < ApplicationRecord
validates_numericality_of :price, :greater_than_or_equal_to => 0 validates_numericality_of :price, :greater_than_or_equal_to => 0
validates_numericality_of :unit_quantity, :greater_than => 0 validates_numericality_of :unit_quantity, :greater_than => 0
validates_numericality_of :deposit, :tax validates_numericality_of :deposit, :tax
end end

View file

@ -1,5 +1,4 @@
class Assignment < ApplicationRecord class Assignment < ApplicationRecord
belongs_to :user belongs_to :user
belongs_to :task belongs_to :task
end end

View file

@ -1,5 +1,4 @@
class BankAccount < ApplicationRecord class BankAccount < ApplicationRecord
has_many :bank_transactions, dependent: :destroy has_many :bank_transactions, dependent: :destroy
normalize_attributes :name, :iban, :description normalize_attributes :name, :iban, :description

View file

@ -1,5 +1,4 @@
class BankTransaction < ApplicationRecord class BankTransaction < ApplicationRecord
# @!attribute external_id # @!attribute external_id
# @return [String] Unique Identifier of the transaction within the bank account. # @return [String] Unique Identifier of the transaction within the bank account.
# @!attribute date # @!attribute date
@ -57,8 +56,10 @@ class BankTransaction < ApplicationRecord
return unless m return unless m
return false if m[:parts].values.sum != amount return false if m[:parts].values.sum != amount
group = Ordergroup.find_by_id(m[:group]) group = Ordergroup.find_by_id(m[:group])
return false unless group return false unless group
usr = m[:user] ? User.find_by_id(m[:user]) : group.users.first usr = m[:user] ? User.find_by_id(m[:user]) : group.users.first
return false unless usr return false unless usr
@ -69,6 +70,7 @@ class BankTransaction < ApplicationRecord
m[:parts].each do |short, value| m[:parts].each do |short, value|
ftt = FinancialTransactionType.find_by_name_short(short) ftt = FinancialTransactionType.find_by_name_short(short)
return false unless ftt return false unless ftt
group.add_financial_transaction! value, note, usr, ftt, link if value > 0 group.add_financial_transaction! value, note, usr, ftt, link if value > 0
end end

View file

@ -3,7 +3,6 @@ module FindEachWithOrder
extend ActiveSupport::Concern extend ActiveSupport::Concern
class_methods do class_methods do
def find_each_with_order(options = {}) def find_each_with_order(options = {})
find_in_batches_with_order(options) do |records| find_in_batches_with_order(options) do |records|
records.each { |record| yield record } records.each { |record| yield record }
@ -34,6 +33,5 @@ module FindEachWithOrder
records = relation.offset(start).to_a records = relation.offset(start).to_a
end end
end end
end end
end end

View file

@ -1,5 +1,4 @@
class Delivery < StockEvent class Delivery < StockEvent
belongs_to :supplier belongs_to :supplier
belongs_to :invoice, optional: true belongs_to :invoice, optional: true
@ -44,5 +43,4 @@ class Delivery < StockEvent
errors.add(:base, I18n.t('model.delivery.each_stock_article_must_be_unique')) errors.add(:base, I18n.t('model.delivery.each_stock_article_must_be_unique'))
end end
end end
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
# Groups organize the User. # Groups organize the User.
# A Member gets the roles from the Group # A Member gets the roles from the Group
class Group < ApplicationRecord class Group < ApplicationRecord

View file

@ -39,7 +39,6 @@ class GroupOrder < ApplicationRecord
data[:order_articles] = {} data[:order_articles] = {}
order.articles_grouped_by_category.each do |article_category, order_articles| order.articles_grouped_by_category.each do |article_category, order_articles|
order_articles.each do |order_article| order_articles.each do |order_article|
# Get the result of last time ordering, if possible # Get the result of last time ordering, if possible
goa = group_order_articles.detect { |goa| goa.order_article_id == order_article.id } goa = group_order_articles.detect { |goa| goa.order_article_id == order_article.id }
@ -88,7 +87,6 @@ class GroupOrder < ApplicationRecord
update_attribute(:price, total) update_attribute(:price, total)
end end
# Save GroupOrder and updates group_order_articles/quantities accordingly # Save GroupOrder and updates group_order_articles/quantities accordingly
def save_ordering! def save_ordering!
transaction do transaction do
@ -104,7 +102,7 @@ class GroupOrder < ApplicationRecord
def total def total
return price + transport if transport return price + transport if transport
price price
end end
end end

View file

@ -2,7 +2,6 @@
# The chronologically order of the Ordergroup - activity are stored in GroupOrderArticleQuantity # The chronologically order of the Ordergroup - activity are stored in GroupOrderArticleQuantity
# #
class GroupOrderArticle < ApplicationRecord class GroupOrderArticle < ApplicationRecord
belongs_to :group_order belongs_to :group_order
belongs_to :order_article belongs_to :order_article
has_many :group_order_article_quantities, dependent: :destroy has_many :group_order_article_quantities, dependent: :destroy

View file

@ -2,7 +2,6 @@
# Considers every update of an article-order, so may rows for one group_order_article ar possible. # Considers every update of an article-order, so may rows for one group_order_article ar possible.
class GroupOrderArticleQuantity < ApplicationRecord class GroupOrderArticleQuantity < ApplicationRecord
belongs_to :group_order_article belongs_to :group_order_article
validates_presence_of :group_order_article_id validates_presence_of :group_order_article_id

View file

@ -30,5 +30,4 @@ class Invite < ApplicationRecord
errors.add(:email, I18n.t('invites.errors.already_member')) errors.add(:email, I18n.t('invites.errors.already_member'))
end end
end end
end end

View file

@ -1,11 +1,9 @@
class Membership < ApplicationRecord class Membership < ApplicationRecord
belongs_to :user belongs_to :user
belongs_to :group belongs_to :group
before_destroy :check_last_admin before_destroy :check_last_admin
protected protected
# check if this is the last admin-membership and deny # check if this is the last admin-membership and deny

View file

@ -1,5 +1,3 @@
# encoding: utf-8
#
class Order < ApplicationRecord class Order < ApplicationRecord
attr_accessor :ignore_warnings, :transport_distribution attr_accessor :ignore_warnings, :transport_distribution
@ -71,8 +69,8 @@ class Order < ApplicationRecord
if stockit? if stockit?
# make sure to include those articles which are no longer available # make sure to include those articles which are no longer available
# but which have already been ordered in this stock order # but which have already been ordered in this stock order
StockArticle.available.includes(:article_category). StockArticle.available.includes(:article_category)
order('article_categories.name', 'articles.name').reject{ |a| .order('article_categories.name', 'articles.name').reject { |a|
a.quantity_available <= 0 && !a.ordered_in_order?(self) a.quantity_available <= 0 && !a.ordered_in_order?(self)
}.group_by { |a| a.article_category.name } }.group_by { |a| a.article_category.name }
else else
@ -173,11 +171,11 @@ class Order < ApplicationRecord
# The array has the following form: # The array has the following form:
# e.g: [["drugs",[teethpaste, toiletpaper]], ["fruits" => [apple, banana, lemon]]] # e.g: [["drugs",[teethpaste, toiletpaper]], ["fruits" => [apple, banana, lemon]]]
def articles_grouped_by_category def articles_grouped_by_category
@articles_grouped_by_category ||= order_articles. @articles_grouped_by_category ||= order_articles
includes([:article_price, :group_order_articles, :article => :article_category]). .includes([:article_price, :group_order_articles, :article => :article_category])
order('articles.name'). .order('articles.name')
group_by { |a| a.article.article_category.name }. .group_by { |a| a.article.article_category.name }
sort { |a, b| a[0] <=> b[0] } .sort { |a, b| a[0] <=> b[0] }
end end
def articles_sort_by_category def articles_sort_by_category
@ -290,6 +288,7 @@ class Order < ApplicationRecord
# Close the order directly, without automaticly updating ordergroups account balances # Close the order directly, without automaticly updating ordergroups account balances
def close_direct!(user) def close_direct!(user)
raise I18n.t('orders.model.error_closed') if closed? raise I18n.t('orders.model.error_closed') if closed?
comments.create(user: user, text: I18n.t('orders.model.close_direct_message')) unless FoodsoftConfig[:charge_members_manually] comments.create(user: user, text: I18n.t('orders.model.close_direct_message')) unless FoodsoftConfig[:charge_members_manually]
update_attributes! state: 'closed', updated_by: user update_attributes! state: 'closed', updated_by: user
end end
@ -362,6 +361,7 @@ class Order < ApplicationRecord
def distribute_transport def distribute_transport
return unless group_orders.any? return unless group_orders.any?
case transport_distribution.try(&:to_i) case transport_distribution.try(&:to_i)
when Order.transport_distributions[:ordergroup] then when Order.transport_distributions[:ordergroup] then
amount = transport / group_orders.size amount = transport / group_orders.size

View file

@ -38,6 +38,7 @@ class OrderArticle < ApplicationRecord
def units def units
return units_received unless units_received.nil? return units_received unless units_received.nil?
return units_billed unless units_billed.nil? return units_billed unless units_billed.nil?
units_to_order units_to_order
end end

View file

@ -1,5 +1,4 @@
class OrderComment < ApplicationRecord class OrderComment < ApplicationRecord
belongs_to :order belongs_to :order
belongs_to :user belongs_to :user

View file

@ -1,4 +1,3 @@
# encoding: utf-8
# #
# Ordergroups can order, they are "children" of the class Group # Ordergroups can order, they are "children" of the class Group
# #
@ -24,6 +23,7 @@ class Ordergroup < Group
def contact def contact
"#{contact_phone} (#{contact_person})" "#{contact_phone} (#{contact_person})"
end end
def non_members def non_members
User.natural_order.all.reject { |u| (users.include?(u) || u.ordergroup) } User.natural_order.all.reject { |u| (users.include?(u) || u.ordergroup) }
end end
@ -43,6 +43,7 @@ class Ordergroup < Group
def self.custom_fields def self.custom_fields
fields = FoodsoftConfig[:custom_fields] && FoodsoftConfig[:custom_fields][:ordergroup] fields = FoodsoftConfig[:custom_fields] && FoodsoftConfig[:custom_fields][:ordergroup]
return [] unless fields return [] unless fields
fields.map(&:deep_symbolize_keys) fields.map(&:deep_symbolize_keys)
end end
@ -163,6 +164,4 @@ class Ordergroup < Group
errors.add :name, message errors.add :name, message
end end
end end
end end

View file

@ -4,6 +4,7 @@ class PeriodicTaskGroup < ApplicationRecord
def has_next_task? def has_next_task?
return false if tasks.empty? return false if tasks.empty?
return false if tasks.first.due_date.nil? return false if tasks.first.due_date.nil?
return true return true
end end

View file

@ -1,5 +1,4 @@
class SharedArticle < ApplicationRecord class SharedArticle < ApplicationRecord
# connect to database from sharedLists-Application # connect to database from sharedLists-Application
SharedArticle.establish_connection(FoodsoftConfig[:shared_lists]) SharedArticle.establish_connection(FoodsoftConfig[:shared_lists])
# set correct table_name in external DB # set correct table_name in external DB

View file

@ -1,5 +1,4 @@
class SharedSupplier < ApplicationRecord class SharedSupplier < ApplicationRecord
# connect to database from sharedLists-Application # connect to database from sharedLists-Application
SharedSupplier.establish_connection(FoodsoftConfig[:shared_lists]) SharedSupplier.establish_connection(FoodsoftConfig[:shared_lists])
# set correct table_name in external DB # set correct table_name in external DB
@ -8,7 +7,6 @@ class SharedSupplier < ApplicationRecord
has_many :suppliers, -> { undeleted } has_many :suppliers, -> { undeleted }
has_many :shared_articles, :foreign_key => :supplier_id has_many :shared_articles, :foreign_key => :supplier_id
def find_article_by_number(order_number) def find_article_by_number(order_number)
# note that `shared_articles` uses number instead order_number # note that `shared_articles` uses number instead order_number
cached_articles.detect { |a| a.number == order_number } cached_articles.detect { |a| a.number == order_number }

View file

@ -1,6 +1,4 @@
# encoding: utf-8
class StockArticle < Article class StockArticle < Article
has_many :stock_changes has_many :stock_changes
scope :available, -> { undeleted.where('quantity > 0') } scope :available, -> { undeleted.where('quantity > 0') }
@ -30,8 +28,8 @@ class StockArticle < Article
end end
def quantity_ordered def quantity_ordered
OrderArticle.where(article_id: id). OrderArticle.where(article_id: id)
joins(:order).where(orders: {state: %w[open finished received]}).sum(:units_to_order) .joins(:order).where(orders: { state: %w[open finished received] }).sum(:units_to_order)
end end
def quantity_history def quantity_history

View file

@ -1,8 +1,6 @@
class StockEvent < ApplicationRecord class StockEvent < ApplicationRecord
has_many :stock_changes, dependent: :destroy has_many :stock_changes, dependent: :destroy
has_many :stock_articles, through: :stock_changes has_many :stock_articles, through: :stock_changes
validates_presence_of :date validates_presence_of :date
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class Supplier < ApplicationRecord class Supplier < ApplicationRecord
include MarkAsDeletedWithName include MarkAsDeletedWithName
include CustomFields include CustomFields
@ -116,6 +115,7 @@ class Supplier < ApplicationRecord
# default value # default value
def shared_sync_method def shared_sync_method
return unless shared_supplier return unless shared_supplier
self[:shared_sync_method] || 'import' self[:shared_sync_method] || 'import'
end end

View file

@ -1,5 +1,4 @@
class SupplierCategory < ActiveRecord::Base class SupplierCategory < ActiveRecord::Base
belongs_to :financial_transaction_class belongs_to :financial_transaction_class
has_many :suppliers has_many :suppliers
@ -15,5 +14,4 @@ class SupplierCategory < ActiveRecord::Base
def check_for_associated_suppliers def check_for_associated_suppliers
raise I18n.t('activerecord.errors.has_many_left', collection: Supplier.model_name.human) if suppliers.undeleted.any? raise I18n.t('activerecord.errors.has_many_left', collection: Supplier.model_name.human) if suppliers.undeleted.any?
end end
end end

View file

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
class Task < ApplicationRecord class Task < ApplicationRecord
has_many :assignments, :dependent => :destroy has_many :assignments, :dependent => :destroy
has_many :users, :through => :assignments has_many :users, :through => :assignments
@ -33,11 +32,10 @@ class Task < ApplicationRecord
user.tasks.undone.where(assignments: { accepted: true }) user.tasks.undone.where(assignments: { accepted: true })
end end
# find all tasks in the period (or another number of days) # find all tasks in the period (or another number of days)
def self.next_assigned_tasks_for(user, number = FoodsoftConfig[:tasks_period_days].to_i) def self.next_assigned_tasks_for(user, number = FoodsoftConfig[:tasks_period_days].to_i)
user.tasks.undone.where(assignments: {accepted: true}). user.tasks.undone.where(assignments: { accepted: true })
where(["tasks.due_date >= ? AND tasks.due_date <= ?", Time.now, number.days.from_now]) .where(["tasks.due_date >= ? AND tasks.due_date <= ?", Time.now, number.days.from_now])
end end
# count tasks with not enough responsible people # count tasks with not enough responsible people
@ -53,6 +51,7 @@ class Task < ApplicationRecord
periodic_task_group_count = {} periodic_task_group_count = {}
self.unassigned_tasks_for(user).reject do |item| self.unassigned_tasks_for(user).reject do |item|
next false unless item.periodic_task_group next false unless item.periodic_task_group
count = periodic_task_group_count[item.periodic_task_group] || 0 count = periodic_task_group_count[item.periodic_task_group] || 0
periodic_task_group_count[item.periodic_task_group] = count + 1 periodic_task_group_count[item.periodic_task_group] = count + 1
count >= max count >= max

View file

@ -1,5 +1,3 @@
# encoding: utf-8
require 'digest/sha1' require 'digest/sha1'
# specific user rights through memberships (see Group) # specific user rights through memberships (see Group)
class User < ApplicationRecord class User < ApplicationRecord
@ -232,6 +230,7 @@ class User < ApplicationRecord
def self.custom_fields def self.custom_fields
fields = FoodsoftConfig[:custom_fields] && FoodsoftConfig[:custom_fields][:user] fields = FoodsoftConfig[:custom_fields] && FoodsoftConfig[:custom_fields][:user]
return [] unless fields return [] unless fields
fields.map(&:deep_symbolize_keys) fields.map(&:deep_symbolize_keys)
end end
@ -251,5 +250,4 @@ class User < ApplicationRecord
# this should not be part of the model anyway # this should not be part of the model anyway
{ :id => id, :name => "#{display} (#{ordergroup.try(:name)})" } { :id => id, :name => "#{display} (#{ordergroup.try(:name)})" }
end end
end end

View file

@ -1,4 +1,3 @@
# encoding: utf-8
class Workgroup < Group class Workgroup < Group
include CustomFields include CustomFields
@ -26,5 +25,4 @@ class Workgroup < Group
errors.add(:role_admin, I18n.t('workgroups.error_last_admin_role')) errors.add(:role_admin, I18n.t('workgroups.error_last_admin_role'))
end end
end end
end end

View file

@ -12,7 +12,6 @@ class ConfigSerializer < ActiveModel::Serializer
# help and version # help and version
attributes :applepear_url, :help_url, :foodsoft attributes :applepear_url, :help_url, :foodsoft
def foodsoft def foodsoft
{ {
version: Foodsoft::VERSION, version: Foodsoft::VERSION,

View file

@ -12,6 +12,7 @@ class UserNotifier
order_id = args.first order_id = args.first
Order.find(order_id).group_orders.each do |group_order| Order.find(order_id).group_orders.each do |group_order|
next if group_order.ordergroup.nil? next if group_order.ordergroup.nil?
group_order.ordergroup.users.each do |user| group_order.ordergroup.users.each do |user|
if user.settings.notify['order_finished'] if user.settings.notify['order_finished']
Mailer.deliver_now_with_user_locale user do Mailer.deliver_now_with_user_locale user do

View file

@ -1,6 +1,5 @@
require 'exception_notification/rails' require 'exception_notification/rails'
require 'resque/failure/multiple' require 'resque/failure/multiple'
require 'resque/failure/redis' require 'resque/failure/redis'
require 'exception_notification/resque' require 'exception_notification/resque'
@ -8,7 +7,6 @@ require 'exception_notification/resque'
Resque::Failure::Multiple.classes = [Resque::Failure::Redis, ExceptionNotification::Resque] Resque::Failure::Multiple.classes = [Resque::Failure::Redis, ExceptionNotification::Resque]
Resque::Failure.backend = Resque::Failure::Multiple Resque::Failure.backend = Resque::Failure::Multiple
ExceptionNotification.configure do |config| ExceptionNotification.configure do |config|
# Ignore additional exception types. # Ignore additional exception types.
# ActiveRecord::RecordNotFound, Mongoid::Errors::DocumentNotFound, AbstractController::ActionNotFound and ActionController::RoutingError are already added. # ActiveRecord::RecordNotFound, Mongoid::Errors::DocumentNotFound, AbstractController::ActionNotFound and ActionController::RoutingError are already added.
@ -49,5 +47,4 @@ ExceptionNotification.configure do |config|
# :url => 'http://example.com:5555/hubot/path', # :url => 'http://example.com:5555/hubot/path',
# :http_method => :post # :http_method => :post
# } # }
end end

View file

@ -1,6 +1,5 @@
# extend the BigDecimal class # extend the BigDecimal class
class String class String
# remove comma from decimal inputs # remove comma from decimal inputs
def self.delocalized_decimal(string) def self.delocalized_decimal(string)
if !string.blank? and string.is_a?(String) if !string.blank? and string.is_a?(String)

Some files were not shown because too many files have changed in this diff Show more