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

Allow select winner legislation proposals #1640

Merged
merged 23 commits into from
Sep 29, 2018

Conversation

javierm
Copy link

@javierm javierm commented Sep 17, 2018

Note: continuing #1608 since Raúl isn't available anymore. Everything here is copied from there and was written by @raul-fuentes.

References

consuldemocracy#2739

Objectives

  • Add a new attribute to Legislation::Proposal -> selected
  • Change the admin interface 0.0.0.0:3000/admin/legislation/processes/X/proposals
    with the proposals list and a select button for each proposal
  • Change the public interface 0.0.0.0:3000/legislation/processes/X/proposals
    if any shown proposal is selected now appears filters for only show the selected proposals (or all)

Visual Changes

  • admin interface changes
    peek 09-08-2018 14-41

  • public interface changes
    peek 09-08-2018 14-40

Notes

None

raul-fuentes and others added 5 commits September 24, 2018 18:27
Add admin interface for mark any proposal as selected
Add filter to public interface for selected proposals
The `update` action is usually expected to behave the same way it does
everywhere else, which is updating a record using the `params` hash.

The name `toggle_select` comes from the name we use in a similar
situation for budget investments.
@javierm javierm force-pushed the improve_index_legislation_proposals branch from 2ece1e9 to 538545b Compare September 24, 2018 16:27
Now the interface is more similar to the one in budget investments.
Just as we do with confidence score, and as admins expect when they
order by received supports: the ones with more supports appear first.
By default records are already ordered by ID, so we weren't checking the
ordering by ID functionality was working properly.

Making the records be ordered by title first makes the test a bit more
reliable.
@javierm javierm force-pushed the improve_index_legislation_proposals branch from 942bd9d to dc6aff3 Compare September 24, 2018 17:26
@javierm javierm force-pushed the improve_index_legislation_proposals branch from dc6aff3 to 224e9ce Compare September 24, 2018 17:30
scenario 'Selected filter works correctly' do
legislation_process = create(:legislation_process)
proposal1 = create(:legislation_proposal, legislation_process_id: legislation_process.id)
proposal2 = create(:legislation_proposal, legislation_process_id: legislation_process.id, selected: true)

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [109/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

end
end

end

Choose a reason for hiding this comment

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

Layout/TrailingBlankLines: Final newline missing. (https://github.com/bbatsov/ruby-style-guide#newline-eof)

legislation_process = create(:legislation_process)
proposal1 = create(:legislation_proposal, title: 'bbbb', cached_votes_up: 10, legislation_process_id: legislation_process.id)
proposal2 = create(:legislation_proposal, title: 'aaaa', cached_votes_up: 20, legislation_process_id: legislation_process.id)
proposal3 = create(:legislation_proposal, title: 'cccc', cached_votes_up: 30, legislation_process_id: legislation_process.id)

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [131/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

scenario 'Sorting legislation proposals by Id', js: true do
legislation_process = create(:legislation_process)
proposal1 = create(:legislation_proposal, title: 'bbbb', cached_votes_up: 10, legislation_process_id: legislation_process.id)
proposal2 = create(:legislation_proposal, title: 'aaaa', cached_votes_up: 20, legislation_process_id: legislation_process.id)

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [131/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)


scenario 'Sorting legislation proposals by Id', js: true do
legislation_process = create(:legislation_process)
proposal1 = create(:legislation_proposal, title: 'bbbb', cached_votes_up: 10, legislation_process_id: legislation_process.id)

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [131/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

scenario 'Sorting legislation proposals by title', js: true do
legislation_process = create(:legislation_process)
create(:legislation_proposal, title: 'bbbb', cached_votes_up: 10, legislation_process_id: legislation_process.id)
create(:legislation_proposal, title: 'aaaa', cached_votes_up: 20, legislation_process_id: legislation_process.id)

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [119/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)


scenario 'Sorting legislation proposals by title', js: true do
legislation_process = create(:legislation_process)
create(:legislation_proposal, title: 'bbbb', cached_votes_up: 10, legislation_process_id: legislation_process.id)

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [119/100] (https://github.com/bbatsov/ruby-style-guide#80-character-limits)

@@ -1,5 +1,7 @@
class Legislation::ProcessesController < Legislation::BaseController
has_filters %w{open next past}, only: :index
has_filters %w{all selected}, only: :proposals

Choose a reason for hiding this comment

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

Style/PercentLiteralDelimiters: %w-literals should be delimited by [ and ]. (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces)

end
end
end

Choose a reason for hiding this comment

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

Layout/TrailingBlankLines: Final newline missing. (https://github.com/bbatsov/ruby-style-guide#newline-eof)

@@ -1,7 +1,16 @@
class Admin::Legislation::ProposalsController < Admin::Legislation::BaseController

has_orders %w{id title supports}, only: :index

Choose a reason for hiding this comment

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

Style/PercentLiteralDelimiters: %w-literals should be delimited by [ and ]. (https://github.com/bbatsov/ruby-style-guide#percent-literal-braces)

@javierm javierm force-pushed the improve_index_legislation_proposals branch from 1259d15 to 9a7a377 Compare September 24, 2018 17:54
@javierm javierm changed the title [WIP] Allow select winner legislation proposals Allow select winner legislation proposals Sep 24, 2018
We kill two birds with one stone and also make each line less than 100
characters long.
As agreed when discussing our rubocop rules.
@javierm javierm force-pushed the improve_index_legislation_proposals branch from 406d306 to f664946 Compare September 24, 2018 20:28
As done in the rest of the application: we show the filters even if
there isn't any data to display.
The same way we order budget results.
That way users might be less surprised when they see proposals are
different each time they access the page.
@javierm javierm force-pushed the improve_index_legislation_proposals branch from b28d273 to 15f4fbd Compare September 26, 2018 12:02
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.

None yet

5 participants