Skip to content

Commit

Permalink
Merge pull request #133 from Vizzuality/release/tpi-production-seeds
Browse files Browse the repository at this point in the history
Release/tpi production seeds
  • Loading branch information
simaob committed Nov 25, 2019
2 parents 63c834c + 22e4f87 commit befc726
Show file tree
Hide file tree
Showing 122 changed files with 2,723 additions and 1,542 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Expand Up @@ -25,6 +25,9 @@ Layout/DotPosition:
Naming/HeredocDelimiterNaming:
Enabled: false

Style/BracesAroundHashParameters:
EnforcedStyle: context_dependent

Style/SymbolArray:
EnforcedStyle: brackets

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -24,6 +24,7 @@ gem 'octokit', '~> 4.0'
gem 'google-cloud-storage', require: false

gem 'discard'
gem 'public_activity'
gem 'friendly_id'
gem 'language_list'

Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Expand Up @@ -277,6 +277,11 @@ GEM
pg (1.1.4)
polyamorous (2.3.0)
activerecord (>= 5.0)
public_activity (1.6.4)
actionpack (>= 3.0.0)
activerecord (>= 3.0)
i18n (>= 0.5.0)
railties (>= 3.0.0)
public_suffix (4.0.1)
puma (4.3.0)
nio4r (~> 2.0)
Expand Down Expand Up @@ -492,6 +497,7 @@ DEPENDENCIES
listen (>= 3.0.5, < 3.2)
octokit (~> 4.0)
pg (>= 0.18, < 2.0)
public_activity
puma (~> 4.1)
rails (~> 6.0.1)
rails-controller-testing
Expand Down
23 changes: 23 additions & 0 deletions app/admin/activities.rb
@@ -0,0 +1,23 @@
ActiveAdmin.register PublicActivity::Activity do
config.per_page = 30
config.batch_actions = false

menu parent: 'Administration', priority: 3, label: 'Users Activity'

decorate_with PublicActivity::ActivityDecorator

actions :all, except: [:new, :create]

filter :trackable_type, label: 'Record Type'
filter :owner_of_AdminUser_type_email_contains, label: 'User email contains'
filter :key_contains, label: 'Action details contains'
filter :updated_at

index title: 'Users Activity' do
column 'Record Type', :trackable_type
column 'Record', :trackable, &:trackable_link
column 'Activity details', &:activity_details
column 'User', :owner
column :updated_at, &:updated_at_display
end
end
26 changes: 18 additions & 8 deletions app/admin/companies.rb
Expand Up @@ -10,15 +10,16 @@
publishable_sidebar only: :show

permit_params :name, :isin, :sector_id, :geography_id, :headquarters_geography_id,
:ca100, :size, :visibility_status
:ca100, :market_cap_group, :visibility_status, :sedol,
:latest_information, :historical_comments

filter :isin_contains, label: 'ISIN'
filter :name_contains, label: 'Name'
filter :geography
filter :headquarters_geography
filter :size,
filter :market_cap_group,
as: :check_boxes,
collection: proc { array_to_select_collection(Company::SIZES) }
collection: proc { array_to_select_collection(Company::MARKET_CAP_GROUPS) }

data_export_sidebar 'Companies'

Expand All @@ -39,11 +40,14 @@
row :slug
row :sector
row :isin, &:isin_as_tags
row :sedol
row :geography
row :headquarters_geography
row :ca100
row :size
row :market_cap_group
row 'Management Quality Level', &:mq_level_tag
row :latest_information
row :historical_comments
row :created_at
row :updated_at
end
Expand Down Expand Up @@ -118,7 +122,7 @@
index do
column(:name) { |company| link_to company.name, admin_company_path(company) }
column :isin, &:isin_as_tags
column(:size) { |company| company.size.humanize }
column(:market_cap_group) { |company| company.market_cap_group.humanize }
column :level, &:mq_level_tag
column :geography
column :headquarters_geography
Expand All @@ -132,11 +136,13 @@
column :name
column :isin
column(:sector) { |c| c.sector.name }
column :size
column :market_cap_group
column :sedol
column(:geography_iso) { |c| c.geography.iso }
column(:geography) { |c| c.geography.name }
column(:headquarters_geography_iso) { |c| c.headquarters_geography.iso }
column(:headquarters_geography) { |c| c.headquarters_geography.name }
column :latest_information
column :ca100
column :visibility_status
end
Expand All @@ -148,14 +154,15 @@
columns do
column { f.input :name }
column { f.input :isin, as: :tags }
column { f.input :sedol }
end

columns do
column { f.input :sector }
column do
f.input :size,
f.input :market_cap_group,
as: :select,
collection: array_to_select_collection(Company::SIZES)
collection: array_to_select_collection(Company::MARKET_CAP_GROUPS)
end
end

Expand All @@ -168,6 +175,9 @@
end

f.input :ca100

f.input :latest_information
f.input :historical_comments
end

f.actions
Expand Down
1 change: 1 addition & 0 deletions app/admin/cp_assessments.rb
Expand Up @@ -48,6 +48,7 @@
year_columns = collection.flat_map(&:emissions_all_years).uniq.sort

column :id
column(:company_id) { |a| a.company.id }
column(:company) { |a| a.company.name }
column :assessment_date
column :publication_date, &:publication_date_csv
Expand Down
1 change: 1 addition & 0 deletions app/admin/instrument.rb
Expand Up @@ -4,6 +4,7 @@
permit_params :name, :instrument_type_id

config.batch_actions = false
config.sort_order = 'name_asc'

decorate_with InstrumentDecorator

Expand Down
1 change: 1 addition & 0 deletions app/admin/laws_sectors.rb
@@ -1,5 +1,6 @@
ActiveAdmin.register LawsSector do
config.batch_actions = false
config.sort_order = 'name_asc'

menu parent: 'Laws', priority: 5

Expand Down
30 changes: 19 additions & 11 deletions app/admin/legislations.rb
Expand Up @@ -7,10 +7,10 @@

publishable_scopes

permit_params :title, :date_passed, :description,
permit_params :title, :date_passed, :description, :parent_id,
:geography_id, :sector_id, :law_id, :legislation_type,
:created_by_id, :updated_by_id, :visibility_status,
:natural_hazards_string, :keywords_string,
:natural_hazards_string, :keywords_string, :responses_string,
events_attributes: permit_params_for(:events),
documents_attributes: permit_params_for(:documents),
framework_ids: [], document_type_ids: [], instrument_ids: [],
Expand All @@ -26,19 +26,21 @@
filter :frameworks,
as: :check_boxes,
collection: proc { Framework.all }
filter :responses,
as: :check_boxes,
collection: proc { Response.all }
filter :visibility_status,
as: :select,
collection: proc { array_to_select_collection(VisibilityStatus::VISIBILITY) }

index title: 'Laws and Policies' do
selectable_column
column :title, &:title_summary_link
column :legislation_type
column :date_passed
column 'Frameworks', &:frameworks_string
column :geography
column :sector
column :legislation_type
column :document_types
column :date_passed
column 'Parent Legislation', &:parent
column :created_by
column :updated_by
tag_column :visibility_status
Expand All @@ -58,20 +60,22 @@
row :description
row :date_passed
row :geography
row 'Parent legislation', &:parent
row :sector
row :law_id
row :legislation_type
row 'Frameworks', &:frameworks_string
row :updated_at
row :updated_by
row :created_at
row :created_by
row 'Document Types', &:document_types_string
row 'Keywords', &:keywords_string
row 'Responses (e.g. adaptation or mitigation)', &:responses_string
row 'Natural Hazards', &:natural_hazards_string
row 'Keywords', &:keywords_string
list_row 'Documents', :document_links
list_row 'Instruments', :instrument_links
list_row 'Governances', :governance_links
row :updated_at
row :updated_by
row :created_at
row :created_by
end
end

Expand Down Expand Up @@ -105,10 +109,12 @@
column(:legislation_type) { |l| l.legislation_type.downcase }
column :date_passed
column :description
column(:parent) { |l| l.parent&.title }
column(:geography) { |l| l.geography.name }
column(:geography_iso) { |l| l.geography.iso }
column(:sector) { |l| l.sector&.name }
column :frameworks, &:frameworks_string
column :responses, &:responses_string
column :document_types, &:document_types_string
column :keywords, &:keywords_string
column :natural_hazards, &:natural_hazards_string
Expand Down Expand Up @@ -161,8 +167,10 @@
def scoped_collection
super.includes(
:geography,
:parent,
:sector,
:frameworks,
:responses,
:keywords,
:natural_hazards,
:document_types,
Expand Down
33 changes: 19 additions & 14 deletions app/admin/litigations.rb
Expand Up @@ -7,18 +7,20 @@
publishable_sidebar only: :show

permit_params :title, :jurisdiction_id, :sector_id, :document_type,
:visibility_status, :summary, :core_objective,
:citation_reference_number,
:created_by_id, :updated_by_id, :keywords_string,
:visibility_status, :summary, :at_issue,
:citation_reference_number, :created_by_id, :updated_by_id,
:keywords_string, :responses_string,
litigation_sides_attributes: permit_params_for(:litigation_sides),
documents_attributes: permit_params_for(:documents),
events_attributes: permit_params_for(:events),
legislation_ids: [],
external_legislation_ids: []
legislation_ids: [], external_legislation_ids: []

filter :title_contains
filter :summary_contains
filter :jurisdiction
filter :responses,
as: :check_boxes,
collection: proc { Response.all }
filter :document_type, as: :select, collection: proc {
array_to_select_collection(Litigation::DOCUMENT_TYPES)
}
Expand All @@ -44,9 +46,8 @@
index do
selectable_column
column :title, class: 'max-width-300', &:title_link
column :document_type
column :jurisdiction
column :sector
column :document_type
column :citation_reference_number
column :created_by
column :updated_by
Expand All @@ -64,8 +65,9 @@
column(:sector) { |l| l.sector&.name }
column :citation_reference_number
column :summary
column :responses, &:responses_string
column :keywords, &:keywords_string
column :core_objective
column :at_issue
column(:visibility_status) { |l| l.visibility_status&.humanize }
column(:legislation_ids) { |l| l.legislation_ids.join('; ') }
end
Expand All @@ -82,21 +84,23 @@
row :document_type
row :citation_reference_number
row :summary
row :core_objective
row :at_issue
row 'Responses (e.g. adaptation or mitigation)', &:responses_string
row 'Keywords', &:keywords_string
list_row 'Documents', :document_links
list_row 'Laws', :legislation_links
list_row 'External Laws', :external_legislation_links
row :updated_at
row :updated_by
row :created_at
row :created_by
list_row 'Documents', :document_links
list_row 'Laws', :legislation_links
list_row 'External Laws', :external_legislation_links
end
end

tab :sides do
panel 'Litigation Sides' do
table_for resource.litigation_sides.decorate do
table_for resource.litigation_sides
.includes(:connected_entity).decorate do
column :side_type
column :name
column :party_type
Expand Down Expand Up @@ -156,7 +160,8 @@
include DiscardableController

def scoped_collection
super.includes(:jurisdiction, :sector, :created_by, :updated_by)
super.includes(:jurisdiction, :sector, :responses,
:created_by, :updated_by)
end
end
end
3 changes: 3 additions & 0 deletions app/admin/mq_assessments.rb
Expand Up @@ -66,6 +66,7 @@
form partial: 'form'

index do
column :methodology_version
column :title, &:title_link
column :assessment_date
column :publication_date
Expand All @@ -75,6 +76,8 @@

csv do
column :id
column :methodology_version
column(:company_id) { |a| a.company.id }
column(:company) { |a| a.company.name }
column :assessment_date
column :publication_date, &:publication_date_csv
Expand Down
7 changes: 4 additions & 3 deletions app/admin/tags.rb
@@ -1,8 +1,9 @@
%w[
PoliticalGroup
NaturalHazard
Keyword
Framework
Keyword
NaturalHazard
PoliticalGroup
Response
].each do |tag_class|
ActiveAdmin.register tag_class.constantize do
config.sort_order = 'name_asc'
Expand Down
13 changes: 13 additions & 0 deletions app/assets/images/icons/country-flag.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit befc726

Please sign in to comment.