Add scope to Budgets, Debates, Meetings, Proposals and Surveys components#6309
Add scope to Budgets, Debates, Meetings, Proposals and Surveys components#6309tramuntanal merged 18 commits intodevelopfrom
Conversation
9b43505 to
100e6a7
Compare
f21cbde to
3165737
Compare
6ede71e to
e32dacd
Compare
85e6088 to
4b0c7c8
Compare
ad18024 to
03856df
Compare
5e7ffd4 to
10ef889
Compare
7aba9c2 to
e4d7242
Compare
5cb3a8c to
78555f1
Compare
e4d7242 to
65e3dbb
Compare
|
@tramuntanal I've rebased and solved conflicts 😁 |
tramuntanal
left a comment
There was a problem hiding this comment.
Good job and refactor @agustibr !
I've just commented some details before merging 😄
decidim-core/lib/decidim/scopable.rb
Outdated
| # 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 |
There was a problem hiding this comment.
shouldn't we have this methods in the corresponding ScopableComponent and ScopableParticipatorySpace concerns?
There was a problem hiding this comment.
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.
|
by the way there's an assemblies test failing |
- rename/refactor Scopable Concerns - debates - meetings - proposals - surveys
…o ScopableComponent
f1d0cde to
190f604
Compare
|
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 😁 |
|
Hi @tramuntanal, all checks passed ✅ 😁 |
…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
🎩 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
CHANGELOGupgrade notes, if requiredIf 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
all components use
scoperelated method fallback to its participatory_spacerename/refactor Scopable Concern:
Scopable: has all common logicScopableParticipatorySpace(wasScopable), has the logic related to spaces.ScopableComponent, has the logic related to componentsScopableResource(wasScopableComponent), has the logic for resources📷 Screenshots (optional)