Commit Graph

37 Commits

Author SHA1 Message Date
Alberto
048ca61207 Improve styles for budgets voting phase 2021-03-24 15:50:25 +01:00
Ziyan Junaideen
1e3e8c1304 Add approval voting to budgets
Co-Authored-By: Javi Martín <javim@elretirao.net>
2020-08-06 12:38:18 +02:00
Javi Martín
8edcbcfd3b Fix aria-valuenow attibute in ballot progress bar
We were setting it to 0, and so screen reader users might be confused by
it.

The easiest way to reuse the code and using it for both this attribute
and the width of the progress bar is to move this method to the voting
style, just like the other methods used in this view.

Note the progressbar ARIA role might not be right, since this isn't a
task which is "progressing", but an indicator of the amount spent and
amount available, which is exactly what the <meter> HTML5 tag was
designed for.

We might use a <meter> tag in the future. For now, I'm leaving it as it
is because I'm not certain about how well <meter> is supported in
accessibility tools, and because it's definitely not supported in
Internet Explorer 11, which we haven't officially dropped support for.
2020-07-30 16:20:00 +02:00
Javi Martín
160964fcdc Make method to check a line can be added generic
In the Knapsack voting style, we can't add an investment if its cost is
greater than the money we've got left, but in other voting styles money
might not be the issue.

So we're introducing the term "resources" and adapting the code
accordingly.
2020-07-30 16:20:00 +02:00
Javi Martín
5f726df8be Extract methods showing voting style information
The idea is that different voting styles will display different
information messages.
2020-07-30 16:19:58 +02:00
Javi Martín
ad094e5063 Extract class to handle voting style logic
Since we're going to introduce a new voting style which will not be
based on money, we're extracting the logic specific to the current
voting style to a new class.

This way adding new voting styles will be easier.
2020-07-28 13:06:31 +02:00
Javi Martín
a9900e3f27 Remove duplication calculating insufficient funds
We were using the same logic twice.

I've moved the logic to the Ballot model, which to me is a more natural
place to calculate whether there's enough money left than the Investment
model. After all, the remaining money is in the ballot, and not in the
investment.
2020-07-28 13:06:31 +02:00
Javi Martín
d0d681a44b Add and apply EmptyLineAfterGuardClause rule
We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.

In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
2019-10-24 17:56:03 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
93c6347b45 Apply Rails/FindBy rubocop rule
We were already using it in most places.
2019-10-23 18:29:09 +02:00
Juanjo Bazán
7ab602175a makes models inherit from ApplicationRecord 2019-04-17 17:40:56 +02:00
alejandro
596ff77ec1 replaces uniq with distinct
Uniq is deprecated
2019-04-16 17:28:07 +02:00
rgarcia
aeb84108bc Verify poll ballots 2019-04-10 18:29:01 +02:00
rgarcia
aa7441271d Prevent balloting online after casting a ballot offline 2019-04-03 22:19:51 +02:00
Bertocq
2888c20489 Fix all Style/RedundantSelf rubocop issues 2017-07-05 11:55:52 +02:00
Juanjo Bazán
3eb22ab7b9 removes exception on invalid vote
responds rendering correct error message instead
2017-05-16 13:12:32 +02:00
rgarcia
8083f259c2 takes into account headings without balloted investments 2017-05-03 17:49:29 +02:00
rgarcia
2f6c1bc7bc displays the correct amount spent in review my ballot
returns the first heading with investments for a group
2017-05-03 17:06:27 +02:00
kikito
b289e21992 Refactors valid_heading 2017-01-04 13:56:54 +01:00
kikito
a589d8a76d Simplifies ballot.add_investment using automatic denormalization 2016-12-23 15:37:32 +01:00
kikito
4434a601d3 Implements several helper methods for formatting amounts 2016-12-14 11:49:16 +01:00
rgarcia
24740578ff displays money remaining in each group 2016-09-10 16:22:42 +02:00
rgarcia
22373c3ddd Review my votes page 2016-09-10 16:22:41 +02:00
rgarcia
9d4f2d1aff Displays budget groups 2016-09-10 16:22:41 +02:00
rgarcia
3c55d66591 fixes conflicts with budget 2016-07-27 11:41:46 +02:00
Juanjo Bazán
1b57e14a86 removes heading reference in ballot
heading info is stored per group in ballot_lines
2016-06-14 14:04:27 +02:00
Juanjo Bazán
4fcf138045 refactors investment adding to ballots 2016-06-14 14:03:21 +02:00
Juanjo Bazán
b5a6828e41 adds Budget::Group model to group headings
many refactors through budget related models
2016-06-09 18:00:06 +02:00
kikito
1aa70bec94 Adds method Ballot#has_investment? 2016-06-07 11:10:42 +02:00
kikito
c6c3e22a40 Adds methods for investments in models 2016-06-03 18:44:34 +02:00
kikito
bb7f82a72f Fixes hidden bug when calculating amount_available 2016-05-27 15:12:54 +02:00
kikito
3e39272b3b Fixes implementation of amount_available moving it to the ballot 2016-05-24 17:39:49 +02:00
Juanjo Bazán
57642075a7 adds ballot model spec 2016-05-24 13:04:12 +02:00
Juanjo Bazán
1cae255555 changes sps to investments in ballot relation 2016-05-24 13:04:12 +02:00
Juanjo Bazán
c48059594b removes belongs_to :heading relation from ballot 2016-05-24 13:04:12 +02:00
kikito
ccffcf60b3 Replaces geozones by headings in the models 2016-05-20 14:06:50 +02:00
kikito
9d195609f9 Adds models 2016-05-20 12:41:48 +02:00