Commit Graph

14628 Commits

Author SHA1 Message Date
Julian Herrero
69838c78b9 Revert "Stop using Knapsack Pro"
This reverts PR https://github.com/consul/consul/pull/3812
2019-11-06 18:58:05 +07:00
Javier Martín
450c5feb5e Merge pull request #3819 from consul/remove_csv
Remove new CSV report generation
2019-11-06 00:33:26 +01:00
Javi Martín
82b0a6a92d Remove new CSV report generation
The new CSV report was more configurable and could work on proposals,
processes and comments. However, it had several issues.

In the public area, by default it generated a blank file.

In the admin section, the report was hard to configure and it generated
a file with less quality than the old system.

So until we improve this system, we're bringing back the old investment
CSV exporter.

This commit reverts most of commit 9d1ca3bf.
2019-11-06 00:04:02 +01:00
Javi Martín
ea8efa36f5 Fix pluralization typos 2019-11-06 00:04:02 +01:00
Javier Martín
440696683a Merge pull request #3817 from consul/valuators
Fix valuation permissions for finished budgets
2019-11-06 00:03:36 +01:00
Javi Martín
a3534e1f93 Use presence to simplify code 2019-11-05 23:15:17 +01:00
Javi Martín
d1d71f0044 Don't allow valuation if cannot edit dossier
We were adding the condition to show the form in the view. However, that
doesn't prevent users from sending a POST/PUT request to the controller
action.

We could add the condition to the controller as well, but since the
`valuate` permission is only used in one place, it's easier to restrict
that permission to valuators who can edit the dossier.
2019-11-05 23:15:16 +01:00
Javi Martín
6db0272575 Fix valuation permissions for finished budgets 2019-11-05 23:13:04 +01:00
Javi Martín
8f87753306 Simplify test for valuator abilities 2019-11-05 23:12:10 +01:00
Javi Martín
d077f7c14b Refactor method to display valuator abilities
Using `select` is easier to follow than adding `nil` to an array and
then using `compact`.
2019-11-05 22:59:19 +01:00
Javier Martín
4722e74e72 Merge pull request #3816 from consul/columns_selector
Fix typos in columns selector
2019-11-05 17:47:27 +01:00
Javi Martín
edf3ec8c2e Fix typo in selectable columns 2019-11-05 16:23:08 +01:00
Javi Martín
ed88105598 Remove unneeded variable declaration
It was generated by CoffeeScript, but in JavaScript we use `var` to
declare it.
2019-11-05 15:43:27 +01:00
Javier Martín
cbe6af3eb7 Merge pull request #3811 from consul/investment_changelog
Use audited to track changes in investments
2019-11-05 14:46:04 +01:00
Javi Martín
9565d6ac56 Simplify tests for audits 2019-11-05 14:17:04 +01:00
Javi Martín
5192ac052f Improve user interface showing a change log entry
Don't use <label> tags for things that are not labels, add a proper
<title> for the page, add a back link, remove an unnecessary
`inline-block` style for a header, localize dates and field names, ...

The interface could be further improve: proper diffs for long texts,
better separation between fields, ...
2019-11-05 13:23:11 +01:00
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