From 3cbeabc82c8f89805b1e7c41dffd3f13e777aa29 Mon Sep 17 00:00:00 2001 From: Tomasz Subik Date: Thu, 21 Nov 2024 14:36:53 +0100 Subject: [PATCH 1/3] operator documents API add contract signature filter --- app/resources/concerns/operator_documentable.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/resources/concerns/operator_documentable.rb b/app/resources/concerns/operator_documentable.rb index dbc440f25..7c3890403 100644 --- a/app/resources/concerns/operator_documentable.rb +++ b/app/resources/concerns/operator_documentable.rb @@ -21,6 +21,10 @@ module OperatorDocumentable filters :type, :status, :operator_id, :fmu_id, :required_operator_document_id, :country_ids, :source, :legal_categories, :forest_types + filter :contract_signature, apply: ->(records, value, _options) { + records.joins(:required_operator_document).where(required_operator_document: {contract_signature: value}) + } + privateable :document_visible?, [:start_date, :expire_date, :note, :reason, :response_date, :source_info, :uploaded_by, :created_at, :updated_at] def admin_comment From dc2b9c1b1cb0236c607f14d21efa9aacb53970ef Mon Sep 17 00:00:00 2001 From: Tomasz Subik Date: Wed, 20 Nov 2024 17:23:34 +0100 Subject: [PATCH 2/3] fix workflows --- .github/workflows/linters.yml | 1 + .github/workflows/security.yml | 1 + .github/workflows/tests.yml | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index f5abaac01..999791214 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -10,6 +10,7 @@ jobs: - uses: actions/checkout@v4 - name: Install dependencies run: | + sudo apt update --fix-missing sudo apt-get install libgdal-dev - name: Set up Ruby uses: ruby/setup-ruby@v1 diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml index ed1033859..570bd1aa4 100644 --- a/.github/workflows/security.yml +++ b/.github/workflows/security.yml @@ -10,6 +10,7 @@ jobs: - uses: actions/checkout@v4 - name: Install dependencies run: | + sudo apt update --fix-missing sudo apt-get install libgdal-dev - name: Set up Ruby uses: ruby/setup-ruby@v1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 79b7ce218..c0432a4bf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,6 +31,7 @@ jobs: - name: Install dependencies run: | + sudo apt update --fix-missing sudo apt-get install libgdal-dev - name: Set up Ruby @@ -58,8 +59,7 @@ jobs: - name: Install dependencies run: | sudo apt update --fix-missing - sudo apt-get -yqq install gdal-bin - sudo apt-get install libgdal-dev + sudo apt-get -yqq install gdal-bin libgdal-dev npm install -g mjml - name: Set up Ruby From 59e1ff2ba2928de6a66e32c6ac6851ae2a8ea785 Mon Sep 17 00:00:00 2001 From: Tomasz Subik Date: Mon, 9 Dec 2024 13:16:51 +0100 Subject: [PATCH 3/3] update gems --- Gemfile.lock | 115 +++++++++++----------- app/controllers/v1/sessions_controller.rb | 2 +- lib/tasks/single_use/quality_control.rake | 3 +- 3 files changed, 63 insertions(+), 57 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2157d188b..b8159be60 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -158,7 +158,7 @@ GEM mutex_m securerandom (>= 0.3) tzinfo (~> 2.0) - acts_as_list (1.2.3) + acts_as_list (1.2.4) activerecord (>= 6.1) activesupport (>= 6.1) addressable (2.8.7) @@ -257,7 +257,7 @@ GEM activerecord (>= 5.a) database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) - date (3.4.0) + date (3.4.1) debug (1.9.2) irb (~> 1.10) reline (>= 0.3.8) @@ -284,12 +284,12 @@ GEM railties (>= 5.0.0) faker (3.5.1) i18n (>= 1.8.11, < 2) - faraday (2.12.0) - faraday-net_http (>= 2.0, < 3.4) + faraday (2.12.2) + faraday-net_http (>= 2.0, < 3.5) json logger - faraday-net_http (3.3.0) - net-http + faraday-net_http (3.4.0) + net-http (>= 0.5.0) faraday-retry (2.2.1) faraday (~> 2.0) ferrum (0.15) @@ -305,14 +305,16 @@ GEM formtastic (5.0.0) actionpack (>= 6.0.0) formtastic_i18n (0.7.0) - gapic-common (0.23.0) + gapic-common (0.24.0) faraday (>= 1.9, < 3.a) faraday-retry (>= 1.0, < 3.a) + google-cloud-env (~> 2.2) + google-logging-utils (~> 0.1) google-protobuf (>= 3.25, < 5.a) googleapis-common-protos (~> 1.6) googleapis-common-protos-types (~> 1.15) - googleauth (~> 1.11) - grpc (~> 1.65) + googleauth (~> 1.12) + grpc (~> 1.66) gdal (3.0.0) globalid (1.2.1) activesupport (>= 6.1) @@ -339,19 +341,20 @@ GEM googleapis-common-protos (>= 1.3.10, < 2.a) googleapis-common-protos-types (>= 1.0.5, < 2.a) googleauth (>= 0.16.2, < 2.a) - google-cloud-translate-v3 (1.1.1) + google-cloud-translate-v3 (1.2.0) gapic-common (>= 0.21.1, < 2.a) google-cloud-errors (~> 1.0) google-cloud-location (>= 0.7, < 2.a) google-iam-v1 (>= 0.7, < 2.a) - google-iam-v1 (1.0.1) + google-iam-v1 (1.1.0) gapic-common (>= 0.21.1, < 2.a) google-cloud-errors (~> 1.0) grpc-google-iam-v1 (~> 1.1) - google-protobuf (4.28.3) + google-logging-utils (0.1.0) + google-protobuf (4.29.1) bigdecimal rake (>= 13) - google-protobuf (4.28.3-x86_64-linux) + google-protobuf (4.29.1-x86_64-linux) bigdecimal rake (>= 13) googleapis-common-protos (1.6.0) @@ -360,19 +363,20 @@ GEM grpc (~> 1.41) googleapis-common-protos-types (1.16.0) google-protobuf (>= 3.18, < 5.a) - googleauth (1.11.2) + googleauth (1.12.0) faraday (>= 1.0, < 3.a) - google-cloud-env (~> 2.1) + google-cloud-env (~> 2.2) + google-logging-utils (~> 0.1) jwt (>= 1.4, < 3.0) multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) groupdate (6.5.1) activesupport (>= 7) - grpc (1.67.0) + grpc (1.68.1) google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) - grpc (1.67.0-x86_64-linux) + grpc (1.68.1-x86_64-linux) google-protobuf (>= 3.25, < 5.0) googleapis-common-protos-types (~> 1.0) grpc-google-iam-v1 (1.8.0) @@ -389,7 +393,7 @@ GEM http-cookie (~> 1.0) http-form_data (~> 2.2) llhttp-ffi (~> 0.5.0) - http-cookie (1.0.7) + http-cookie (1.0.8) domain_name (~> 0.5) http-form_data (2.3.0) i18n (1.14.6) @@ -405,7 +409,7 @@ GEM has_scope (>= 0.6) railties (>= 6.0) responders (>= 2) - io-console (0.7.2) + io-console (0.8.0) irb (1.14.1) rdoc (>= 4.0.0) reline (>= 0.4.2) @@ -413,7 +417,7 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.8.1) + json (2.9.0) jsonapi-resources (0.9.12) activerecord (>= 4.1) concurrent-ruby @@ -447,7 +451,7 @@ GEM llhttp-ffi (0.5.0) ffi-compiler (~> 1.0) rake (~> 13.0) - logger (1.6.1) + logger (1.6.2) loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -461,17 +465,17 @@ GEM mime-types (3.6.0) logger mime-types-data (~> 3.2015) - mime-types-data (3.2024.1105) + mime-types-data (3.2024.1203) mini_magick (4.13.2) mini_mime (1.1.5) - mini_portile2 (2.8.7) - minitest (5.25.1) + mini_portile2 (2.8.8) + minitest (5.25.4) mjml-rails (4.12.1) msgpack (1.7.5) multi_json (1.15.0) mustache (1.1.1) - mutex_m (0.2.0) - net-http (0.5.0) + mutex_m (0.3.0) + net-http (0.6.0) uri net-imap (0.5.1) date @@ -488,10 +492,10 @@ GEM net-protocol net-ssh (7.3.0) nio4r (2.7.4) - nokogiri (1.16.7) + nokogiri (1.17.0) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.7-x86_64-linux) + nokogiri (1.17.0-x86_64-linux) racc (~> 1.4) oj (3.16.7) bigdecimal (>= 3.0) @@ -513,10 +517,11 @@ GEM patience_diff (1.2.0) optimist (~> 3.0) pg (1.5.9) - psych (5.2.0) + psych (5.2.1) + date stringio public_suffix (6.0.1) - puma (6.4.3) + puma (6.5.0) nio4r (~> 2.0) racc (1.8.1) rack (3.0.11) @@ -528,7 +533,7 @@ GEM rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rackup (2.2.0) + rackup (2.2.1) rack (>= 3) rails (7.1.5) actioncable (= 7.1.5) @@ -553,9 +558,9 @@ GEM activesupport (>= 4.2) choice (~> 0.2.0) ruby-graphviz (~> 1.2) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.1) loofah (~> 2.21) - nokogiri (~> 1.14) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) railties (7.1.5) actionpack (= 7.1.5) activesupport (= 7.1.5) @@ -570,7 +575,7 @@ GEM activerecord (>= 6.1.5) activesupport (>= 6.1.5) i18n - rdoc (6.7.0) + rdoc (6.8.1) psych (>= 4.0.0) redcarpet (3.6.0) redis (5.3.0) @@ -593,8 +598,8 @@ GEM redis-store (>= 1.2, < 2) redis-store (1.11.0) redis (>= 4, < 6) - regexp_parser (2.9.2) - reline (0.5.11) + regexp_parser (2.9.3) + reline (0.5.12) io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) @@ -632,14 +637,14 @@ GEM rspec-expectations (~> 3.13) rspec-mocks (~> 3.13) rspec-support (~> 3.13) - rspec-support (3.13.1) - rswag-api (2.15.0) - activesupport (>= 5.2, < 8.0) - railties (>= 5.2, < 8.0) - rswag-ui (2.15.0) - actionpack (>= 5.2, < 8.0) - railties (>= 5.2, < 8.0) - rubocop (1.66.1) + rspec-support (3.13.2) + rswag-api (2.16.0) + activesupport (>= 5.2, < 8.1) + railties (>= 5.2, < 8.1) + rswag-ui (2.16.0) + actionpack (>= 5.2, < 8.1) + railties (>= 5.2, < 8.1) + rubocop (1.68.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -649,7 +654,7 @@ GEM rubocop-ast (>= 1.32.2, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.35.0) + rubocop-ast (1.36.2) parser (>= 3.3.1.0) rubocop-performance (1.22.1) rubocop (>= 1.48.1, < 2.0) @@ -678,21 +683,21 @@ GEM sprockets (> 3.0) sprockets-rails tilt - securerandom (0.3.2) + securerandom (0.4.0) sendgrid-actionmailer (3.2.0) mail (~> 2.7) sendgrid-ruby (~> 6.4) sendgrid-ruby (6.7.0) ruby_http_client (~> 3.4) - sentry-rails (5.21.0) + sentry-rails (5.22.0) railties (>= 5.0) - sentry-ruby (~> 5.21.0) - sentry-ruby (5.21.0) + sentry-ruby (~> 5.22.0) + sentry-ruby (5.22.0) bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) shoulda-matchers (4.0.1) activesupport (>= 4.2.0) - sidekiq (7.3.5) + sidekiq (7.3.6) connection_pool (>= 2.3.0) logger rack (>= 2.2.4) @@ -722,10 +727,10 @@ GEM net-ssh (>= 2.8.0) ostruct ssrf_filter (1.2.0) - standard (1.41.1) + standard (1.42.1) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) - rubocop (~> 1.66.0) + rubocop (~> 1.68.0) standard-custom (~> 1.0.0) standard-performance (~> 1.5) standard-custom (1.0.2) @@ -735,7 +740,7 @@ GEM lint_roller (~> 1.1) rubocop-performance (~> 1.22.0) stringio (3.1.2) - super_diff (0.13.0) + super_diff (0.14.0) attr_extras (>= 6.2.4) diff-lcs patience_diff @@ -751,7 +756,7 @@ GEM unaccent (0.4.0) unicode-display_width (2.6.0) uniform_notifier (1.16.0) - uri (1.0.1) + uri (1.0.2) warden (1.2.9) rack (>= 2.0.9) web-console (4.2.1) @@ -763,7 +768,7 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webrick (1.9.0) + webrick (1.9.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) diff --git a/app/controllers/v1/sessions_controller.rb b/app/controllers/v1/sessions_controller.rb index 8942e5f38..16589e8b3 100644 --- a/app/controllers/v1/sessions_controller.rb +++ b/app/controllers/v1/sessions_controller.rb @@ -6,7 +6,7 @@ class SessionsController < APIController def create @user = User.find_by(email: auth_params[:email]) - if @user&.valid_password?(auth_params[:password]) && @user&.is_active + if @user.present? && @user.valid_password?(auth_params[:password]) && @user.is_active token = Auth.issue({user: @user.id}) @user.update_tracked_fields!(request) render json: {token: token, role: @user.user_permission.user_role, diff --git a/lib/tasks/single_use/quality_control.rake b/lib/tasks/single_use/quality_control.rake index 8465d87be..25f1dc485 100644 --- a/lib/tasks/single_use/quality_control.rake +++ b/lib/tasks/single_use/quality_control.rake @@ -55,7 +55,8 @@ namespace :quality_control do passed = version.changeset["validation_status"].last == "Ready for publication" before_changes = version.reify - comment = before_changes&.admin_comment + # next line rubocop reporting some false positive, it's not useless assignment + comment = before_changes&.admin_comment # rubocop:disable Link/UselessAssignment if version.changeset.key?("admin_comment") comment = version.changeset["admin_comment"].last