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
Merged

Remove Participation module #3909

merged 16 commits into from
Oct 16, 2021

Conversation

stbnrivas
Copy link
Contributor

@stbnrivas stbnrivas commented Jul 1, 2021

Closes #3826

✌️ What does this PR do?

remove module participations and its dependencies into other modules

  • gobierto cms
  • gobierto_calendars | because process and event (pg_search)

@stbnrivas
Copy link
Contributor Author

Hi!, @ferblape about

def test_destroyable?
refute process_information_page.destroyable?
::GobiertoParticipation::ProcessStagePage.where(
page_id: process_information_page.id
).destroy_all
assert process_information_page.reload.destroyable?
end

about this test this should be (2 preferred)

  1. removed
  2. replaced for another model ¿why model can I use?

@ferblape
Copy link
Member

ferblape commented Jul 1, 2021 via email

@stbnrivas
Copy link
Contributor Author

stbnrivas commented Jul 1, 2021

what's about GobiertoAttachment::AttachmentDocumentsController? Does it make sense without GobiertoParticipations::Process?

def set_context
return unless @attachment
@current_module = @attachment.module
@current_process ||= begin
if @collection && @collection.container_type == "GobiertoParticipation::Process"
@collection.container
end
end
end

thx

@ferblape
Copy link
Member

ferblape commented Jul 1, 2021 via email

@stbnrivas stbnrivas force-pushed the 3826-remove-module-participation branch from cd5b708 to cc0082d Compare July 1, 2021 12:58
@stbnrivas
Copy link
Contributor Author

stbnrivas commented Jul 2, 2021

@blat I have a problem with a test that before works and not now ... I am missing something...

def root_level_term
@root_level_term ||= gobierto_common_terms(:mammal)
end
def dependent_level_term
@dependent_level_term ||= gobierto_common_terms(:dog)
end
def terms_with_dependencies
@terms_with_dependencies ||= {
issue: gobierto_common_terms(:culture_term),
scope: gobierto_common_terms(:center_term),
political_group: gobierto_common_terms(:marvel_term)
}
end

but the problem is that this fixtures(culture_term, center_term, marvel_term) don't have dependent into sublevel

def test_destroy_of_term_with_dependencies
terms_with_dependencies.each do |_, term|
refute term.destroy
end
end

an example of dependant level with animals and dog fixtures level is (note line 19 below)

mammal:
vocabulary: animals
name_translations: <%= { es: "Mamífero", en: "Mammal" }.to_json %>
description_translations: <%= { es: "Vertebrado caracterizado por presentar glándulas mamarias", en: "Vertebrates characterised by the possession of mammary glands" }.to_json %>
slug: <%= "animals-mammal" %>
position: 0
level: 0
external_id: 1
dog:
vocabulary: animals
name_translations: <%= { es: "Perro", en: "Dog" }.to_json %>
description_translations: <%= { es: "Mamífero que ladra", en: "Mammal who barks" }.to_json %>
slug: <%= "animals-dog" %>
position: 0
level: 1
term_id: <%= ActiveRecord::FixtureSet.identify(:mammal) %>
external_id: 2

but into all term.yml there are single culture_term

  1. I propose change:
# change this
  def test_destroy_of_term_with_dependencies
    terms_with_dependencies.each do |_, term|
      refute term.destroy
    end
  end

# to this
  def test_destroy_of_term_with_dependencies
    refute root_level_term.destroy
  end

But I have a worse problem the decorator don't detect terms collection here

def destroy
dependent_resources_decorator = TermDependentResourcesDecorator.new(self)
if dependent_resources_decorator.has_dependent_resources?
errors.add(:base, :has_dependent_resources_html, dependencies_list: dependent_resources_decorator.dependencies_list)
return false
end
super
end

TermDependendentResourceDecorator is not enough. I need add some changes at:

def destroy
dependent_resources_decorator = TermDependentResourcesDecorator.new(self)
if dependent_resources_decorator.has_dependent_resources?
errors.add(:base, :has_dependent_resources_html, dependencies_list: dependent_resources_decorator.dependencies_list)
return false
end
super
end

  1. I propose add new case to dependant
def destroy
      dependent_resources_decorator = TermDependentResourcesDecorator.new(self)
      if dependent_resources_decorator.has_dependent_resources?
        errors.add(:base, :has_dependent_resources_html, dependencies_list: dependent_resources_decorator.dependencies_list)
        return false
      elsif !terms.empty?
        errors.add(:base, :has_dependent_resources_html, dependencies_list: "term_id")
        return false
      end

      super
    end

What am I missing?

@stbnrivas stbnrivas force-pushed the 3826-remove-module-participation branch from cc0082d to 9bb7fc7 Compare July 2, 2021 10:22
@stbnrivas
Copy link
Contributor Author

should I delete (full) or refactor this decorator and its test? . I am not sure about because it looks like a feature into GobiertoCMS designed to be used by GobiertoParticipations.

So with participation deleted. Does it keeping sense?

def test_template
assert_equal "gobierto_cms/pages/templates/page", site_page_decorated.template
assert_equal "gobierto_participation/processes/pages/templates/news", themes_page_decorated.template
site_page_decorated.template = "raw_page"
assert_equal "gobierto_cms/pages/templates/raw_page", site_page_decorated.template
end

thx

@ferblape
Copy link
Member

ferblape commented Jul 2, 2021

Hmmmm, not exactly, that decorator is used to customize GobiertoCms::Pages, which are used in participation module but also in other modules. So leave the decorator and update the test to remove the relative to themes.

@stbnrivas
Copy link
Contributor Author

what about this test? should I delete it or where should I redirect path instead of admin_participation_process_pages_path(process.id)

module GobiertoAdmin
module GobiertoCommon
class UpdateCmsPagesCollectionTest < ActionDispatch::IntegrationTest
def setup
super
@path = admin_participation_process_pages_path(process.id)
end
def admin
@admin ||= gobierto_admin_admins(:nick)
end
def site
@site ||= sites(:madrid)
end
def process
@sport_city_process ||= gobierto_participation_processes(:sport_city_process)
end
def test_update_news_collection
with_javascript do
with_signed_in_admin(admin) do
with_current_site(site) do
visit @path
click_on "Configuration"
within "form.edit_collection" do
fill_in "collection_title_translations_en", with: "News updated"
fill_in "collection_slug", with: "news-updated"
click_button "Update"
end
assert has_message?("Collection was successfully updated.")
end
end
end
end
end
end
end

thx

@ferblape
Copy link
Member

ferblape commented Jul 2, 2021 via email

@stbnrivas
Copy link
Contributor Author

stbnrivas commented Jul 5, 2021

hi, just to confirm, the test into this folder https://github.com/PopulateTools/gobierto/tree/master/test/integration/gobierto_admin/gobierto_attachments are dependent of some fixtures of GobiertoParticipations.

Should I refactor or delete?

thx

@stbnrivas stbnrivas force-pushed the 3826-remove-module-participation branch from 9bb7fc7 to 8c0344b Compare July 5, 2021 15:17
@ferblape
Copy link
Member

ferblape commented Jul 6, 2021 via email

@stbnrivas
Copy link
Contributor Author

class AddTypeToProcesses < ActiveRecord::Migration[5.1]
def change
add_column :gpart_processes, :process_type, :integer, default: GobiertoParticipation::Process.process_types[:group_process], null: false
end
end

After the module deletion the class GobiertoParticipation::Process is undefined and migration will fail. How I should fix this?

  • keep migration implicated but surrounded by if defined?
  • removing the content of migration method affected?

Just to say, there are 4 cases of migrations like this

Thx

@ferblape
Copy link
Member

ferblape commented Jul 6, 2021

Good point, using if defined? sounds good to me

@stbnrivas
Copy link
Contributor Author

Should join fixtures and fixtures_archive? at least which that are still in use ... or I'm missing something?

<%= ERB.new(IO.read(Rails.root.join "test/fixtures_archive/gobierto_cms/pages/madrid/other.yml")).result %>
<%= ERB.new(IO.read(Rails.root.join "test/fixtures_archive/gobierto_cms/pages/santander/other.yml")).result %>
<%= ERB.new(IO.read(Rails.root.join "test/fixtures_archive/gobierto_cms/pages/santander/first_level.yml")).result %>
<%= ERB.new(IO.read(Rails.root.join "test/fixtures_archive/gobierto_cms/pages/santander/second_level.yml")).result %>

<%= ERB.new(IO.read(Rails.root.join "test/fixtures_archive/gobierto_cms/section_items/madrid/other.yml")).result %>

thx!

@stbnrivas
Copy link
Contributor Author

stbnrivas commented Jul 7, 2021

So attachment and participation have a set of test cases which I need remove or rewrite as new feature. Some details:

assert has_no_link?(collection_with_archived_container.title.to_s)

before deletion module attachment show the collection and attachments that belongs to GobiertoParticipation::Process. These process can be archived with paranoid and then these collections were not show.

I think that this behavior don't apply to attachment collections which don't belongs to Process:

  • I searched examples into staging admin/attachments/file_attachments
  • then archive all attachment into a collection
  • the collection it keep showing (I think that it's right)

therefore this test should be removed, or I am missing something?
thx

@ferblape
Copy link
Member

ferblape commented Jul 7, 2021 via email

@stbnrivas
Copy link
Contributor Author

that was my first step. OkI will separate into different commit to speak about later

thx

@stbnrivas stbnrivas force-pushed the 3826-remove-module-participation branch 6 times, most recently from 7426721 to 53f5b08 Compare July 13, 2021 13:19
@stbnrivas
Copy link
Contributor Author

stbnrivas commented Jul 23, 2021

I'm having problems passing test of gobierto_engine_gencat so I found this js errors, into my local env and also into staging

Screenshot from 2021-07-23 08-59-48

@stbnrivas stbnrivas changed the title 3826 remove module participations WIP 3826 remove module participations Jul 27, 2021
@stbnrivas stbnrivas force-pushed the 3826-remove-module-participation branch from fb6ff9f to aa050ed Compare July 28, 2021 11:11
@ferblape ferblape linked an issue Sep 8, 2021 that may be closed by this pull request
2 tasks
@ferblape
Copy link
Member

@entantoencuanto please continue the work of Esteban in this PR, he's commenting about some errors in gencat engine tests, but it's weird because participation and gencat are not related and don't share code.

@entantoencuanto entantoencuanto force-pushed the 3826-remove-module-participation branch 3 times, most recently from 87d04a4 to 0d6b623 Compare September 14, 2021 20:05
@entantoencuanto entantoencuanto marked this pull request as ready for review October 6, 2021 10:17
@entantoencuanto entantoencuanto changed the title WIP 3826 remove module participations 3826 remove module participations Oct 6, 2021
@ferblape ferblape changed the title 3826 remove module participations Remove Participation module Oct 14, 2021
@ferblape ferblape merged commit 513f7fd into master Oct 16, 2021
@ferblape ferblape deleted the 3826-remove-module-participation branch October 16, 2021 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove modules code citizien chars, participation, budgets consultations
3 participants