Commit Graph

67 Commits

Author SHA1 Message Date
Javi Martín
8b13daad95 Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
2023-08-18 14:56:16 +02:00
Javi Martín
756a16f67a Remove investment filters in groups
The interface was a bit confusing, since after clicking on "See
unfeasible investments" (or similar), we were on a page where no
investments were shown.

Besides, since commit 7e3dd47d5, the group page is only linked from the
"my ballot" page, through a link inviting the user to vote in that
group, and it's only possible to vote selected investments (which is the
default filter during the final voting phase).

The only reason we had these links here was these links weren't present
in the investments page. But they're present there since commit
04605d5d5, so we don't need them in the group page anymore.
2021-10-29 15:01:40 +02:00
Javi Martín
4a42804a7d Extract calculate winners button to a component
This way we remove some duplication.
2021-10-19 02:33:53 +02:00
Javi Martín
720d3530d7 Add and apply Style/HashTransformKeys rubocop rule
The `transform_keys` method is available since Ruby 2.5.
2021-09-03 11:49:53 +02:00
Javi Martín
d5f4313f59 Simplify getting URL to support an investment
We're also changing the method name to `vote_path` in order to be
consistent with the way Rails uses `_path` for relative URLs.
2021-06-14 14:38:34 +02:00
Javi Martín
57628a78d9 Move investment votes partial to a component
This way changing it will be easier.
2021-06-14 12:51:41 +02:00
Javi Martín
82e8de094b Extract budget form to a component
This way it will be easier to change it and reuse it.
2021-06-08 14:25:43 +02:00
Julian Herrero
7e3dd47d5a Unify budget landing pages
There was a big difference between the current budget and a specific
budget landing page. This didn't really make too much sense. Also, it
was not possible to know how a draft participatory budget will look
before it was published.

By unifying those two views now they will look quite similar and it
will be possible for administrators to preview any draft budget and to
know how the budget will look like before actually publishing it.
2021-03-18 15:03:21 +01:00
Julian Herrero
16c582f282 Extract component for budget groups and headings 2021-03-18 13:59:09 +01:00
decabeza
04605d5d5b Add filters on budget investments index page
Now it's easier to change the investments filter. Previously we had to
go back to the budget index page, change the filter there, and then
select one heading.

Now the links to change the current filter in the budget index page
aren't needed anymore.
2021-03-17 13:44:01 +01:00
Julian Herrero
28caabecdf Refactor participatory budgets in draft mode
Previously the draft mode was a phase of the PB, but that had some
limitations.

Now the phase drafting disappears and therefore the PB can have the
status published or not published (in draft mode).

That will give more flexibility in order to navigate through the
different phases and see how it looks for administrators before
publishing the PB and everybody can see.

By default, the PB is always created in draft mode, so it gives you
the flexibility to adjust and modify anything before publishing it.
2021-02-23 17:05:24 +01:00
Javi Martín
02e27e13dc Extract component for budget actions
We can omit passing a parameter to the helper method thanks to that, and
we group related code together.
2020-10-21 13:19:52 +02:00
Javi Martín
4a5d4b3c0b Group investment search form methods together
We had helper methods all over the place which were only used in one
view. Since we're going to change some of them to use the budget as a
parameter, they don't belong in those helpers anymore.

Note the method `budget_heading_select_options` is used in more places,
so we're keeping it where it was.
2020-09-08 18:35:16 +02: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
749428d93f Replace content_tag with new tag builder syntax
One of the main advantages of this syntax is we can now omit the content
parameter when it's empty.
2020-04-27 19:26:37 +02:00
Javi Martín
ea2aeab383 Apply rubocop Rails/FindBy rule everywhere
We didn't detect these cases because by default the rule only searches
for offenses in `app/models/`.
2019-11-08 19:15:04 +01:00
Javi Martín
62c4d41af4 Remove unused budget attributes
Tags and help links can be edited, but aren't used anywhere. Since we
don't know what the intended behavior was, I'm removing them for now.

My best guess is tags were supposed to be used so investments for a
budget can only be assigned tags present in the budget. Achieving that
behavior wouldn't be a trivial task.
2019-11-01 17:12:42 +01:00
Javi Martín
beae82aae8 Order tags to search by alphabetically
We were ordering one group of tags alphabetically and then adding
another group of tags which wasn't ordered alphabetically, which didn't
make much sense.
2019-11-01 17:12:42 +01:00
Javi Martín
fb2b821c28 Remove duplication in investment tag methods 2019-11-01 17:12:42 +01:00
Javi Martín
20001824e5 Use acts_as_taggable for budget tags
We were adding columns to the budgets table instead of using the same
logic we use everywhere else.
2019-11-01 17:12:42 +01:00
Javi Martín
d5cb519819 Fix typo in milestone tags 2019-11-01 17:12:42 +01:00
Javi Martín
b8fbd6347b Use acts_as_taggable for investment valuation tags
We were manually doing the same thing, generating inconsistent results,
since the method `valuation_tag_list` was using the `valuation` context,
when actually the expected behavior would be to use the `valuation_tag`
context.
2019-11-01 17:12:31 +01:00
Javi Martín
c1f2e8fd7a Use budget.investments instead of by_budget
Same result, with less code.
2019-11-01 16:49:14 +01:00
Javi Martín
a727dcc031 Apply Style/SymbolProc rubocop rule
This style is much more concise.
2019-10-26 20:10:32 +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
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
German Galia
74083df10f Add historic fields to participatory budget 2019-06-12 18:03:53 +02:00
Javi Martín
da59315530 Don't show links to budget results if disabled 2019-06-06 12:18:05 +02:00
Javi Martín
eb7dc3ef2d Extract partial to render budget navigation links 2019-06-06 12:17:52 +02:00
Alberto Garcia Cabeza
135984d535 removes budget countdown 2019-05-16 13:37:47 +02:00
rgarcia
b62eff841c Fix symbolize_keys deprectation warning
DEPRECATION WARNING: Method symbolize_keys is deprecated and will be
removed in Rails 5.1, as `ActionController::Parameters` no longer
inherits from hash. Using this deprecated behavior exposes potential
security problems. If you continue to use this method you may be
creating a security vulnerability in your app that can be exploited.
Instead, consider using one of these documented methods which are not
deprecated:
http://api.rubyonrails.org/v5.0.4/classes/ActionController/Parameters.ht
ml (called from csv_params at
/home/travis/build/consul/consul/app/helpers/budgets_helper.rb:15)
2019-04-17 17:40:55 +02:00
rgarcia
6fa7562181 Automatically create a budget poll if it does not exist 2019-04-03 22:23:22 +02:00
Julian Herrero
b460c024f3 Use double quotes in app/helpers 2019-03-15 09:26:49 +01:00
rgarcia
55fb14ac14 do not display alert when supporting for whole city 2019-02-07 16:55:24 +01:00
decabeza
a2161f3ace Hide voted group css class if current filter is unfeasible 2019-02-05 17:16:04 +01:00
decabeza
5409db6c55 Show only selected investments on map from publishing prices phase
If there are no selected investements show all investments on map.
2019-02-05 14:01:27 +01:00
decabeza
773302f0d7 Show only random order for unfeasible and unselected investments 2019-01-30 14:16:25 +01:00
decabeza
13b3d9cebc Fixes admin menu link when create a new widget 2018-11-12 17:11:17 +01:00
Alberto
f345786cc0 Merge pull request #2622 from consul/selected-investments-map
Adds message to selected budget investments
2018-06-06 19:21:24 +02:00
decabeza
0bf31bde6c Updates all active to is-active classes 2018-06-06 12:02:13 +02:00
iagirre
2821985552 Change 'Calculate Winners button' to budget_investments index.
Move the button so that it appears in the Winners tab of the
budget_investments index.

When the budget is in "Balloting projects", "Reviewing Ballots"
or "Finished budget" phases, the button will appear as a button
(clickable). If there are no winners calculated yet, the text
will be "Calculate winner investments"; if there are, the text
will be "Recalculate winner investments".

If the budget is in another phase, the button will be
disabled and a message will appear: 'The budget has to stay on
phase "Balloting projects", "Reviewing Ballots" or
"Finished budget" in order to calculate winners projects'
2018-05-28 15:12:28 +02:00
decabeza
f1e722ac5c Adds message to selected budget investments 2018-05-10 14:54:34 +02:00
rgarcia
39c6ac4a91 Display message in budget's index when there are no budgets
When there are no budgets we were seeing an exception in the budgets’
index

There are two parts to take into account here:
1) Making sure there is a current_budget present, otherwise we display
the “no budgets” message

2) The map helper is called from the controller, so we need to make
sure current_budget is present there too

Note: We could have added a bunch of `try` statements in the budgets’s
index, instead of using a conditional, however there are quite a few
`current_budget` calls so it seems more appropriate to use a conditional
2018-04-05 14:25:32 +02:00
María Checa
cd1a0548ba Add map_location#json_data method 2018-03-27 15:17:31 +02:00
Bertocq
2341a2f70b Add by_budget scope to Investment and use it 2018-02-10 16:36:14 +01:00
Raúl Fuentes
ecdbc4a3f7 added balloting to the list of phases allowed to see all the links 2018-02-10 15:27:40 +01:00
Raúl Fuentes
5b16d395e7 Added logic to not show invetment links is the budget phase isn't reviewing_ballots or finished 2018-02-10 15:27:40 +01:00
Vicente Mendoza
ff5112f96b Changed the budgets helper so just search for the current budget 2018-01-26 11:30:02 +01:00
Raúl Fuentes
82b750de68 moved duplicated code to helper 2018-01-23 15:42:01 +01:00