-
Notifications
You must be signed in to change notification settings - Fork 15
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
Show district proposals at community page #2134
base: master
Are you sure you want to change the base?
Conversation
90258eb
to
8261b83
Compare
@@ -37,11 +43,20 @@ def load_participants | |||
@participants = @community.participants | |||
end | |||
|
|||
def load_geozone_proposals | |||
geozone = @community.proposal.geozone | |||
@proposals = geozone.proposals.without_comunity.page(params[:proposals_page]).order(:created_at) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why without_comunity
?
@proposals = geozone.proposals.without_comunity.page(params[:proposals_page]).order(:created_at) | |
@proposals = geozone.proposals.without_comunity.order(:created_at).page(params[:proposals_page]) |
Although AFAIK it doesn't affect the application, we usually write page
after order
in order to make the code easier to understand, since it follows the logic behind it: first we order the records, and then we take a certain number of them. We don't take a certain number of records first and then we order them.
<li class="tabs-title"> | ||
<%= link_to "#tab-district-proposals" do %> | ||
<h3> | ||
<%= t("community.show.tab.proposals") %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to make this tab.proposals
key and the #tab-district-proposals
URL more consistent? I mean, another tab uses tab.participants
and #tab-participants
; if we followed these conventions, maybe in the future we could refactor the code and remove the duplication.
Of course, now it's a bit difficult because the third "tab" points to #tab-polls
but the key is subnav.surveys
😌.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
spec/features/communities_spec.rb
Outdated
|
||
visit community_path(proposal.community) | ||
|
||
expect(page).not_to have_link "District proposals (1)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(page).not_to have_link "District proposals (1)" | |
expect(page).not_to have_link text: "District proposals" |
This way this expectation will fail even if (for whatever reasons) the code has a bug and renders "District proposals ()" for real proposals.
spec/features/communities_spec.rb
Outdated
proposals = create_list(:proposal, Kaminari.config.default_per_page + 1, geozone: geozone) | ||
visit community_path(fake_proposal.community) | ||
click_link "District proposals (26)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proposals = create_list(:proposal, Kaminari.config.default_per_page + 1, geozone: geozone) | |
visit community_path(fake_proposal.community) | |
click_link "District proposals (26)" | |
allow(Proposal).to receive(:default_per_page).and_return(2) | |
proposals = create_list(:proposal, 3, geozone: geozone) | |
visit community_path(fake_proposal.community) | |
click_link "District proposals (3)" |
This way the test is much faster since it creates 3 records instead of 26.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 👌🏼
70e2107
to
45a5f08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 😄.
IMO, it has more sense to call it `community-tabs` than `communities-participants`.
Now we can use the `app/views/custom/proposals/_proposal.html.erb` partial anywhere. Otherwise, Rails would search for the partial at the caller parent folder throwing a `Not found template error`.
The proposal geozone is mandatory when comunity_hide is true.
45a5f08
to
0f9e409
Compare
I recently updated the code with the latest |
References
This is part of the Ciudades Abiertas project.
Objectives
community_hide
set totrue
. The tab title might contain the number of proposals. As example:"District proposals (15)"
.per page
proposals, show the pagination links. Currently, theper page
value is the default, 25.Visual Changes
Does this PR need a Backport to CONSUL?
No
Notes
None