Commit Graph

14774 Commits

Author SHA1 Message Date
Javier Martín
dbe67edcdf Merge pull request #3839 from consul/generate_stats
Improve restrictions for poll stats
2019-11-09 19:58:08 +01:00
Pierre Mesure
232e6c7f11 Replace old Spanish text with org name 2019-11-09 19:38:13 +01:00
Javi Martín
ed6a4a1b95 Don't generate stats for budget polls
The link to show stats for these polls is nowhere to be seen in the
application, and these stats are included in the budget stats, so it
makes sense to restrict access to them.
2019-11-09 19:34:24 +01:00
Javi Martín
01a01c834d Only generate stats if we can access them
There's no point generating stats nobody can access.

Note with this change we're automatically excluding polls created in the
dashboard, since these polls don't have stats enabled.
2019-11-09 19:34:24 +01:00
Javi Martín
f8e6e98d3a Define stats and result permissions with scopes
When defining abilities, scopes cover more cases because they can be
used to check permissions for a record and to filter a collection. Ruby
blocks can only be used to check permissions for a record.

Note the `Budget::Phase.kind_or_later` name sounds funny, probably
because we use the word "phase" for both an an attribute in the budgets
table and an object associated with the budget, and so naming methods
for a budget phase is a bit tricky.
2019-11-09 19:34:21 +01:00
Javi Martín
9e27027f56 Remove duplicate scope
The scopes `created_by_admin` and `public_polls` were very similar. I'm
using `created_by_admin` because `Poll.public_polls` feels redundant,
and the reason for that name is we should not name the scope `public`
because `public` is a ruby access modifier.
2019-11-09 19:33:02 +01:00
Javi Martín
864f750d92 Remove duplication in poll permissions
We were checking for `expired?` and `results_enabled?` in views and
helpers, when we've already defined a rule for accessing stats and
results for a poll.

This way we also fix a bug when stats were enabled but the poll wasn't
finished. In this scenario, the link pointed to the stats page, but when
clicking it we'd get a "you don't have permission" message.

Now the link doesn't point to the stats page anymore.
2019-11-09 19:33:02 +01:00
Javi Martín
2029d7baa5 Limit admin access to poll stats and results
There's no reason to allow administrators to check stats and results for
a poll when it isn't finished or when results and stats are not enabled.

Now admins have the same permissions as everyone else.
2019-11-09 19:32:54 +01:00
Javi Martín
8dbad5c3d2 Simplify tests for stats and results permissions
Now these tests look like the other ability tests.
2019-11-09 15:18:58 +01:00
Javier Martín
6778bdb204 Merge pull request #3834 from consul/find_by_everywhere
Apply rubocop Rails/FindBy rule everywhere
2019-11-08 20:32:31 +01:00
Javier Martín
82c0e9650d Merge pull request #3833 from consul/remove_obsolete_milestone_tables
Remove old milestone tables
2019-11-08 19:37:51 +01:00
Javi Martín
9ff285b9cc Use find_by_slug_or_id! to find a poll
We were manually doing a similar thing - only we weren't raising an
exception when we should.
2019-11-08 19:22:11 +01:00
Javi Martín
ea2aeab383 Apply rubocop Rails/FindBy rule everywhere
We didn't detect these cases because by default the rule only searches
for offenses in `app/models/`.
2019-11-08 19:15:04 +01:00
Javier Martín
84bbd81d95 Merge pull request #3832 from consul/test_logger
Don't add log info messages when running tests
2019-11-08 19:10:55 +01:00
Javi Martín
56c797348c Remove old milestone tables
These tables are obsolete since commit c0f6fa18, and their content was
migrated in version 0.18 with the task added in commit 4c3dadf1.
2019-11-08 18:57:54 +01:00
Javier Martín
fcb2e2fb54 Merge pull request #3831 from consul/fix_action_title
Fix random title with trailing spaces
2019-11-08 18:41:18 +01:00
Javier Martín
0f646c67f1 Merge pull request #3828 from consul/remove_obsolete_translatable_columns
Bring back removal of translatable columns
2019-11-08 18:20:54 +01:00
Javi Martín
a1b89094be Don't add log info messages when running tests
We use these messages in rake tasks, but when we run the test suite they
only add noise.
2019-11-08 18:06:18 +01:00
Javi Martín
8f021cbfce Fix random title with trailing spaces
When the generated title for a dashboard action ended with a space, the
action `click_link(feature.title)` failed because the link shown in the
HTML ignores the trailing spaces.

Using `strip` solves the problem. Not the most elegant solution, though;
ideally we'd generate a better title.
2019-11-08 17:58:56 +01:00
Javier Martín
487008d445 Merge pull request #3829 from rockandror/remove-duplicated-local-census-records-on-deployment
Remove duplicated local census records on deployment
2019-11-08 15:39:53 +01:00
Senén Rodero Rodríguez
15b4ff64f4 Run local census records remove_duplicates rake task during deployment
... and before applying new migrations.
2019-11-08 14:46:45 +01:00
Senén Rodero Rodríguez
be886ba77a Add rake task to remove duplicated local census records
Also supress migration messages during spec execution to keep test log as clean
as possible.
2019-11-08 14:46:45 +01:00
Javier Martín
943f2d9379 Merge pull request #3773 from rockandror/local-census-records-fixes
Local census records fixes
2019-11-08 12:36:37 +01:00
Javi Martín
7a78776569 Bring back removal of translatable columns
Globalize does not support having translatable columns with the same
name in the original table and the translations table. We were planning
to migrate to Mobility, but we aren't doing so before releasing version
1.1.

We've also found a gotcha regarding having both columns: if we use the
`update_column` method, which we use in rake tasks to speed up the
process and in tests where we want to skip validations and callbacks, we
update the column in the original table and no exception is raised. If
we remove the column in the original table, we get an exception, which
is what we want since our intention is to update the column in the
translations table.

With this change we're following the advice given by the Mobility lead
developer: "If you don't need the columns, I think it would make sense
to just remove them to avoid any edge case issues."

This commit reverts commit 251326ea.
2019-11-07 22:01:43 +01:00
Javier Martín
ed2d4dcf7f Merge pull request #3827 from consul/remove_obsolete_report_columns
Remove obsolete report columns from polls
2019-11-07 22:01:26 +01:00
Javi Martín
5ed308c6f7 Remove obsolete report columns from polls
These columns are obsolete since commit 354b183e, and its content was
migrated in version 1.0 with the task defined in commit 9ae0cbb2.
2019-11-07 20:36:43 +01:00
Javier Martín
f399802b30 Merge pull request #3826 from consul/jquery3_compatibility
Update deprecated jQuery syntax
2019-11-07 19:00:14 +01:00
Senén Rodero Rodríguez
a150f2161e Validate inclusion of document type in allowed document types
* Add custom message for inclusion validation to include the allowed values.
* Force user to choose document_type from select lik the one shown at verification form.
* Convert stored document_type to a human readable text
2019-11-07 16:26:19 +01:00
Javi Martín
849c081a1b Simplify the way we attach documents in tests
Now we do it the same way we attach images in `nested_imageable`.

Now we don't need to execute some JavaScript in the test, which by the
way was causing an error when upgrading to jQuery 3.
2019-11-07 15:58:49 +01:00
Javi Martín
d015362299 Remove obsolete poltergeist code
We moved to chromedriver a long time ago.
2019-11-07 15:58:49 +01:00
Javi Martín
953fc7ddb0 Update deprecated jQuery syntax
These methods had already been superseeded by other methods since jQuery
1.7 or 1.8, and jQuery 3.0 will deprecate them.
2019-11-07 15:58:49 +01:00
Javier Martín
52d165b419 Merge pull request #3804 from consul/bump_ckeditor
Bump ckeditor from 4.2.4 to 4.3.0
2019-11-07 14:54:19 +01:00
Javier Martín
a5cf7c6377 Merge pull request #3825 from consul/safe_navigation
Enable Lint/SafeNavigationChain rubocop rule
2019-11-07 13:52:01 +01:00
Javi Martín
45fedfe410 Enable Lint/SafeNavigationChain rubocop rule
We didn't add it before because we weren't following it in the code
related to votation types, but we've removed that code.
2019-11-07 13:17:26 +01:00
Javi Martín
ec1502ee00 Update CKEditor plugins to be precompiled
The new version of CKEditor loads the balloonpanel and balloontoolbar
plugins. Even if we don't need them, I haven't found a way to prevent
them from loading, meaning we have to precompile them.
2019-11-07 01:24:49 +01:00
Javi Martín
f240e0073f Bump ckeditor from 4.2.4 to 4.3.0
This version solves a security issue:

https://ckeditor.com/cke4/release/CKEditor-4.11.0

Note this version adds a `ckeditor/samples` folder, which is
automatically added to the application's assets manifest even if we
remove all CKEditor references in our application. One of the files in
that folder makes ExecJS raise a syntax error, causing every page to
raise a 500 error.
2019-11-06 22:05:44 +01:00
Javier Martín
a2f5317ae1 Merge pull request #3824 from consul/jumping_ckeditor
Avoid jumping CKEditor
2019-11-06 20:59:43 +01:00
Javi Martín
4ab3498892 Avoid jumping CKEditor
This is a hack: we're making the textarea have the same size as CKEditor
so when it's replaced the page won't jump.

A very similar hack was removed in commit e844b0b2. Back then I thought
this was a small issue we could live with, but the user experience turns
out to be a bit annoying, and it makes tests fail sometimes because
Capybara is trying to click something when the page jumps, and so it
misses the click.
2019-11-06 20:26:26 +01:00
Javier Martín
0d2ca78f46 Merge pull request #3820 from consul/remove_summary
Remove collaborative legislation summary
2019-11-06 17:55:11 +01:00
Javi Martín
128a816464 Remove collaborative legislation summary
This feature wasn't properly tested nor reviewed, and after reviewing
several pull requests with a similar status and considering this pull
request is related to the public area of the web, we've decided to
remove it before releasing version 1.1.

This commit reverts commit 4f50e67a.
2019-11-06 17:21:03 +01:00
Javier Martín
405ceee8f9 Merge pull request #3821 from consul/revert-3812-knapsack
Revert "Stop using Knapsack Pro"
2019-11-06 17:20:47 +01:00
Javier Martín
b86e0abc31 Merge pull request #3822 from consul/finished_budgets
Fix admin permissions for finished budgets
2019-11-06 16:12:59 +01:00
Javi Martín
0383ed96f5 Fix typo related to investment previews 2019-11-06 15:35:13 +01:00
Javi Martín
33c2b28063 Remove duplicate test
This test is exactly the same as the "visible for admins" scenario.
2019-11-06 15:35:13 +01:00
Javi Martín
6bbfb55586 Fix admin permissions for finished budgets
Although we weren't showing links in the views to execute certain
actions, forms could be still sent using a PUT/PATCH pull request to the
controller actions.
2019-11-06 15:35:12 +01:00
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