Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Participation module #3909

Merged
merged 16 commits into from
Oct 16, 2021
Prev Previous commit
Next Next commit
update files
  • Loading branch information
stbnrivas authored and entantoencuanto committed Oct 5, 2021
commit c80df4592a6df7395b0684a738e6f63bdc093653
5 changes: 3 additions & 2 deletions app/helpers/gobierto_cms/page_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ def section_tree(nodes, viewables)

def gobierto_cms_page_or_news_path(page, options = {})
url_helpers = Rails.application.routes.url_helpers
if page.collection.item_type == "GobiertoCms::Page"

if page.collection&.item_type == "GobiertoCms::Page"
section = page.section
if section
url_helpers.gobierto_cms_section_item_path(section.slug, page.slug, options)
else
url_helpers.gobierto_cms_page_path(page.slug, options)
end
elsif page.collection.item_type == "GobiertoCms::News"
elsif page.collection&.item_type == "GobiertoCms::News"
url_helpers.gobierto_cms_news_path(page.slug, options)
end
end
Expand Down
4 changes: 0 additions & 4 deletions app/javascript/gobierto_admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ import './modules/module-admin-search.js'
import './modules/people_controller.js'
import './modules/person_controller.js'
import './modules/person_events_controller.js'
import './modules/process_polls_controller.js'
import './modules/process_stage_pages_controller.js'
import './modules/process_stages_controller.js'
import './modules/processes_controller.js'
import './modules/sections_controller.js'
import './modules/terms_controller.js'
import './modules/sites_controller.js'
Expand Down
2 changes: 1 addition & 1 deletion app/models/gobierto_attachments/attaching.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def create_collection
container_id: attachable.collection.container_id,
item_type: attachment.class.name,
slug: "attachment-#{attachable.collection.slug}",
title: I18n.t("gobierto_participation.shared.documents")
title: "" #FIXME
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h2>
<%= link_to edit_admin_cms_page_path(page, collection_id: page.collection), class: "tipsit draggable", title: t('.page_help'), data: { id: page.id, title: page.title } do %>
<%= page.title %>
<span class="secondary"><%= page.collection.title %></span>
<span class="secondary"><%= page.collection&.title %></span>
<% end %>
</h2>
<div class="date"><%= time_ago_in_words(page.updated_at) %></div>
Expand Down
34 changes: 34 additions & 0 deletions db/migrate/20210701062214_remove_module_gobierto_participation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class RemoveModuleGobiertoParticipation < ActiveRecord::Migration[6.0]

def change
GobiertoModuleSettings.where(module_name: 'GobiertoParticipation').each(&:delete)
Activity.where(recipient_type: "GobiertoParticipation::Process").each(&:delete)

GobiertoCommon::CollectionItem.where(item_type: "GobiertoParticipation::Process").each(&:delete)
GobiertoCommon::CollectionItem.where(item_type: "GobiertoParticipation").each(&:delete)

GobiertoCommon::Collection.where(container_type: "GobiertoParticipation::Process").each(&:delete)
GobiertoCommon::Collection.where(container_type: "GobiertoParticipation").each(&:delete)


drop_table :gpart_comments
drop_table :gpart_contribution_containers
drop_table :gpart_contributions
drop_table :gpart_flags
drop_table :gpart_poll_answer_templates
drop_table :gpart_poll_answers
drop_table :gpart_poll_questions
drop_table :gpart_polls
drop_table :gpart_process_stage_pages
drop_table :gpart_process_stages
drop_table :gpart_processes
drop_table :gpart_votes

Site.all.each do |site|
site.configuration_data["modules"].delete("GobiertoParticipation")
site.configuration_data["modules"].first if site.configuration_data["home_page"] == "GobiertoParticipation"
site.save
end
end

end
46 changes: 0 additions & 46 deletions lib/tasks/gobierto_common/migrate_to_vocabularies.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@ namespace :common do
namespace :migrate_to_vocabularies do
desc "Generate a vocabulary for each site from existing issues"
task issues: :environment do
ignored_attributes = %w(id site_id created_at updated_at)
Site.all.each do |site|
next if Issue.where(site: site).blank?
puts "== Migrating issues of #{ site.domain }"
issues = site.vocabularies.find_or_create_by(name: "issues")
scopes_vocabulary_id = site.gobierto_participation_settings&.scopes_vocabulary_id
settings = ::GobiertoAdmin::GobiertoParticipation::SettingsForm.new(site_id: site.id, issues_vocabulary_id: issues.id, scopes_vocabulary_id: scopes_vocabulary_id)
settings.save
Issue.where(site: site).each do |issue|
next if issues.terms.where(slug: issue.slug).exists?
term = issues.terms.create(issue.attributes.except(*ignored_attributes))
puts "== Created term of issues vocabulary: #{ term.name }"
end
end

GobiertoCommon::Collection.where(container_type: "Issue").each do |collection|
move_issue_to_term(
Expand Down Expand Up @@ -57,33 +43,10 @@ namespace :common do
)
end

GobiertoParticipation::Process.where.not(issue_id: nil).each do |process|
site = process.site
next if (issue = Issue.where(site: site).find_by_id(process.issue_id)).blank?
term = site.issues.find_by(name_translations: issue.name_translations)
if term.blank?
term = site.issues.terms.create(issue.attributes.except(*ignored_attributes))
end
process.update_attribute(:issue_id, term.id)
end
end

desc "Generate a vocabulary for each site from existing scopes"
task scopes: :environment do
ignored_attributes = %w(id site_id created_at updated_at)
Site.all.each do |site|
next if GobiertoCommon::Scope.where(site: site).blank?
puts "== Migrating scopes of #{ site.domain }"
scopes = site.vocabularies.find_or_create_by(name: "scopes")
issues_vocabulary_id = site.gobierto_participation_settings&.issues_vocabulary_id
settings = ::GobiertoAdmin::GobiertoParticipation::SettingsForm.new(site_id: site.id, scopes_vocabulary_id: scopes.id, issues_vocabulary_id: issues_vocabulary_id)
settings.save
GobiertoCommon::Scope.where(site: site).each do |scope|
next if scopes.terms.where(slug: scope.slug).exists?
term = scopes.terms.create(scope.attributes.except(*ignored_attributes))
puts "== Created term of scopes vocabulary: #{ term.name }"
end
end

GobiertoCommon::Collection.where(container_type: "GobiertoCommon::Scope").each do |collection|
move_scope_to_term(
Expand Down Expand Up @@ -123,15 +86,6 @@ namespace :common do
)
end

GobiertoParticipation::Process.where.not(scope_id: nil).each do |process|
site = process.site
next if (scope = GobiertoCommon::Scope.where(site: site).find_by_id(process.scope_id)).blank?
term = site.scopes.find_by(name_translations: scope.name_translations)
if term.blank?
term = site.scopes.terms.create(scope.attributes.except(*ignored_attributes))
end
process.update_attribute(:scope_id, term.id)
end
end

desc "Generate a vocabulary for each site from existing political groups"
Expand Down
4 changes: 2 additions & 2 deletions test/integration/gobierto_admin/site_update_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_site_update
end

select privacy_page.title, from: "site_privacy_page_id"
select "GobiertoParticipation", from: "site_home_page"
select "GobiertoBudgets", from: "site_home_page"

with_stubbed_s3_file_upload do
with_stubbed_s3_upload! do
Expand All @@ -90,7 +90,7 @@ def test_site_update
assert has_field?("site_links_markup", with: "Site Links markup")
assert has_field?("site_google_analytics_id", with: "UA-000000-01")
assert has_select?("Privacy page", selected: privacy_page.title)
assert has_select?("site_home_page", selected: "GobiertoParticipation")
assert has_select?("site_home_page", selected: "GobiertoBudgets")
assert has_field?("site_populate_data_api_token", with: "APITOKEN")
assert has_field?("site_raw_configuration_variables", with: "var1: value1\r\nvar2: value2\r\n")

Expand Down