Commit Graph

18194 Commits

Author SHA1 Message Date
Karim Semmoud
3faaa8521d Render markdown tables in legislation draft
* Add Tables option to Redcarpet in Legislation draft

* Allow table tags in Admin Legislation Sanitizer

* Add Test to render markdown tables in Legislation drafts

* Add Test for Admin Legislation Sanitizer

We include test for image, table and h1 to h6 tags and additional tests to strengthen the allowed and disallowed parameters

* Add Table from markdown test in System and Factories

* Add test to render  tables for admin user

* Remove comment line about Redcarpet options

* Edit custom css for legislation draft table to make it responsive
2023-06-29 20:48:01 +02:00
Senén Rodero
b4f2e66c78 Merge pull request #5147 from consul/bump_capybara-webmock
Bump selenium-webdriver from 3.142 to 4.0.0
2023-06-29 18:37:57 +02:00
Senén Rodero Rodríguez
41a84d6625 Bump selenium-webdriver from 3.142 to 4.0.0
And also `capybara-webmock' to the latest as the previous
one is not supported by selenium-webdriver.

The change in the rails_helper.rb file fixes a deprecation warning
related to desired capabilities after this upgrade.
2023-06-29 17:29:21 +02:00
Javi Martín
68927409b6 Fix text selection in budget heading
The `inverted-selection` rules defined in the `%brand-background`
selector weren't being applied because we were using this selector in
`::before` and `::after` pseudoelements. Not sure about the reason, but
it looks like the saturation of `::after::selection` pseudoelements
resulted in invalid selectors and so the inverted selection rules were
ignored for every selection using `%brand-background`, like
`%budget-header`.

Using `@include brand-background` instead of `@extend %brand-background`
in pseudoelements solves the issue. The inverted selection might not
work in these pseudoelements, but we don't need it there since these
pseudoelements don't have content.
2023-06-29 15:54:29 +02:00
Javi Martín
970a64e276 Enable mousewheel when focusing on the map
Zooming with the mousewheel is useful when you want to use it, but
annoying when you don't want to.

Here we're taking an intermediary approach: by default, the mousewheel
isn't active, but it will be active after focusing on the map, so it can
be used both to scroll and to zoom.

This behavior presents usability issues, though, since we aren't making
users aware of the way the mousewheel works, and even if they were
aware, it could be confusing anyway. However, I currently think it's
better than always enabling or always disabling the mousewheel (might
change my mind, though).

Note that the "focus" event is only used on the map, so if we click on a
marker or navigate to a marker with the keyboard without focusing on the
map first, the mousewheel isn't enabled. The same would happen if we
used the "click" event.

We might use the Leaflet.GestureHandling plugin in the future to deal
with this issue and the scroll on touch screens.
2023-06-29 15:54:07 +02:00
Javi Martín
ee9cd881e0 Restart DelayedJob workers after they crash
DelayedJob offers the `--monitor` (aliased as `-m`) option to create a
process that monitors the workers and restarts them when they crash.

This change implies that, in order to stop the delayed job workers, we
now need to pass the `-n` option when running `bin/delayed_job stop`:
`RAILS_ENV=production bin/delayed_job -n 2 stop`.
2023-06-29 15:50:19 +02:00
Senén Rodero
59d260c891 Merge pull request #5143 from consul/bump_parser
Bump parser from 3.1.0.3 to 3.2.2.3
2023-06-29 13:37:36 +02:00
Senén Rodero Rodríguez
15e9c593a8 Bump parser from 3.1.0.3 to 3.2.2.3 2023-06-29 13:03:54 +02:00
Senén Rodero
93d33b6d83 Merge pull request #5141 from consul/search_dictionary_selector
Fix Serbian locale code
2023-06-28 13:02:26 +02:00
Senén Rodero Rodríguez
83b5965821 Fix Serbian locale code
I accidentally duplicated the locale code within
commit 3c3ff65.
2023-06-27 18:06:19 +02:00
Sebastia
f001f07210 Merge pull request #5140 from consul/legislation-proposals
Remove unused code from Legislation proposals
2023-06-27 16:48:20 +02:00
taitus
d2b181777d Call Legislation::Proposals::VotesComponent directly 2023-06-27 15:57:03 +02:00
Senén Rodero
ab698a79a8 Merge pull request #5098 from consul/map_open_popups_with_keyboard
Open marker popups when navigating with the keyboard
2023-06-27 15:33:45 +02:00
Javi Martín
ad26c5cf9f Fix background images with special characters
Just like we did for budgets, we're doing the same thing in all the
places where we render background images attached by either regular
users or administrators.

This way we correctly render background images with characters like
brackets or quotes.
2023-06-27 15:06:30 +02:00
taitus
ab2c548964 Remove unused code for legislation proposals votes
In these commits 38ba5e159b and 8805037e2f we added the parameter
"vote_url" in the call to the partial "votes" in collaborative legislation
proposals.

It seems that this parameter is only used in the proposals module and not in
collaborative legislation proposals.

While it is true that in the partial "votes" in these commits this parameter
"vote_url" is referred to, in commit 276baedcf it seems to be removed.

For this reason, we remove the parameter.
2023-06-27 14:44:54 +02:00
karim-semmoud
3a623c070f Add tests for budget images with brackets / quotes 2023-06-27 13:57:51 +02:00
Senén Rodero
90ddd99751 Merge pull request #5134 from consul/pg_search_dictionaries
Update search dictionaries
2023-06-26 20:54:51 +02:00
Senén Rodero Rodríguez
3fa3c90db6 Fix map markers navigation for keyboard users
By using the bindPopup function instead of the click event
popups work when using the keyboard.

Note that now we are loading all the map markers in the first
request in a single query to the database (needed when there
is a lot or markers to show). Because of that we removed the
AJAX endpoint.
2023-06-26 20:33:35 +02:00
Senén Rodero Rodríguez
2b0a812543 Add method to retrieve translations in one database query
This methods performs much better when we need to load a lot of
globalized models translations and returns the best fallback translation
for the current language.
2023-06-26 20:33:35 +02:00
Javi Martín
5630a24d7a Render budget images with special chars their names
Images with brackets weren't being rendered properly, so we're now
enclosing the URL in single quotes. In order to render images with
single quotes, we're also using the `j` method.

Since the tests were written by a different developer, we're adding them
in the next commit.
2023-06-26 20:06:39 +02:00
karim-semmoud
f4973498be Add budget image to Budget and image factories and model 2023-06-26 19:40:42 +02:00
Sebastia
bb8759d8fd Merge pull request #5122 from consul/strip-metadata
Remove metadata from images
2023-06-26 15:56:33 +02:00
Javi Martín
ec1fe1fbb1 Merge pull request #5104 from markusgeert/feature/disable-create-booths-button
Disable the create booths button when the polls function is disabled
2023-06-23 15:45:50 +02:00
Max Stevens
13bf866c95 Disable the create booths button when the polls function is disabled 2023-06-23 14:33:19 +02:00
Javi Martín
8ed898a13c Merge pull request #5110 from consul/dependabot/bundler/audited-5.3.3
Bump audited from 5.0.2 to 5.3.3
2023-06-23 14:09:46 +02:00
Senén Rodero Rodríguez
3c3ff65be1 Update search dictionaries
Since the creation of this list 3 years ago we added more languages to the
application and PostgreSQL added more dictionaries too.
2023-06-23 12:53:43 +02:00
Senén Rodero Rodríguez
1d7c821935 Sort languages alphabetically
So it's easier to know where to add new ones when needed.
2023-06-23 12:53:41 +02:00
Senén Rodero
443c5e0a53 Merge pull request #5137 from consul/legislation_translations
Allow administrators to override legislation and budget translations
2023-06-23 11:51:32 +02:00
Senén Rodero Rodríguez
27249f6e69 Allow administrators to override budgets translations 2023-06-23 11:15:54 +02:00
Senén Rodero Rodríguez
dc9a30adda Allow administrators to override legislation translations
Now administrators can override default legislation translations through
the administration panel.
2023-06-23 11:15:54 +02:00
Senén Rodero Rodríguez
ca12388005 Do not render proposals geozones when empty 2023-06-19 14:37:01 +02:00
Senén Rodero Rodríguez
e4cd02c6a9 Extract proposals geozones to a component 2023-06-19 11:15:37 +02:00
Senén Rodero Rodríguez
37695cd262 Add the geozone name to the proposal partial when there are geozones defined
As we have links pointing to a search by geozone name I
think we should show somewhere the geozone where the
proposal belongs.
2023-06-14 19:07:05 +02:00
Senén Rodero Rodríguez
1bc2a68856 Do not show the geozone selector where there are no geozones defined 2023-06-14 14:32:08 +02:00
Senén Rodero Rodríguez
9003c460d5 Do not render the geozone link where there are no geozones defined 2023-06-14 14:32:07 +02:00
Senén Rodero Rodríguez
a6b1866908 Allow to pass the destination link for the geozone link
Previous to this commit the geozone link shown in the
legislation proposal page was pointing to the proposals
process feature instead to the legislation proposals.
2023-06-14 14:31:44 +02:00
Senén Rodero
cf8a98f06b Merge pull request #5121 from consul/application_name_for_deployments
Allow to change the application name for deployments
2023-06-12 16:38:04 +02:00
taitus
78ee45630b Remove metadata from images
Currently in the application we never show the original image, we always
show one of its variants.

This change removes the metadata of both the variants and the original
version so that if at some point we decide to show the original version,
we will no longer have to remember to remove the metadata.
2023-06-12 14:30:00 +02:00
Senén Rodero Rodríguez
b3c294bb9a Convert geozone shared partial to a component 2023-06-12 13:57:45 +02:00
Senén Rodero Rodríguez
d7bc82a8ab Allow to change the application name for deployments
When someone installs CONSUL with the installer using
a custom `app_name`, the deployment configuration file
must use the same application name; otherwise, the
Capistrano task to update the crontab will duplicate the
crontab entries with different names causing unexpected
errors.

Below is an example of the issue. The first set of crontab
entries was created during installation using a custom
app_name. The second set of entries are duplicated
during the first deployment with a wrong application
name in the config/deploy.rb file.

```
deploy@ubuntu:~$ crontab -l
* * * * * /bin/bash -l -c 'date > ~/cron-test.txt'
0 5 * * * /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230529101753 && RAILS_ENV=production bundle exec rake -s sitemap:refresh --silent'
0 1 * * * /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230529101753 && RAILS_ENV=production bundle exec rake files:remove_old_cached_attachments --silent'
0 3 * * * /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230529101753 && RAILS_ENV=production bundle exec rake votes:reset_hot_score --silent'
0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230529101753 && RAILS_ENV=production bundle exec rake -s stats:generate --silent'
@reboot /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230529101753 && bundle exec puma -C config/puma/production.rb'
@reboot /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230529101753 && RAILS_ENV=production bin/delayed_job -n 2 restart'

* * * * * /bin/bash -l -c 'date > ~/cron-test.txt'
0 5 * * * /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230530112702 && RAILS_ENV=production bundle exec rake -s sitemap:refresh --silent'
0 1 * * * /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230530112702 && RAILS_ENV=production bundle exec rake files:remove_old_cached_attachments --silent'
0 3 * * * /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230530112702 && RAILS_ENV=production bundle exec rake votes:reset_hot_score --silent'
0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230530112702 && RAILS_ENV=production bundle exec rake -s stats:generate --silent'
@reboot /bin/bash -l -c 'cd /home/deploy/participacyl/releases/20230530112702 && bundle exec puma -C config/puma/production.rb'
```
2023-06-07 16:58:40 +02:00
Javi Martín
a480c5d545 Merge pull request #5123 from consul/fix-current-secrets
Fix cached tenant secrets when running tests
2023-06-06 14:50:08 +02:00
taitus
4de39918c2 Fix cached secrets when running tests
When running multiple specs that have to overwrite the rails secrets,
it can happen that the condition:
"@cached_rails_secrets != Rails.application.secrets"
is not met and unexpected secrets are returned.

We have found this case while experimenting with tests related to the
Tenant secrets. In one case, assigning cached rails secrets to nil resulted in
a failure to detect when the 'rails.application.secrets' had changed.
2023-06-05 19:53:15 +02:00
Senén Rodero
ae4cf319f6 Merge pull request #5119 from consul/airbrake_setup_for_errbit
Fix integration between `Errbit` and the `airbrake` gem
2023-06-05 17:07:24 +02:00
Javi Martín
1392733dbc Merge pull request #3907 from consul/polygon_geographies
Add polygon geographies to Budgets' map
2023-05-31 17:45:59 +02:00
Javi Martín
a9029be93d Include heading geozone in investments sidebar map
Note that, in this case, we aren't binding a popup to the polygon
because the link would point to the same page we're already in.
2023-05-31 16:56:15 +02:00
Matheus Miranda
de13e789dd Add polygon geographies to Budgets' map
Note that in the budgets wizard test we now create district with no
associated geozone, so the text "all city" will appear in the districts
table too, meaning we can't use `within "section", text: "All city" do`
anymore since it would result in an ambiguous match.

Co-Authored-By: Julian Herrero <microweb10@gmail.com>
Co-Authored-By: Javi Martín <javim@elretirao.net>
2023-05-31 16:56:15 +02:00
Javi Martín
d1f1e1dfea Add notices when creating and updating geozones
Just like we do in pretty much every section in the admin area.
2023-05-31 16:56:14 +02:00
Javi Martín
fb0caa3eda Remove obsolete check for the budget presence
This check isn't necessary since commit 7e3dd47d5, since now we check
that the budget is present before creating the components which call
this method.
2023-05-31 16:56:14 +02:00
Javi Martín
106dee0040 Remove redundant HTML map classes
The `map` class is applied to the map element by LeafletJS; using it in
the container led to hacks like adding an `inline` class to fix the fact
that the container was using the `height` rule of the `.map` elements.

Even though we don't add styles for them, I'm adding the `budgets-map`
and `budget-investments-map` HTML classes so these elements can still be
easily selected with CSS and JavaScript.
2023-05-31 16:56:12 +02:00
Javi Martín
727e849fd4 Move investments sidebar map view to a component
This way we remove some logic from the (huge) investments controller
class.
2023-05-29 17:46:04 +02:00