Commit Graph

1554 Commits

Author SHA1 Message Date
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
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
Raimond Garcia
a215c9c603 Merge pull request #2322 from consul/current_budget
Change concept of current budget to account for multiple budgets
2018-01-16 16:53:10 +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
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
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
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
BertoCQ
3d5bf04829 Merge pull request #2311 from consul/2299-budget_investments_related_content
Budget investments related content
2018-01-15 20:02:34 +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
María Checa
a1f840e8fd Added improvements to related contents 2018-01-12 18:35:15 +01:00
Raimond Garcia
b0bd7792be Merge pull request #1917 from wairbut-m2c/iagirre-admin-budget-heading-action
Actions for budgets' headings added. Edit headings, delete headings i…
2018-01-11 13:47:27 +01:00
iagirre
0e11e21b2a Merged with master and solved conflicts 2018-01-10 13:23:39 +01:00
Bertocq
334091710c Refactor price & explanation showing logic at Investment model 2018-01-10 11:26:16 +01:00
Bertocq
21d6ce57c5 Add published_prices? helper method and phases constant at Budget model 2018-01-10 01:15:07 +01:00
Bertocq
f3a7de55ea Rename should_show_price_info? to should_show_price_explanation? at Budget::Investment & usage 2018-01-10 01:13:34 +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
Raúl Fuentes
29018e3062 changes made at the request of voodoorai2000 2018-01-09 13:08:03 +01:00
Bertocq
f9803ce9ca Add drafting phase to budget model & translations 2018-01-08 22:56:11 +01:00
Bertocq
18236e8827 Fix random order seed value cleanup to allow negative values and always be numeric 2018-01-06 18:21:24 +01:00
Bertocq
b990384b0a Fix multiple attachment upload by setting the id, style and updated at date on hash 2018-01-03 17:38:44 +01:00
Bertocq
ce9d5ec022 Cleanup bad indentation on direct upload model 2018-01-03 17:38:44 +01:00
rgarcia
96066aee44 Validates map presence only on create
As we are using an attr_accessor to make sure a user accepts that the
proposal “has no map”, the validation was being run in every save.

Making other things break, for example the updating of the counter
cache `cached_votes_up`, when someone voted for the proposal, as the
attr_accessor `skip_map` was not present
2017-12-26 12:39:29 +01:00
BertoCQ
d534b02b3c Merge pull request #2206 from consul/related-contents-score
Related contents score
2017-12-20 15:13:12 +01:00
María Checa
1e23281c28 Fixed related content tests 2017-12-20 13:43:56 +01:00
rgarcia
7889efd6ee Fix map location update
When editing the map of a proposal or investment(the mappable) the
updated_at attribute of the mappable was not been updated and so the
map still displayed the old location after updating it
2017-12-20 12:43:49 +01:00
Bertocq
cf06d5b047 Refactor related content score methods to make them easier to follow 2017-12-20 10:24:00 +01:00
Bertocq
3eecabe9a8 Prevent authors or users that already scored from scoring related content 2017-12-20 03:06:41 +01:00
Bertocq
e6a5071160 Fix typo on RelatedContentScore attribute score to value 2017-12-20 02:36:14 +01:00
Bertocq
a72cc58b49 Fix Related Content Score presence validations and unique composed key 2017-12-20 02:36:14 +01:00
Bertocq
e19153a26e Fix typo on RelatedContentsScore call to RelatedContentScore 2017-12-20 02:36:14 +01:00
Bertocq
585eb36871 Hide related content when scoring goes under threshold 2017-12-20 02:36:13 +01:00
Bertocq
d544d56722 Add correct user to RelatedContentScore on creation 2017-12-20 02:36:13 +01:00
Bertocq
2e0dd9caea Relationable find_related_content should not be used to find, refactored to have a single purpose 2017-12-20 02:36:13 +01:00
Bertocq
2688f2a919 Add author user to related content 2017-12-20 02:36:13 +01:00
Bertocq
4d2d7c1a0a Add act as paranoid to related content, with not_hidden scope using hidden_at 2017-12-20 02:36:13 +01:00
Bertocq
f21f5ec05e Refactor Related Content Controller score methods 2017-12-20 02:36:13 +01:00
Bertocq
065b0ed3c8 Create Related Content Scores 2017-12-20 02:36:10 +01:00