Skip to content

Add scope to Budgets, Debates, Meetings, Proposals and Surveys components#6309

Merged
tramuntanal merged 18 commits intodevelopfrom
feature/scopable_components
Sep 15, 2020
Merged

Add scope to Budgets, Debates, Meetings, Proposals and Surveys components#6309
tramuntanal merged 18 commits intodevelopfrom
feature/scopable_components

Conversation

@agustibr
Copy link
Copy Markdown
Contributor

@agustibr agustibr commented Jul 16, 2020

🎩 What? Why?

An administrator can configure some components (Budgets/Debates/Meetings/Proposals/Surveys) to work with scopes.

This PR extracts PR #5941 from the closed PR #5993, to include scopable components into PR #6223.

📌 Related Issues

📋 Subtasks

  • Add CHANGELOG upgrade notes, if required

  • If there's a new public field, add it to GraphQL API

  • Add documentation regarding the feature

  • Add/modify seeds

  • Add tests

  • admin: add component general setting scope

    • budgets
    • debates
    • meetings
    • proposals
    • surveys
  • all components use scope related method fallback to its participatory_space

  • rename/refactor Scopable Concern:

    • Scopable: has all common logic
    • ScopableParticipatorySpace (was Scopable), has the logic related to spaces.
    • ScopableComponent, has the logic related to components
    • ScopableResource (was ScopableComponent), has the logic for resources

📷 Screenshots (optional)

Screenshot 2020-04-08 at 17 31 04

Screenshot 2020-04-08 at 17 31 36

@agustibr agustibr force-pushed the feature/scopable_components branch 2 times, most recently from 9b43505 to 100e6a7 Compare July 16, 2020 19:10
@agustibr agustibr changed the base branch from develop to feature/budget_component_w_many_budgets July 16, 2020 19:10
@agustibr agustibr self-assigned this Jul 16, 2020
@agustibr agustibr force-pushed the feature/scopable_components branch 3 times, most recently from f21cbde to 3165737 Compare July 20, 2020 10:08
@agustibr agustibr force-pushed the feature/scopable_components branch 3 times, most recently from 6ede71e to e32dacd Compare July 22, 2020 09:10
@agustibr agustibr mentioned this pull request Jul 22, 2020
2 tasks
@agustibr agustibr force-pushed the feature/scopable_components branch 2 times, most recently from 85e6088 to 4b0c7c8 Compare July 24, 2020 13:35
@agustibr agustibr force-pushed the feature/budget_component_w_many_budgets branch from ad18024 to 03856df Compare July 27, 2020 06:15
@agustibr agustibr force-pushed the feature/scopable_components branch 2 times, most recently from 5e7ffd4 to 10ef889 Compare July 27, 2020 11:19
@agustibr agustibr marked this pull request as ready for review July 28, 2020 06:44
@agustibr agustibr force-pushed the feature/budget_component_w_many_budgets branch from 7aba9c2 to e4d7242 Compare July 28, 2020 07:21
@agustibr agustibr force-pushed the feature/scopable_components branch from 5cb3a8c to 78555f1 Compare July 28, 2020 07:24
@agustibr agustibr force-pushed the feature/budget_component_w_many_budgets branch from e4d7242 to 65e3dbb Compare July 29, 2020 13:56
@agustibr
Copy link
Copy Markdown
Contributor Author

agustibr commented Sep 7, 2020

@tramuntanal I've rebased and solved conflicts 😁

Copy link
Copy Markdown
Contributor

@tramuntanal tramuntanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job and refactor @agustibr !

I've just commented some details before merging 😄

Comment on lines +73 to +85
# validation method for participatory spaces
def scope_belongs_to_organization
return if !scope || !organization

errors.add(:scope, :invalid) unless organization.scopes.where(id: scope.id).exists?
end

# validation method for components
def scope_belongs_to_participatory_space
return if !scopes_enabled? || !participatory_space

errors.add(:scope, :invalid) if participatory_space.out_of_scope?(scope)
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we have this methods in the corresponding ScopableComponent and ScopableParticipatorySpace concerns?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate :scope_belongs_to_organization ensures that the scopable (space, component or any other resource) is scoped within the organization's scope, I think this is a good place for this method.

and the :scope_belongs_to_participatory_space method ensures that any resource scope (such as a component) is scoped within the spaces' scope, so yes I'll move this method to the ScopableComponent module where validate :scope_belongs_to_participatory_space is called.

@tramuntanal
Copy link
Copy Markdown
Contributor

by the way there's an assemblies test failing

@agustibr agustibr force-pushed the feature/scopable_components branch from f1d0cde to 190f604 Compare September 14, 2020 13:22
@agustibr
Copy link
Copy Markdown
Contributor Author

agustibr commented Sep 14, 2020

Thanks @tramuntanal ! I did some changes as suggested.

Tests should pass ok, the previous failed test from assemblies seems that is not related to this PR, and re-runing the CI solved it 😁

@agustibr
Copy link
Copy Markdown
Contributor Author

Hi @tramuntanal, all checks passed ✅ 😁

Copy link
Copy Markdown
Contributor

@tramuntanal tramuntanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Copy link
Copy Markdown
Contributor

@tramuntanal tramuntanal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@tramuntanal tramuntanal merged commit dbcbc5e into develop Sep 15, 2020
@tramuntanal tramuntanal deleted the feature/scopable_components branch September 15, 2020 06:11
mrcasals pushed a commit to codegram/decidim that referenced this pull request Sep 16, 2020
…ents (decidim#6309)

* add scope to components

* add scopes to budgets

* fix survey types spec

* feature(budgets): add scope to budget resource

* add component spec to check_boxes_tree_helper_spec.rb

* add spec: scope_belongs_to_component_validator

* added scopable resource examples

* feat(budgets): add scope info to admin index

* fix(projects): index scope filter by budget scope

* feat(admin): scope helper methods for index views

* fix(i18n): add missing keys

* fix check_box_tree helper when nil scope

* remove unused i18n keys

* add resource_filter_scope_values method

* fix wrong merge errors with feature/budget_component_w_many_budgets

* chore(scopable): move `scope_belongs_to_participatory_space` method to ScopableComponent

* chore(scopes_picker): add docs for :namespace option

* chore(proposals): remove trait :with_geocoding_and_collaborative_drafts_enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure permissions at district (scope) level for the different components

4 participants