Commit Graph

76 Commits

Author SHA1 Message Date
Javi Martín
234a5108a4 Use strings for class_name
As mentioned in the Rails console:

DEPRECATION WARNING: Passing a class to the `class_name` is deprecated
and will raise an ArgumentError in Rails 5.2. It eagerloads more classes
than necessary and potentially creates circular dependencies. Please
pass the class name as a string.
2019-05-28 14:26:18 +02:00
Javi Martín
4f4dc2c2af Add show results and stats form to budgets 2019-05-22 11:50:03 +02:00
Javi Martín
7c0e499eee Add table to store stats versions
We need a way to manually expire the cache for a budget or poll without
expiring the cache of every budget or poll.

Using the `updated_at` column would be dangerous because most of the
times we update a budget or a poll, we don't need to regenerate their
stats.

We've considered adding a `stats_updated_at` column to each of these
tables. However, in that case we would also need to add a similar column
in the future to every process type whose stats we want to generate.
2019-05-21 13:50:19 +02:00
Javi Martín
8bb0fa4726 Add Budget#valuating_or_later? method
We're going to use it so we know if a budget has finished its support
phase.
2019-05-21 13:50:18 +02:00
Javi Martín
1f225c59ed Use PHASE_KINDS to calculate "or_later?" methods
This implementation is a bit more robust because we don't have to change
any of the "or_later?" methods if we add or remove a new phase.

We could also use metaprogramming to reduce code duplication in these
methods. So far, I've decided to keep the code simple since the
duplication seems reasonable.
2019-05-21 13:50:18 +02:00
Juanjo Bazán
110ee961e3 adds budget stats for final voting to admin stats 2019-05-16 14:45:46 +02:00
Juanjo Bazán
7ab602175a makes models inherit from ApplicationRecord 2019-04-17 17:40:56 +02:00
Julian Herrero
9a15f3d160 Remove Budget overrided translation class
Since Globalize gem update to v5.2.0 we cannot override translations
anymore in the same way that before the update. Milestone::Translation
class removed in this commit were no longer loaded correctly when
translation class is retrieved by translation_class method provided by
Globalize. Here is the diff between both gem versions:

https://github.com/globalize/globalize/compare/v5.0.0...v5.2.0diff-a1370b109e0dd567545b072bc6447b8fR51

This problem is not happening on test environment but is throwing an
exception in other environments as it has not loaded the delegation
definition inside our custom translation class.

To fix this we added a new class method inside globalizable model
concern to allow to define method delegation on translations classes from
parent globalizable classes when needed without having to override
Translation classes.

Another way to properly load our custom Milestone::Translation class is
to place it inside parent model class.
2019-04-16 17:28:07 +02:00
rgarcia
20a3f6539d Add association between polls and budgets 2019-04-03 22:19:44 +02:00
Julian Herrero
3ba961a2d7 Use double quotes in models 2019-03-14 17:25:43 +01:00
Julian Herrero
d76782f150 Make budgets translatable 2019-02-13 11:41:58 +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
María Checa
8c69871cfa Add logic to show only winner investments if budget is finished
Backported from AyuntamientoMadrid/consul
2018-07-24 11:33:38 +02:00
Javier Martín
37eaf29517 Fix flaky emails spec.
These tests were failing randomly because there is no guarantee
the methods `Budget#email_selected` and `Budget#email_unselected` will
always send the emails in the same order, because `investments.selected`
and `investments.unselected` don't necessarily return the records in the
order they were created.

Ordering by id is certainly not very elegant; however, ordering by
another field like `created_at` is dangerous because the record could be
created at (almost) the exact same time.

Related to issue #2446 and issue #2519.
2018-07-03 23:59:20 +02: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
Antonis Tzorvas
c21d806ecc Refs #2603 Show 'See Results' button in admin panel 2018-05-19 13:38:02 +03:00
decabeza
f1e722ac5c Adds message to selected budget investments 2018-05-10 14:54:34 +02:00
Bertocq
b72e43168b Use user locale instead of default locale to format currencies 2018-03-08 10:20:05 +01:00
Bertocq
e0871e5dc6 Only update slug if empty or model condition is met 2018-02-04 23:04:48 +01:00
iagirre
846898f3ec New phase "Information" added and UI modified to not show the links.
Specs to test the functionality added.
2018-01-23 15:42:01 +01:00
Bertocq
7599eb4c35 Refactor budget phases step progress functions and usage 2018-01-18 17:18:05 +01:00
Bertocq
2e883db283 Refactor budget phases current step & total steps 2018-01-18 16:53:36 +01:00
BertoCQ
01d7b86d42 Merge pull request #2331 from consul/current-budget-polish
Add current_budget to management controllers
2018-01-18 00:27:56 +01:00
rgarcia
21cdddcbae Order budgets by created_at instead of by id
This is a preventive change which will be useful once the rake to
migrate from `spending_proposals` to `budget_investments` is complete

As after running that migration, old `spending_proposal` budgets will
have a newer `id` than the existing budgets. And therefore the last
budget will be one of those migrated from the old `spending_proposal`
model

By ordering by `created_at` and probably updating the `created_at`
attribute in the rake that migrates `spending_proposals` to
`budget_investments`, we will have a coherent order for budgets
2018-01-16 19:44:11 +01:00
BertoCQ
d44db9cec4 Merge branch 'master' into feature/budget_phases 2018-01-16 17:47:47 +01:00
Bertocq
313d8d2e11 Adjust date ranges of prev/next phases when enabling/disabling a Budget::Phase, with model specs 2018-01-16 15:20:18 +01:00
Bertocq
59fb0b562c Create all Phases after a Budget creation 2018-01-16 12:18:13 +01:00
Bertocq
10f5cc0d3b Add phases relation at Budget model, as well as current_phase helper method 2018-01-16 12:18:13 +01:00
Bertocq
ca3d759d9f Refactor Budget publishing prices phases constant to Budget::Phase model 2018-01-16 12:18:13 +01:00
Bertocq
66691b644a Refactor Budget::PHASES constant to Budget::Phase::PHASE_KINDS 2018-01-16 12:18:13 +01:00
Bertocq
f2228a908b Refactor budget's phase max description lenght from Budget to Phase model 2018-01-16 12:18:13 +01:00
Bertocq
153b46b468 Create description_for_phase helper method at Budget, to make it easier to get non-active-phase description 2018-01-16 12:18:13 +01:00
Bertocq
5016568b8a Correctly indent private function at budget model 2018-01-16 12:18:13 +01:00
rgarcia
349780922d Add Budget.open scope
Before Budget.current could return multiple budgets, now there can only
be a single current_budget.

Adding the concept of open, which better reflects what the admin sees
in this page: A tab for open budgets and a tab for finished budgets
2018-01-15 22:01:59 +01:00
rgarcia
9176de949a Refactor concept of current budget
When there was only one budget this implementation worked fine

Nowadays there can be multiple budgets, and therefore the definition of
the current_budget has changed. It is no longer a budget that has not
finished, but rather, the last budget created that is not in the
initial drafting phase.

Budgets in the drafting phase are not considered the current_budget,
but rather a budget that is still being prepared and that soon will
become the current_budget
2018-01-15 19:13:37 +01:00
Bertocq
7179dbbba0 Remove deprecated on hold budget phase group, no longer used in code 2018-01-14 20:41:24 +01:00
Bertocq
21d6ce57c5 Add published_prices? helper method and phases constant at Budget model 2018-01-10 01:15:07 +01:00
Bertocq
922318b978 Add publishing prices phase to budget model, plus translation texts 2018-01-10 01:10:57 +01:00
Bertocq
d8ceff1a53 Refactor Budget's on hold phases to constant, plus alignments 2018-01-10 01:09:13 +01:00
Bertocq
f9803ce9ca Add drafting phase to budget model & translations 2018-01-08 22:56:11 +01:00
BertoCQ
e990568895 Merge pull request #1721 from consul/feature/add_slugs_to_budget_related
Add slugs to budget related
2017-07-05 13:16:24 +02:00
Bertocq
e3d89261a6 Add Sluggable concern and unique validation to Budget, Group and Heading
* What: We need to generate slug on Budget, Group and Heading classes, validating its unique for its scope

* How: Adding a presence and unique validation using Budget always as scope.
2017-07-05 12:33:16 +02:00
Bertocq
2888c20489 Fix all Style/RedundantSelf rubocop issues 2017-07-05 11:55:52 +02:00
Bertocq
154cdac332 Add calculate_winners on Admin Budget controller, route and ability for admins 2017-06-25 15:47:04 +02:00
rgarcia
712e576e75 adds email delivery of selected and unselected investments 2017-05-12 13:57:31 +02:00
Juanjo Bazán
33e8ebf043 adds balloting_or_later? method to Budget 2017-05-09 17:27:58 +02:00
Juanjo Bazán
8654517743 changes budget name max length 2017-04-27 17:04:25 +02:00
Alberto Garcia Cabeza
8722699cd8 fixes typos and spec for budgets investments 2017-01-08 22:17:14 +01:00
kikito
248755a801 Modifies the investment orders shown by phase 2017-01-05 17:38:36 +01:00
kikito
9e4b2fda89 Adds phases to form 2017-01-01 15:03:58 +01:00