Skip to content

Commit

Permalink
Merge branch 'chore/update-dependencies' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Sep 19, 2024
2 parents f89baa0 + 037bc2d commit 397885e
Show file tree
Hide file tree
Showing 20 changed files with 231 additions and 204 deletions.
367 changes: 197 additions & 170 deletions Gemfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/admin/observation_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def scoped_collection
end

def apply_filtering(chain)
super(chain).distinct
super.distinct
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Category < ApplicationRecord
include Translatable
enum category_type: {operator: 0, government: 1}
enum :category_type, {operator: 0, government: 1}

translates :name, touch: true
active_admin_translates :name do
Expand Down
2 changes: 1 addition & 1 deletion app/models/fmu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Fmu < ApplicationRecord
include EsriShapefileUpload
include ValidationHelper

enum forest_type: ForestType::TYPES_WITH_CODE
enum :forest_type, ForestType::TYPES_WITH_CODE

belongs_to :country, inverse_of: :fmus
has_many :observations, inverse_of: :fmu, dependent: :destroy
Expand Down
4 changes: 2 additions & 2 deletions app/models/gov_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class GovDocument < ApplicationRecord
has_paper_trail
acts_as_paranoid

enum status: {doc_not_provided: 0, doc_pending: 1, doc_invalid: 2, doc_valid: 3, doc_expired: 4}
enum uploaded_by: {government: 1, admin: 2}
enum :status, {doc_not_provided: 0, doc_pending: 1, doc_invalid: 2, doc_valid: 3, doc_expired: 4}
enum :uploaded_by, {government: 1, admin: 2}

belongs_to :user, optional: true
belongs_to :country
Expand Down
8 changes: 4 additions & 4 deletions app/models/observation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class Observation < ApplicationRecord

WrongStateError = Class.new(StandardError)

enum evidence_type: {"No evidence" => 0, "Uploaded documents" => 1, "Evidence presented in the report" => 2}
enum observation_type: {"operator" => 0, "government" => 1}
enum validation_status: {
enum :evidence_type, {"No evidence" => 0, "Uploaded documents" => 1, "Evidence presented in the report" => 2}
enum :observation_type, {"operator" => 0, "government" => 1}
enum :validation_status, {
"Created" => 0,
"Ready for QC1" => 10,
"QC1 in progress" => 11,
Expand All @@ -73,7 +73,7 @@ class Observation < ApplicationRecord
"Published (not modified)" => 8,
"Published (modified)" => 9
}
enum location_accuracy: {
enum :location_accuracy, {
"Estimated location" => 0, "GPS coordinates extracted from photo" => 1, "Accurate GPS coordinates" => 2
}

Expand Down
2 changes: 1 addition & 1 deletion app/models/observation_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ObservationDocument < ApplicationRecord
mount_base64_uploader :attachment, ObservationDocumentUploader
include MoveableAttachment

enum document_type: {
enum :document_type, {
"Government Documents" => 0, "Company Documents" => 1, "Photos" => 2,
"Testimony from local communities" => 3, "Other" => 4, "Maps" => 5
}
Expand Down
8 changes: 4 additions & 4 deletions app/models/observation_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
class ObservationHistory < ApplicationRecord
acts_as_paranoid

enum observation_type: {"operator" => 0, "government" => 1}
enum validation_status: {
enum :observation_type, {"operator" => 0, "government" => 1}
enum :validation_status, {
"Created" => 0,
"Ready for QC1" => 10,
"QC1 in progress" => 11,
Expand All @@ -42,9 +42,9 @@ class ObservationHistory < ApplicationRecord
"Published (not modified)" => 8,
"Published (modified)" => 9
}
enum location_accuracy: {"Estimated location" => 0, "GPS coordinates extracted from photo" => 1,
enum :location_accuracy, {"Estimated location" => 0, "GPS coordinates extracted from photo" => 1,
"Accurate GPS coordinates" => 2}
enum fmu_forest_type: ForestType::TYPES_WITH_CODE
enum :fmu_forest_type, ForestType::TYPES_WITH_CODE

belongs_to :observation
belongs_to :country
Expand Down
6 changes: 3 additions & 3 deletions app/models/observation_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ObservationStatistic < ApplicationRecord
belongs_to :subcategory, optional: true
belongs_to :operator, optional: true

enum validation_status: {
enum :validation_status, {
"Created" => 0,
"Ready for QC" => 1,
"QC in progress" => 2,
Expand All @@ -43,8 +43,8 @@ class ObservationStatistic < ApplicationRecord
"Published (modified)" => 9,
"Published (all)" => 789 # extra state for looking for all published
}
enum observation_type: {"operator" => 0, "government" => 1}
enum fmu_forest_type: ForestType::TYPES_WITH_CODE
enum :observation_type, {"operator" => 0, "government" => 1}
enum :fmu_forest_type, ForestType::TYPES_WITH_CODE

validates :date, presence: true

Expand Down
6 changes: 3 additions & 3 deletions app/models/operator_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ class OperatorDocument < ApplicationRecord
.where(required_operator_documents: {contract_signature: false})
}

enum status: {doc_not_provided: 0, doc_pending: 1, doc_invalid: 2, doc_valid: 3, doc_expired: 4, doc_not_required: 5}
enum uploaded_by: {operator: 1, monitor: 2, admin: 3, other: 4}
enum source: {company: 1, forest_atlas: 2, other_source: 3}
enum :status, {doc_not_provided: 0, doc_pending: 1, doc_invalid: 2, doc_valid: 3, doc_expired: 4, doc_not_required: 5}
enum :uploaded_by, {operator: 1, monitor: 2, admin: 3, other: 4}
enum :source, {company: 1, forest_atlas: 2, other_source: 3}

NON_HISTORICAL_ATTRIBUTES = %w[id attachment updated_at created_at].freeze
EXPIRABLE_STATUSES = %w[doc_valid doc_not_required]
Expand Down
4 changes: 2 additions & 2 deletions app/models/operator_document_annex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class OperatorDocumentAnnex < ApplicationRecord

validates :name, :start_date, :status, presence: true

enum status: {doc_pending: 1, doc_invalid: 2, doc_valid: 3, doc_expired: 4}
enum uploaded_by: {operator: 1, monitor: 2, admin: 3, other: 4}
enum :status, {doc_pending: 1, doc_invalid: 2, doc_valid: 3, doc_expired: 4}
enum :uploaded_by, {operator: 1, monitor: 2, admin: 3, other: 4}

scope :valid, -> { where(status: OperatorDocumentAnnex.statuses[:doc_valid]) }
scope :from_user, ->(operator_id) { joins(:operator_document).where(operator_documents: {operator_id: operator_id}) }
Expand Down
6 changes: 3 additions & 3 deletions app/models/operator_document_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class OperatorDocumentHistory < ApplicationRecord
scope :non_signature, -> { joins(:required_operator_document).where(required_operator_documents: {contract_signature: false}) } # non signature
scope :valid, -> { joins(:operator_document).where(operator_documents: {status: OperatorDocument.statuses[:doc_valid]}) } # valid doc

enum status: {doc_not_provided: 0, doc_pending: 1, doc_invalid: 2, doc_valid: 3, doc_expired: 4, doc_not_required: 5}
enum uploaded_by: {operator: 1, monitor: 2, admin: 3, other: 4}
enum source: {company: 1, forest_atlas: 2, other_source: 3}
enum :status, {doc_not_provided: 0, doc_pending: 1, doc_invalid: 2, doc_valid: 3, doc_expired: 4, doc_not_required: 5}
enum :uploaded_by, {operator: 1, monitor: 2, admin: 3, other: 4}
enum :source, {company: 1, forest_atlas: 2, other_source: 3}

# Returns the collection of OperatorDocumentHistory for a given operator at a point in time
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/operator_document_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OperatorDocumentStatistic < ApplicationRecord
belongs_to :country, optional: true
belongs_to :required_operator_document_group, optional: true

enum fmu_forest_type: ForestType::TYPES_WITH_CODE
enum :fmu_forest_type, ForestType::TYPES_WITH_CODE

validates :date, presence: true
validates :date, uniqueness: {scope: [:country_id, :required_operator_document_group_id, :fmu_forest_type, :document_type]}
Expand Down
2 changes: 1 addition & 1 deletion app/models/required_gov_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RequiredGovDocument < ApplicationRecord
belongs_to :country
has_many :gov_documents, dependent: :destroy

enum document_type: {file: 1, link: 2, stats: 3}
enum :document_type, {file: 1, link: 2, stats: 3}

validates :document_type, inclusion: {in: RequiredGovDocument.document_types.keys}
validates :valid_period, numericality: {greater_than: 0}, if: :valid_period?
Expand Down
2 changes: 1 addition & 1 deletion app/models/subcategory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class Subcategory < ApplicationRecord
include Translatable
enum subcategory_type: {operator: 0, government: 1}
enum :subcategory_type, {operator: 0, government: 1}
translates :name, :details, touch: true

# rubocop:disable Standard/BlockSingleLineBraces
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class User < ApplicationRecord

normalizes :first_name, :last_name, :name, with: -> { _1.strip }

enum permissions_request: {operator: 1, ngo: 2, ngo_manager: 4, government: 6, holding: 7}
enum :permissions_request, {operator: 1, ngo: 2, ngo_manager: 4, government: 6, holding: 7}

belongs_to :country, inverse_of: :users, optional: true

Expand Down
4 changes: 2 additions & 2 deletions app/models/user_permission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#

class UserPermission < ApplicationRecord
enum user_role: {user: 0, operator: 1, ngo: 2, ngo_manager: 4,
bo_manager: 5, admin: 3, government: 6, holding: 7}.freeze
enum :user_role, {user: 0, operator: 1, ngo: 2, ngo_manager: 4,
bo_manager: 5, admin: 3, government: 6, holding: 7}.freeze

belongs_to :user

Expand Down
2 changes: 1 addition & 1 deletion app/resources/v1/law_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def self.apply_sort(records, order_options, context = {})
if order_options["country.name"].present? || order_options["subcategory.name"].present?
order_options["id"] = "DESC"
end
super(records, order_options, context)
super
end

def complete
Expand Down
2 changes: 1 addition & 1 deletion app/resources/v1/observation_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def self.apply_sort(records, order_options, context = {})
records = records.order_by_category(order_options["subcategory.category.name"])
order_options.except!("subcategory.category.name")
end
super(records, order_options, context)
super
end

def self.apply_includes(records, directives)
Expand Down
2 changes: 1 addition & 1 deletion app/resources/v1/operator_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def self.records(options = {})

# not great to filter by controller here, but not sure how to do it in observation resource only
if (app == "observations-tool" && user.present?) || controller == "v1/observations"
super(options)
super
else
Operator.active
end
Expand Down

0 comments on commit 397885e

Please sign in to comment.