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'
- Cleanup Translatable module (`translation_params` method too large)
- Move globalize_helpers partial to admin folder
- Use any class for method translation_params
- Helpers in `GlobalizeHelpers` make sure all are in use and see if they can be more legible
- Review js name clases and methods see if they can be more legible
- Refactor milestone views into partials with nice spacing between attributes
There was a problem with the portuguese locale.
The locale was pt-BR, but `globalize_accessors` gem
doesn't allow the creation of methods using locales
with that format.
To avoid transforming pt-BR to pt and lose the distinction
of the different variations of the language, a function has
been added to transform pt-BR into pt_br (without changing
the locale itself). That way, when globalize uses the locales,
all of them will have a valid format (downcased and underscored)
AND they will be always the same (comparing pt-BR with pt_br
doesn't work).
When the locale changes the corresponding tab is
highlighted automatically.
When a language is added to the milestone, the tab
is highlighted automatically.
To delete a translation, a link has been added. This
link works for the selected language. It hides all the
things related to a language (the tab and the text_area)
and empties the text area, so that the value is blank
in the param hash. A variable called `delete_translations[]`
is changed.
e.g. If admin wants to remove English language,
delete_translations[:en] will be 1; if not, it will be 0.
When the milestone is updated, there is a before_action
callback that cleans the selected languages for deletion
(looking the delete_translations[] variable).
Because of the deleted translations are blank in param hash,
them won't be saved in DB.
There's no good reason to call assigned_valuators(investment) when the
logic can be at the model.
Also removed the valuator_groups texts to be added in an independent
method
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
ApplicationHelper#format_price and Budget#formatted_amount has the same
objective and code, but the Budget#formatted_amount method also uses the
currency of the Budget to correctly give currencies format.
By replacing usage of format_price with formatted_amount we can remove
format_price and have a single location for currency format logic.
Why:
The logic to construct the link to a heading (if it exists) is in three
different places, this is a clear candidate for a helper method.
How:
Just checking at the helper method if `assigned_heading` and `budget`
has values and composing the link if so.
Why:
When there is not Budget accepting (Investment creation) the guide page
doesn't have much sense as it will give the user an option that can't be
used (creating an Investment).
How:
Using `Budget.current&.accepting?` conditional at GuidesHelper to link
to new proposal link instead of guide page, and adding an scenario to
guides feature spec for it.
Why:
Newsletter attribute `segment_recipient` is an integer to be used as
enum. There's no advantage to store a number instead of an string if the
ammount of elements in the table is not going to be huge, or we can take
advantage of using an enum.
Also maintaining both Newsletters enum paired with UserSegments::SEGMENTS
would be a maintenance burden.
How:
* Migration to change segment_recipient column from integer to string
* Removing enumeration from Newsletter model class
* Using UserSegments::SEGMENTS instead of Newsletter.segment_recipients
or integer values