Commit Graph

29 Commits

Author SHA1 Message Date
Javi Martín
b5b07bccd3 Apply PercentLiteralDelimiters rubocop rule 2019-09-10 20:02:15 +02:00
Javi Martín
e500d15704 Use Translation classes consistently
We're moving the code for the phases translation class to the same place
in the code the other translation classes are: right after including the
Globalizable module.
2019-08-08 18:49:14 +02:00
Senén Rodero Rodríguez
3b03e583f9 Move Translation class inside Budget::Phase
The reason to move Translation class is explained here [1]

[1] 106649a8a5
2019-06-27 09:19:37 +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
Javi Martín
c8146e13db Indent private methods following our syntax rules 2019-05-21 13:50:18 +02:00
Javi Martín
005a708adc Don't use find_by in scopes
As the Rails guides say:

> All scope methods will return an ActiveRecord::Relation object

That means `find_by_kind` will return a relation when nothing is found;
the expected behaviour is to return `nil`, like all `find_by` methods
do.

Using scopes also means strange things happen when we try to chain
scopes like `phases.published.drafting`. With scopes, the `drafting`
part would be ignored and all published phases would be returned.
2019-05-21 13:50:18 +02:00
Angel Perez
01c1ac2b10 Replace all occurrences of ActiveRecord::Base with ApplicationRecord 2019-04-17 17:40:56 +02:00
Julian Herrero
dc88212b75 Remove Budget::Phase 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.

Since module Sanitizable takes care of traslations, it's enough to
include the module in order to correctly sanitize the description.
2019-04-16 17:28:07 +02:00
Julian Herrero
3ba961a2d7 Use double quotes in models 2019-03-14 17:25:43 +01:00
Julian Herrero
90d0a6e416 Make budget phases translatable 2019-02-13 11:44:56 +01:00
Raúl Fuentes
82b750de68 moved duplicated code to helper 2018-01-23 15:42:01 +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
d017b5bb49 Make Budget::Phase#invalid_dates_range? private 2018-01-23 00:23:22 +01:00
Bertocq
16b6abe2b8 Touch Budget object after updating a Budget::Pphase
Why:

We need to clear associated rails cache keys in order for changes to be
ready to be seen on the views

How:

* Just an after_save callback to a private method
2018-01-23 00:23:19 +01:00
María Checa
1abb7f0310 Added admin budget phases controller and routes 2018-01-19 17:55:24 +01:00
decabeza
f722caac24 removes budget steps on header 2018-01-19 14:35:05 +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
a6b06ca730 Improve Budget's homepage
* Add budget's phases number status
* Add budget's headings and groups list
* Placeholders for future improvements
2018-01-17 19:11:58 +01:00
Bertocq
02d596c872 Add a rake task to generate missing Budget::Phase's and migrate descricptions 2018-01-16 15:20:52 +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
601351d160 Validate next/prev phases before saving a Budget::Phase, with model specs 2018-01-16 15:20:17 +01:00
Bertocq
d505cda949 Add description sanitization to Budget::Phase with model specs 2018-01-16 12:18:13 +01:00
Bertocq
21b62106e5 Add next/prev enabled phase helper functions to Budget::Phase with model specs 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
36e74d0ef2 Add Budget::Phase model, spec and factory
Create a new Budget::Phase model that:
* Stablishes a relation with its budget
* Stablishes relation with two other Budget::Phases (previous and next)
* Validates basic dates range, kind and description rules.
* Adds scopes to get the ones enabled as well as each individual phase

Create a factory that generates a basic and valid Budget::Phase

Create a model spec that checks kind, date range and budget validations.
2018-01-16 12:18:13 +01:00