Commit Graph

15065 Commits

Author SHA1 Message Date
Javi Martín
98e836ea83 Improve interface of change log table
The name of the changed field is translated, values are truncated so
descriptions with thousands of character would make this table huge and
impossible to read, dates are localized, and values like arrays and
booleans are displayed properly.
2019-11-05 13:23:11 +01:00
Javi Martín
04cd3b460e Audit changes in investment translations
Note the user interface could certainly be improved, as it doesn't show
which languages have changed.
2019-11-05 13:09:38 +01:00
Javi Martín
e0c2468bd2 Use a different controller for investment audits
The same way we do for milestones. We also make the code more consistent
since the view was already in a separate folder.
2019-11-05 13:03:45 +01:00
Javi Martín
ed223e0bd1 Use audited to track investment changes
Our manual implementation had a few issues. In particular, it didn't
track changes related to associations, which became more of an issue
when we made investments translatable.

Using audited gives us more functionality while at the same time
simplifies our code. However, it adds one more external dependency to
our project.

The reason for choosing audited over paper trail is audited seems to
make it easier to handle associations.
2019-11-05 13:02:37 +01:00
Javi Martín
3f3fe9a3d3 Don't define controller actions in helpers 2019-11-05 12:54:32 +01:00
Javi Martín
6f4dc11dc4 Remove validations in investment changelog entries
If we validate the presence of the old value and the new value, changes
in optional fields will not be stored if either the old value or the new
value are blank.
2019-11-05 12:54:32 +01:00
Javi Martín
e08b516284 Reduce changelog entries generated by dev seeds
Since we were saving the same budget investments several times, once for
every language, we were creating more than 1000 changelog entries.

Assigning the language attributes when creating the investments
generates less entries, making it easier to work with them.
2019-11-05 12:54:32 +01:00
Julian Nicolas Herrero
768f85afcb Merge pull request #3812 from consul/knapsack
Stop using Knapsack Pro
2019-11-04 19:59:27 +07:00
Julian Herrero
5b3d40ce8e Stop using Knapsack Pro 2019-11-04 16:58:06 +07:00
Javier Martín
9ebea50f3f Merge pull request #3810 from consul/remove_tracker_role
Remove tracker role
2019-11-01 21:28:37 +01:00
Javi Martín
ac6d50e06b Remove tracker role
The current tracking section had a few issues:

* When browsing as an admin, this section becomes useless since no
investments are shown
* Browsing investments in the admin section, you're suddenly redirected
to the tracking section, making navigation confusing
* One test related to the officing dashboard failed due to these changes
and had been commented
* Several views and controller methods were copied from other sections,
leading to duplication and making the code harder to maintain
* Tracking routes were defined for proposals and legislation processes,
but in the tracking section only investments were shown
* Probably many more things, since these issues were detected after only
an hour reviewing and testing the code

So we're removing this untested section before releasing version 1.1. We
might add it back afterwards.
2019-11-01 20:08:46 +01:00
Javi Martín
71d9ac20e3 Remove duplicate translations
The first translation block was being overwritten by the second one.
2019-11-01 19:42:32 +01:00
Javier Martín
affb41cb70 Merge pull request #3807 from consul/fix_budget_staff
Fix assigning staff members to budgets
2019-11-01 17:21:33 +01:00
Javi Martín
9b511edd5b Write task to migrate budget admins and valuators
If we didn't run this task, investments for existing budgets wouldn't
show their administrator/valuators as an option when we're editing them,
leading to data loss.
2019-11-01 17:12:42 +01:00
Javi Martín
62c4d41af4 Remove unused budget attributes
Tags and help links can be edited, but aren't used anywhere. Since we
don't know what the intended behavior was, I'm removing them for now.

My best guess is tags were supposed to be used so investments for a
budget can only be assigned tags present in the budget. Achieving that
behavior wouldn't be a trivial task.
2019-11-01 17:12:42 +01:00
Javi Martín
beae82aae8 Order tags to search by alphabetically
We were ordering one group of tags alphabetically and then adding
another group of tags which wasn't ordered alphabetically, which didn't
make much sense.
2019-11-01 17:12:42 +01:00
Javi Martín
fb2b821c28 Remove duplication in investment tag methods 2019-11-01 17:12:42 +01:00
Javi Martín
20001824e5 Use acts_as_taggable for budget tags
We were adding columns to the budgets table instead of using the same
logic we use everywhere else.
2019-11-01 17:12:42 +01:00
Javi Martín
d5cb519819 Fix typo in milestone tags 2019-11-01 17:12:42 +01:00
Javi Martín
b1806dde44 Rename Budget#milestone_tags method
Since budgets now have milestone tags, the name of this method was
confusing and will conflict with the name generated by acts_as_taggable.

Note the new name could be improved too.
2019-11-01 17:12:42 +01:00
Javi Martín
b8fbd6347b Use acts_as_taggable for investment valuation tags
We were manually doing the same thing, generating inconsistent results,
since the method `valuation_tag_list` was using the `valuation` context,
when actually the expected behavior would be to use the `valuation_tag`
context.
2019-11-01 17:12:31 +01:00
Javi Martín
184d5fc504 Remove unused model
It was added in commit 74083df1; we're not sure why.
2019-11-01 16:49:14 +01:00
Javi Martín
8ed3595b70 Revert local variable extraction
It doesn't seem very useful.

This commit reverts part of commit 74083df1.
2019-11-01 16:49:14 +01:00
Javi Martín
c1f2e8fd7a Use budget.investments instead of by_budget
Same result, with less code.
2019-11-01 16:49:14 +01:00
Javi Martín
ac1dd79f95 Fix unselecting all staff for a budget
We need to add a hidden field for each group of check boxes, so if we
don't check anything, the hidden field is sent to the server, indicating
nothing was selected. Without the hidden field, the server will not know
anything has been done to the check boxes.

The easiest way to do it is using `collection_check_boxes`, which also
adds labels to every check box.
2019-11-01 16:49:14 +01:00
Javi Martín
e47c55e87f Remove unused translations
They weren't caught by `i18n-tasks` because there are places were we use
`t("budgets.edit.#{variable}"`, which marks as used all translations
starting with `budgets.edit`
2019-11-01 16:49:14 +01:00
Javi Martín
483c75fb82 Extract methods to load budget staff 2019-11-01 16:49:14 +01:00
Javi Martín
458cffe50b Remove redundant .all calls 2019-11-01 16:49:14 +01:00
Javier Martín
5812138723 Merge pull request #3809 from consul/pluralize_js
Simplify JavaScript to pluralize translations
2019-11-01 16:48:05 +01:00
Javier Martín
f54525f658 Merge pull request #3617 from consul/fix_poll_results_exception
Avoid error for polls results
2019-11-01 12:05:40 +01:00
Javi Martín
6c323eaf3e Use JavaScript pluralize for budget staff
We were using two different systems to set translations in JavaScript:
to set the text for languages, we were using data attributes, and to set
the text for staff members, we were using AJAX calls.

I find data attributes keep the code more simple, since there's no need
to define an extra route and controller action. Furthermore, the user
experience is better because response times are faster.

So now both places use data attributes.
2019-10-31 16:21:39 +01:00
Javi Martín
7b89dd6a5f Refactor links to show staff members 2019-10-31 16:21:39 +01:00
Javi Martín
9e74ebccb6 Store texts data in the element using them
This way we can have a generic function we can apply in other places.
2019-10-31 15:07:08 +01:00
Javi Martín
e314701d49 Extract method to pluralize text in JavaScript
This way we can reuse it in other places.
2019-10-31 15:03:57 +01:00
Javi Martín
b15ae77ddc Simplify Javascript to pluralize translations
We can pass the whole translation hash instead of passing descriptions
individually, and we can replace `%{count}` so we don't need any <span>
tags.
2019-10-31 14:49:46 +01:00
Julian Herrero
629c75ceeb Avoid error for polls results
When a poll is created, and any of the questions for that poll doesn't
have any answer created, the following exception was raised when
trying to see the results:

Failure/Error: question_answers.max_by {|answer| answer.total_votes }.id

  ActionView::Template::Error:
    undefined method `id' for nil:NilClass
      ./app/models/poll/question.rb:66:in `most_voted_answer_id'
2019-10-31 13:48:42 +01:00
Javier Martín
6bcf8ea806 Merge pull request #3806 from consul/remove_votation_types
Remove poll votation types
2019-10-31 13:47:49 +01:00
Mohsin Khan
9fd79cefd4 Don't send newsletters to unconfirmed accounts (Merge #3781) 2019-10-30 21:15:05 +01:00
Javi Martín
af7c37634d Remove poll votation types
Unfortunately this feature wasn't properly reviewed and tested, and it
had many bugs, some of them critical and hard to fix, like validations
being skipped in concurrent requests.

So we're removing it before releasing version 1.1. We might add it back
in the future if we manage to solve the critical issues.

This commit reverts commit 836f9ba7.
2019-10-30 18:48:55 +01:00
Javier Martín
bf7a8b4519 Merge pull request #3805 from consul/remove_people_proposal
Remove people proposal model
2019-10-30 13:48:13 +01:00
Javi Martín
f3df3f4fbc Remove people proposal model
This model isn't used anywhere, since it was created as part of a
feature which couldn't be completed.

This commit reverts commit 46e5d6a9.
2019-10-30 02:26:42 +01:00
Javier Martín
a1dce46754 Merge pull request #3800 from rockandror/add-missing-spanish-translations
Add missing spanish translations
2019-10-28 11:23:40 +01:00
Senén Rodero Rodríguez
db7b826902 Add missing spanish translations for poll questions 2019-10-27 08:55:24 +01:00
Senén Rodero Rodríguez
75d4395f9b Add missing spanish translations for local census record import model 2019-10-27 08:55:24 +01:00
Javier Martín
f18fe79cc4 Merge pull request #3803 from consul/rubocop_layout
Add rubocop style rules
2019-10-26 20:47:20 +02:00
Javi Martín
1fc30eb1c0 Use safe navigation instead of rescue nil 2019-10-26 20:12:12 +02:00
Javi Martín
88c70366a7 Apply rubocop rules for trailing commas 2019-10-26 20:10:33 +02:00
Javi Martín
a727dcc031 Apply Style/SymbolProc rubocop rule
This style is much more concise.
2019-10-26 20:10:32 +02:00
Javi Martín
34e66acdda Apply Style/StringLiteralsInInterpolation rubocop rule
We were already using it in most places.
2019-10-26 13:37:36 +02:00
Javi Martín
8e3bfa0d72 Apply Style/RedundantReturn rubocop rule
We were already following this pattern most of the time.
2019-10-26 13:26:35 +02:00