Commit Graph

140 Commits

Author SHA1 Message Date
Javi Martín
9fe8c47528 Apply Rails/SafeNavigation rubocop rule 2019-09-10 21:43:39 +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
Javi Martín
b5b07bccd3 Apply PercentLiteralDelimiters rubocop rule 2019-09-10 20:02:15 +02:00
Javi Martín
71d9ddd849 Apply rule to end files with a newline character 2019-09-10 20:02:15 +02:00
taitus
b3ae9038c3 Add remote translations to budget investments 2019-06-27 09:21:19 +02:00
Senén Rodero Rodríguez
661ca5a568 Add budget investments translation interface
* Adapt translatable spec helper method to work with budget investments
* Remove old attributes from strong parameters
* Add missing locales to admin.yml and budgets.yml
* Change SpendingProposal.title_max_length and
  SpendingProposal.description_max_lenght to Budget::Investment methods
* Add budget investment translatable attribute translations
2019-06-27 09:20:24 +02:00
German Galia
9d1ca3bfd4 Report generation. Download csv 2019-06-12 10:17:31 +02:00
lalo
be8a0dbe8a Add Milestone tag select filter on executions public page 2019-06-07 14:17:32 +02:00
Julian Herrero
b122302c58 Use find instead of find_by_id
Better raise a 404 HTML NotFound exception than any other unexpected error.
2019-06-03 17:54:19 +02:00
Julian Herrero
4bd20eebf4 Use correct param in controller
There were some custom routes created using the param[:id] but the
Rails routes use the param[:budget_id] by default, so the same
controller could be asked for different param keys.
2019-06-03 16:54:39 +02:00
rgarcia
998b4d9e39 Load budgets using slugs 2019-06-03 16:54:39 +02:00
Bertocq
0d761ddfb1 Hotfixing find the only budget for emails 2019-06-03 16:54:39 +02:00
Javi Martín
76c7827cf4 Use stats objects instead of hashes
It will make it far easier to call other methods on the stats object,
and we're already caching the methods.

We had to remove the view fragment caching because the stats object
isn't as easy to cache. The good thing about it is the view will
automatically be updated when we change logic regarding which stats to
show, and the methods taking long to execute are cached in the model.
2019-05-21 13:50:18 +02:00
voodoorai2000
abb6eb18b0 Order headings by name and group
Note that we are relying on the existing `sort_by_name`[1] method in the `Budget::Heading` class.

This method sorts by DESC group name first and then ASC heading name.

[1] https://github.com/AyuntamientoMadrid/consul/pull/1875
2019-05-16 22:01:42 +02:00
rgarcia
51ab4a430e Load budget in stats controller 2019-05-16 22:01:42 +02:00
Bertocq
e0e02b47c0 Add Budgets Stats Controller, route and ability on reviewing ballots and finished budget 2019-05-16 22:01:42 +02:00
Senén Rodero Rodríguez
596ef8d1ed Fix queries and scopes after column deletion
Some queries were accessing original column instead of the new
translatable one. This should have been causing unexpected behavior
for requests maded in a different locale than the application default.
2019-04-17 17:40:55 +02:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
Javi Martín
6682121069 Reuse code to set and order by a random seed 2019-02-20 12:10:12 +01:00
Javi Martín
facfb807e1 Show all investments in the map
We were showing only the ones being shown in the current page because
we were modifying `@investments` using a method which used
`@investments`, and we were calling that method twice.

There are many possible solutions: using a local variable to store the
result of the `investments` method, modifying `@investments` after
modifying `@investments_map_coordinates`, ... I've used the one which in
my humble opinion is a bit less fragile: not using `@investments` inside
the `investments` method. That way, the `investments` method will always
return the same result.

Note `stub_const("Budgets::InvestmentsController::PER_PAGE", 2)`
wouldn't work because `Budgets::InvestmentsController` isn't loaded when
that line is executed. So we need to load it. Instead of requiring the
file, using `#{Budgets::InvestmentsController}` seems to be an easier
solution.
2019-02-19 13:22:49 +01:00
Javi Martín
8ecf7f4505 Extract constant to define investments per page
That way it's easier to stub in tests. It makes it easier to customize
CONSUL to show a different number of investments per page as well.
2019-02-19 13:21:37 +01:00
Javier Martín
a0fb19f0b4 Merge branch 'master' into feature/3153 2019-02-15 16:25:50 +01:00
Julian Herrero
c9522b424b Show unfeasible and unselected investments for finished budgets
We were filtering by winners investments for finished budget without
having in consideration other filters.
We want the default filter to be `winners` for finished budgets.
2019-02-06 13:50:50 +01:00
Julian Herrero
3bf2fa1b17 Add method find_by_slug_or_id to Sluggable module
Make it easier to find by slug or id for sluggable models. Will return
nil if resource is not found.
2019-01-25 09:08:28 +01:00
Julian Herrero
0af5972d63 Use correct param in controller 2019-01-25 08:48:44 +01:00
rogelio-o
f1bb1ff8de Moves attributes to a concern. 2019-01-14 20:26:47 +01:00
rogelio-o
ea76179002 Solves #3153. It refactors images attributes. 2019-01-12 17:42:55 +01:00
Julian Herrero
0858f4c6f4 cleanup (remove unused code) 2019-01-09 17:49:46 +01:00
Julian Herrero
2081269a67 fix Hound violations 2019-01-02 10:46:31 +01:00
Javier Martín
4782ca37d6 Merge pull request #3111 from consul/backport-customize_toda_la_ciudad
Remove custom "toda la ciudad" code
2018-12-18 13:03:51 +01:00
Javi Martín
e6a609e6e5 Extract method to filter investments by status 2018-12-14 18:15:51 +01:00
Javi Martín
b4b0b18a2d Extract method to get investment milestone status 2018-12-14 18:15:51 +01:00
Javi Martín
91d91f2ebf Remove city heading specific code
This code accidentally made it to consul, and it's specific to Madrid.
2018-12-14 18:15:51 +01:00
Javi Martín
0de8c884ac Extract method to sort investments by heading 2018-12-14 17:26:54 +01:00
Julian Herrero
6439be44f1 change CRUD for budget groups and headings
To make it more consistent with the rest of the Admin panel,
the CRUD for budget groups and headings has been changed
from the old "all-in-one" form to a separate form for each resource.
2018-12-14 16:34:54 +01:00
Julian Herrero
25e1afea48 fix map rendering for budget headings 2018-12-14 15:37:22 +01:00
Julian Nicolas Herrero
6aa54d6c62 Merge branch 'master' into content_blocks_for_headings 2018-12-11 16:40:25 +01:00
Julian Nicolas Herrero
9aab3ddd7b Merge pull request #3038 from MatheusMiranda/add_map_to_heading_page
Add map to sidebar on Heading's page
2018-12-11 16:32:35 +01:00
Marko Lovic
81f516efd7 Change BudgetInvestmentStatus to Milestone::Status
Generalize the BudgetInvestmentStatus model to Milestone::Status so it
is not specific to budget investments, but can be used for any entity
which has milestones. This is in preparation to make the Milestone
model polymorphic and usable by entities other than budget investments.
2018-11-30 14:15:21 +01:00
Milber Champutiz Burbano
9f455b9165 Added feature to add content block to headings in sidebar -- rebase 2018-11-27 09:37:35 -05:00
Matheus Miranda
06f07b1139 Add map to sidebar on Heading's page
Signed-off-by: Matheus Miranda <matheusmirandalacerda@gmail.com>
2018-11-16 09:05:23 +01:00
voodoorai2000
5856af03a5 Fix exception when no available milestones
We were getting an exception when quering[1] for milestones which were not present, due to for example having a publication date later than today

Adding a `try` statement and spec to avoid this situation

[1] 82efc3dd66/app/controllers/budgets/executions_controller.rb (L16)
2018-11-07 18:08:10 +01:00
María Checa
126941a335 Change headings reorder method 2018-11-06 13:02:35 +01:00
María Checa
d089cc14a5 Add logic to handle budget investments with an execution process 2018-11-06 13:02:35 +01:00
Marko Lovic
997db67104 Refactor how headings are ordered 2018-11-06 13:02:35 +01:00
Marko Lovic
375fbf775f Order non-city headings by alphabetical order 2018-11-06 13:02:35 +01:00
Marko Lovic
4758c1b91a Show city heading in first position on executions list 2018-11-06 13:02:35 +01:00
rgarcia
685927116c Query for all investments, not only winner investment
Spending proposals did not have a winner attribute, instead winners
where calculated dynamically looking at votes

Removing this condition, so that we can see investment for the 2016
participatory budget which used spending proposals
2018-11-06 13:02:35 +01:00
Marko Lovic
8376efce3f Hide headings with no investments
The page should not show any headings which don't have any
winning investments. The "no content" message should only be
shown when there are no headings with investments to avoid an
otherwise blank page.

__Note:__ in the main @headings query, _both_ #includes and #joins
are needed to:
 1. eager load all necessary data (#includes)
and
 2. to perform an INNER JOIN on milestones to filter out investments
with no milestones (#joins).
2018-11-06 13:02:35 +01:00
Angel Perez
5de74ea6f1 Load budget headings on budgets/executions#show action 2018-11-06 13:02:34 +01:00