Commit Graph

1586 Commits

Author SHA1 Message Date
Raimond Garcia
65f5ab424b Merge pull request #2570 from consul/unfeasibility-explanation
Display unfeasibility explanation only when valuation has finished
2018-04-05 00:21:31 +02:00
Raimond Garcia
787657e07e Merge pull request #2510 from consul/valuator-groups
Add valuator groups
2018-04-05 00:21:04 +02:00
rgarcia
71bb5b3dcf Fix display of unfeasibility explanation
We were missing a check to make sure valuation had finished before
displaying the unfeasibility explanation
2018-04-04 14:38:31 +02:00
Bertocq
633cc1283b Fix Date & DateTime parsings to use default timezone
Date.new(...) does not take into account the current timezone, while other
parts of the application do. By default always parsing any date with the
default timezone and converting the resulting Time to Date would prevent
this kind of issues

DateTime.parse(...).in_time_zone gives an unexpected result, as the
DateTime.parse(...) will create a DateTime with +0000 time zone and the
`in_time_zone` will modify the DateTime to adjust to the default zone.

Maybe its better explained with an example, using 'Lima' as timezone:

DateTime.parse("2015-01-01")
> Thu, 01 Jan 2015 00:00:00 +0000

DateTime.parse("2015-01-01").in_time_zone
> Wed, 31 Dec 2014 19:00:00 -05 -05:00

And that's not the desired date but the previous day!
2018-04-04 14:21:39 +02:00
rgarcia
7386a39f2d Fix specs 2018-04-04 13:21:21 +02:00
rgarcia
00c965b715 Clean up 2018-04-04 13:19:01 +02:00
rgarcia
7a01745188 Add valuation permissions to groups 2018-04-03 20:58:35 +02:00
rgarcia
7e839e7815 Filter by valuator group 2018-04-03 20:56:31 +02:00
rgarcia
ab498d6d93 Assign groups to investments 2018-04-03 20:55:44 +02:00
rgarcia
1dbbe331c9 Assign valuators to groups 2018-04-03 20:55:44 +02:00
rgarcia
cddfdf4b84 Add valuator groups 2018-04-03 20:55:44 +02:00
María Checa
4713d37346 Add budget/investments#json_data method permissions 2018-03-27 15:26:48 +02:00
María Checa
cd1a0548ba Add map_location#json_data method 2018-03-27 15:17:31 +02:00
rgarcia
09c44ee583 Extend notifications to be marked as read and unread 2018-03-23 11:47:06 +01:00
rgarcia
073cf74818 Fix edge case
The user was able to vote as many investments as wanted in the first
heading voted. However in the second heading voted, only one investment
could be voted

This was due to the previous implementation, where you could only vote
in one heading. Note the `first` call in method
`heading_voted_by_user?(user)`

This commits simplifies the logic and allows voting for any investment
in any heading that the user has previously voted in
2018-03-22 23:08:41 +01:00
rgarcia
5c6eaa76ff Add headings_voted_by_user
This method was used only in Madrid’s fork, but it is now needed to
complete the backport for voting in multiple headings

There wasn’t a test in Madrid, so here goes one too. Even though, the
responsibility should probably be moved soon to the `Budget::Heading`.
For consistency with the related methods and tests it has been left in
the investment_spec
2018-03-22 22:24:58 +01:00
rgarcia
0398bb23cb Consistent spacing
Temporarily… because there are 2 kinds of Ruby developers, those who
indent methods under `private` and does who don’t

https://gist.github.com/joefiorini/1049083#gistcomment-37692
2018-03-22 22:24:58 +01:00
rgarcia
bdffb9765e Allow voting in multiple headings
Now that we have the option of voting in multiple headings per group,
the method of voting in a “different heading assigned” has become
deprecated and thus removed
2018-03-22 22:24:58 +01:00
Raimond Garcia
c1d7378c92 Merge pull request #2504 from consul/budget_group_name_edit
Allow Budget Group names to be edited
2018-03-22 22:12:04 +01:00
rgarcia
7a980d79e7 Removes use of slugs to edit group name
Changing a group’s `to_param` to return the slug instead of the id,
breaks many tests in the user facing interface

We should use slugs in upstream soon, but it should be done in a
separate PR, bringing the whole slug implementation from Madrid’s fork
and the corresponding test coverage
2018-03-22 20:06:53 +01:00
Alberto García
eba4a3c6cb Merge pull request #2528 from consul/budgets-message
Heading link on budgets message
2018-03-09 13:25:39 +01:00
Alberto Calderón Queimadelos
a55218ad9f Merge pull request #2443 from consul/fix_currency_locale
Use user locale instead of default locale to format currencies
2018-03-08 18:03:52 +01:00
decabeza
0e9190bc43 Adds heading link on different heading message 2018-03-08 11:50:09 +01:00
Bertocq
b72e43168b Use user locale instead of default locale to format currencies 2018-03-08 10:20:05 +01:00
Bertocq
1ef2789640 Trim valuator investment valuation ability scope
Valuators shouldn't be able to valuate an investment which valuation has
already been finished (only admins can)
2018-03-06 20:18:05 +01:00
Raúl Fuentes
6d8d44a5e3 Added interface and methods for edit the name of a Budget::Group if the budget is still inthe drafting phase 2018-03-02 09:16:57 +01:00
Bertocq
6b41b6487b Add UserSegments#user_segment_emails helper method
Why:

Both Newsletters and Email Downloads need the same logic: To extract the
emails from all the users in the segment that have newsletter flag
active, removing all empty email values.

How:

1- UserSegments#user_segment_emails holds that repeated logic and is used
on both Newsletter & EmailDownload.

2- Rename Newsletter#list_of_recipients to list_of_recipient_emails as
it is more descriptive. There is no need to pass entire Users around,
only the emails are needed at Mailer#newsletter method.

3- Cleanup Newsletter#list_of_recipient_emails model spec scenario
2018-03-01 20:59:20 +01:00
Bertocq
99851e9588 Remove empty emails from users segments recipients
Why:

User with an empty email value (nil) should not appear in the recipient
list for a given UserSegment at Newsletters or Email Downloads.

How:

Using Enumerable#compact and Enumerable#select to filter out empty emails

Increasing Email Download feature spec and Newsletter model spec to cover
all possible scenarios including the nil email one.
2018-03-01 20:09:32 +01:00
Bertocq
65288573b5 Fix user administrators scope relation 2018-02-22 00:42:40 +01:00
Bertocq
7cfa7b18f9 Validate Newsletter segment_recipient value
Why:

A Newsletter can only be sent if the are available user recipient emails
and that means the `segment_recipient` value actually corresponds to a
function on the UserSegments class.

We could rely on the UserSegments::SEGMENTS constant as the list of
possible user segments functions that a Newsletter can use to gather
emails, so any value not included in that hash would not be valid.

But to be 100% sure the newsletter can get a recipients_list we should
just check if the UserSegments class has a method with same name as the
`segment_recipient` value.

How:

* Adding an validation method that checks if UserSegment has a method
with same name as the `segment_recipient` value.
* Adding an scenario to the Newsletter model spec to check this
2018-02-21 11:46:16 +01:00
Bertocq
4becd0eb35 Change Newsletter's segment_recipient to string
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
2018-02-21 11:46:11 +01:00
Bertocq
bdbb32e824 Move newsletter User scope outside UserSegments
Why:

UserSegments are not only used for Newsletters or Email downloads, but
also for internal Global Notifications. We don't want to have that scope
hardcoded inside UserSegments as users that have opted-out from the
newsletter should still be recipients of global notifications.

How:

Removing the scope from the UserSegments `all_users` method that acts as
base for all the other segments. Including that `newsletter` scope only
on the places that is relevant:
* When listing recipients for a newsletter
* When downloading a listing emails that can be newsletter recipients

Also updated relevant tests
2018-02-21 11:45:38 +01:00
María Checa
017c242085 Merge pull request #2462 from consul/admin-newsletter-emails
Admin newsletter emails
2018-02-20 16:17:37 +01:00
Bertocq
1434449b84 Fix line length issues at User model 2018-02-19 11:09:19 +01:00
Bertocq
9925e2b02f Extract inline query to User scope & refactor 2018-02-19 11:09:19 +01:00
Bertocq
4fb9f6829c Extract inline query to an OfficerAssignment scope 2018-02-19 11:09:19 +01:00
María Checa
24bca36639 Merge branch 'master' into admin-newsletter-emails 2018-02-14 16:07:13 +01:00
María Checa
f1fbe7ff29 Modified administrator abilities for newsletters 2018-02-14 16:05:31 +01:00
María Checa
07f2419f8f Added newsletter model and UserSegments class 2018-02-13 11:39:10 +01:00
Bertocq
57743df197 Enable rubocop Performance/HashEachMethods cop & fix issues 2018-02-10 21:22:47 +01:00
Bertocq
6d9926441e Reverse investment scoped filter for budget by slug and then id 2018-02-10 16:39:27 +01:00
Bertocq
2341a2f70b Add by_budget scope to Investment and use it 2018-02-10 16:36:14 +01:00
Bertocq
7e67e8c93b Remove unnecesary empty line at milestone model 2018-02-05 15:54:33 +01:00
BertoCQ
c16e42e1e3 Merge pull request #2434 from consul/slug_generation_logic
Only change budget slugs if its on draft phase
2018-02-05 15:35:58 +01:00
Bertocq
e0871e5dc6 Only update slug if empty or model condition is met 2018-02-04 23:04:48 +01:00
Bertocq
a297faec4b Add order scope to milestone for publication date 2018-02-03 19:15:31 +01:00
Bertocq
04de1e19f5 Make mappable 100 line length compliant 2018-02-02 21:51:49 +01:00
Bertocq
24b1e64113 Validate MapLocation lat/long/zoom have numeric values 2018-02-02 21:37:50 +01:00
BertoCQ
38b66e8c6c Merge pull request #2295 from wairbut-m2c/aperez-mappable-objects
Improvements for Mappable objects
2018-02-02 19:26:47 +01:00
Angel Perez
47c9b343ee Admins can search investments by title or ID (#2401) 2018-01-31 09:52:55 -04:00