Commit Graph

18107 Commits

Author SHA1 Message Date
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
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
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
Javi Martín
60d52686b9 Remove text-center class in heading price header
Not sure why it was added in commit 9fb5019f0, but it made the table
look funny on some screens, particularly after adding the extra field
we're about to add.
2023-05-29 17:46:04 +02:00
Javi Martín
882cc85532 Move geozones index view to a component
This way we simplify the header and it will be easier to add more code
and tests.
2023-05-29 17:46:04 +02:00
Javi Martín
ca013cf9f1 Move budget headings form partial to a component
This way it'll be easier to test it.
2023-05-29 17:46:04 +02:00
Javi Martín
c6c09074df Move geozone form partial to a component
That way it'll be easier to refactor it.
2023-05-29 17:46:04 +02:00
Sebastia
1462ae72a8 Merge pull request #4854 from iraline/activation_status
Show account activation status for each user in the admin section
2023-05-29 16:50:40 +02:00
Iraline
2dc32c6bc1 Add new column to show activation status 2023-05-29 16:06:51 +02:00
Sebastia
0c1e860760 Merge pull request #5115 from consul/remove-unused-field
Remove unused field and related code
2023-05-29 16:00:09 +02:00
taitus
0d937647af Remove the unused field from the database.
In the PR #1140 this field was added in commit ad697cd2c1, but in this same
PR in commit 28d12fe55 all the related functionality that had been added was
removed but the field was not removed.
2023-05-29 15:12:40 +02:00
taitus
2425d0ecfc Remove unused code
In the commit: 315c57929a this code was added, but at that time this field
was no longer in use, even though it existed in the database.

I don't know why this line was added, but there seems to be no point in
keeping it.
2023-05-29 15:11:38 +02:00
Senén Rodero Rodríguez
b85df50a28 Configure airbrake as Errbit documentation says
Quoting `errbit/errbit/blob/main/app/views/apps/_configuration_instructions.html.erb`

> airbrake.io supports various features that are out of scope for Errbit.
2023-05-29 13:50:33 +02:00
Sebastia
0b7dfb2172 Merge pull request #5114 from consul/bump-wkhtmltopdf-binary
Bump wkhtmltopdf-binary from 0.12.6.5 to 0.12.6.6
2023-05-29 09:29:35 +02:00
Sebastia
d655acc2b6 Merge pull request #5117 from consul/update-spec
Update spec
2023-05-24 11:19:17 +02:00
taitus
81b7f30c8a Update spec
Configure the database before starting the browser with a call to `visit`
2023-05-24 10:25:59 +02:00
Senén Rodero
c52d28788a Merge pull request #5113 from consul/proposals_notifications
Show email digest only if proposals are enabled
2023-05-23 11:35:31 +02:00
taitus
26a158f3ba Update wkhtmltopdf-binary gem
In order to add compatibility to ubuntu 22.04 we update the
wkhtmltopdf-binary gem.  The gem version 0.12.6.5 only
supports up to ubuntu 20.04.
2023-05-22 10:51:25 +02:00
decabeza
e51f240736 Show email digest only if proposals are enabled 2023-05-19 12:41:56 +02:00
Javi Martín
287f483f4e Merge pull request #5111 from consul/remove_marker_accessibility
Use a button instead of a link to remove a marker
2023-05-05 15:23:36 +02:00
Javi Martín
0ef1882a9d Merge pull request #5108 from consul/map_refactoring
Simplify the code rendering the map
2023-05-05 15:21:49 +02:00
Javi Martín
8b14522bf5 Use a button instead of a link to remove a marker
Using a button for interactive elements is better, as explained in
commit 5311daadf.

Since buttons with "type=button" do nothing by default, we no longer
need to call `preventDefault()` when clicking it.
2023-05-04 15:32:33 +02:00
Javi Martín
59ed975f81 Set remove marker link margin-bottom in CSS
We were setting the margin-top property in CSS but the margin-bottom
property by adding a div with a `.margin-bottom` HTML class.
2023-05-04 15:32:33 +02:00
Javi Martín
a145fdb8a8 Make map location HTML class names consistent
We were using `map_location` in one place and
`location-map-remove-marker` in another one. We usually use dashes in
HTML class names, we don't say "location map" anywhere else.
2023-05-04 15:32:33 +02:00
Javi Martín
f4ef6412b6 Remove unused HTML class in link to remove marker
It isn't used since commit c34aa5412.
2023-05-04 15:32:33 +02:00
Javi Martín
b0680628ba Extract function to add investment markers 2023-05-04 15:27:15 +02:00
Javi Martín
21ce7689c2 Don't overwrite marker when creating investment markers
The `marker` variable is like a global variable inside the
`initializeMap` function, so assigning it inside the `createMarker`
function was changing its value in other places.

So we're using different variable names like `newMarker` in order to
make the code easier to follow. Now we "only" change the `marker`
variable in functions that modify the marker.
2023-05-04 15:27:15 +02:00
Javi Martín
74d165ae7a Extract function to create a map 2023-05-04 15:27:15 +02:00
Javi Martín
2e8bc11c2a Extract functions to update map form fields 2023-05-04 15:27:15 +02:00
Javi Martín
f8053c9532 Extract function to get popup in map JavaScript 2023-05-04 15:27:15 +02:00
Javi Martín
4087066c59 Extract function to add map attribution 2023-05-04 15:27:15 +02:00
Javi Martín
00cd91c6b2 Extract functions to get coordinates in map JS
We had 130 lines long function, and we're trying to reduce its size so
it's easier to follow the code.
2023-05-04 15:27:15 +02:00
Javi Martín
e75211125a Remove duplicate i18n text to remove marker
We had two different keys with the same text and were passing it as a
parameter. Since the text is the same in any case, we don't need a
parameter for it.

Note we are using the `proposals` i18n key instead of creating a new one
in a `shared` namespace one because creating a new key would mean that
we'd lose the already existing translations in Crowdin.
2023-05-04 15:27:15 +02:00
Javi Martín
c667582c98 Remove redundant value assignments in map fields
Rails forms automatically take the value from the object related to the
form.
2023-05-04 15:27:15 +02:00
Javi Martín
b9518d64e1 Use Rails methods to get map location input IDs
We were manually generating the IDs in order to pass them as data
attributes in the HTML in a component where we don't have access to the
form which has the inputs.

However, these data attributes only make sense when there's a form
present, so we can pass the form as a parameter and use it to get the
IDs.

We can now define a map as editable when there's an associated form,
which makes sense IMHO.
2023-05-04 15:27:15 +02:00
Javi Martín
84fff2e9fb Simplify code setting marker data in maps
We were probably setting them separately to avoid having blank data
attributes in the HTML. However, when a data attribute is `nil`, Rails
doesn't write it in the HTML in the first place.
2023-05-04 15:27:15 +02:00
Javi Martín
e00aa807b9 Make remove marker label parameter optional
We were passing `nil` in some calls, which was confusing.

Since now we've got two optional parameters, we're using named
parameters.
2023-05-04 15:27:15 +02:00
Javi Martín
aa5f5235de Simplify creating a map location from a heading 2023-05-04 15:27:15 +02:00
Javi Martín
deb965bcce Remove editable parameter in render_map
The calls to `render_map` are confusing since there are so many
parameters. We can assume that the map is editable if we pass the remove
marker label.
2023-05-04 15:27:15 +02:00