Commit Graph

17301 Commits

Author SHA1 Message Date
Senén Rodero Rodríguez
9dae396323 Fix some source strings typos
A translator warned some typos through Crowdin. Thanks `chkoun`.
2021-10-14 13:20:41 +02:00
Javi Martín
7243ace903 Improve performance when editing custom texts
We were executing SQL queries searching for translations even for
records which were not persisted in the database and therefore had no
translations.

So we're now only looking for translations when the record is persisted.

Note that, when the record isn't persisted, we're using `I18n.translate`
instead of the `t` method. That's because the `t` method would also
perform database queries since we overwrite the `t` method in the
`i18n_translation` initializer.

On tabs with many records, like the proposals tab, requests are now up
to three times faster on production environments.

Tests related to this part of the application were failing sometimes
because requests took longer than `Capybara.default_max_wait_time`.
After these changes, the custom information texts pages load about 30%
faster when running the tests.
2021-10-11 20:03:07 +02:00
Javi Martín
c7230e668f Refactor method to get custom texts translations
It was a bit confusing to return `false` in the method and then handle
this case in the view.
2021-10-11 20:03:07 +02:00
Javi Martín
b35c8bda4b Move form field partial to a component
This way it's easier to test; changing it will also be easier.

During my experiments I made a mistake which wasn't covered by the test
suite. We're adding a test for this case.

Note we're using `i18n_content` in the component instead of `content`
because there's already a `content` method provided by ViewComponent.
2021-10-11 20:03:07 +02:00
Sebastia
ced55a58f8 Merge pull request #4708 from consul/confirmation-instructions
Fix sending OAuth confirmation instructions
2021-10-11 13:57:07 +02:00
Javi Martín
1a54659dd7 Merge pull request #4693 from consul/delayed_errbit
Include DelayedJob errors in Errbit exceptions
2021-10-11 13:33:29 +02:00
taitus
0493893ab8 Fix send confirmation instructions on do_finish_signup action
When we try to register with omniauth and the email or username already exists,
we use the finish_signup and do_finish_signup actions to allow the user to choose
another email or username.

The do_finish_signup action of the registration controller calls the
send_oauth_confirmation_instructions method which is responsible for sending the
confirmation email.

In this method we were only validating the case that the email is duplicated. Now
we add one more condition that allows us to send the instructions for the case in
which we have had to change our username.
2021-10-11 12:28:51 +02:00
taitus
ba4595f6ce Use the label text in the specs
Using the label text in the specs is superior to using the name because it tests the label is correctly associated to its form control.
2021-10-11 12:27:18 +02:00
Javi Martín
9f21c27bf1 Include DelayedJob errors in Errbit exceptions
The integration between Airbrake/Errbit and DelayedJob wasn't working
because we require our dependencies in alphabetic order, and so by the
time `airbrake` was required, `delayed_job` wasn't loaded.

So we're manually requiring the integration.
2021-10-08 23:09:27 +02:00
Javi Martín
16fdb94255 Merge pull request #4649 from consul/dependabot/bundler/master/omniauth-google-oauth2-and-omniauth-rails_csrf_protection-and-omniauth-1.0.0
Bump omniauth-google-oauth2, omniauth-rails_csrf_protection and omniauth
2021-10-08 16:44:23 +02:00
dependabot[bot]
376fa684d9 Bump omniauth-google-oauth2, omniauth-rails_csrf_protection and omniauth
Bumps [omniauth-google-oauth2](https://github.com/zquestz/omniauth-google-oauth2), [omniauth-rails_csrf_protection](https://github.com/cookpad/omniauth-rails_csrf_protection) and [omniauth](https://github.com/omniauth/omniauth). These dependencies needed to be updated together.

Updates `omniauth-google-oauth2` from 0.8.2 to 1.0.0
- [Release notes](https://github.com/zquestz/omniauth-google-oauth2/releases)
- [Changelog](https://github.com/zquestz/omniauth-google-oauth2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zquestz/omniauth-google-oauth2/compare/v0.8.2...v1.0.0)

Updates `omniauth-rails_csrf_protection` from 0.1.2 to 1.0.0
- [Release notes](https://github.com/cookpad/omniauth-rails_csrf_protection/releases)
- [Commits](https://github.com/cookpad/omniauth-rails_csrf_protection/compare/v0.1.2...v1.0.0)

Updates `omniauth` from 1.9.1 to 2.0.4
- [Release notes](https://github.com/omniauth/omniauth/releases)
- [Commits](https://github.com/omniauth/omniauth/compare/v1.9.1...v2.0.4)

---
updated-dependencies:
- dependency-name: omniauth-google-oauth2
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: omniauth-rails_csrf_protection
  dependency-type: direct:production
  update-type: version-update:semver-major
- dependency-name: omniauth
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-08 01:10:47 +02:00
Javi Martín
a0c7856d33 Merge pull request #4657 from consul/dependabot/bundler/master/airbrake-11.0.3
Bump airbrake from 7.4.0 to 11.0.3
2021-10-08 01:10:04 +02:00
dependabot[bot]
838e5a50be Bump airbrake from 7.4.0 to 11.0.3
Note we're using `config.performance_stats = false` because enabling it
was causing a huge performance hit; pages were about 2-4 times slower
and some tests failed since requests took longer than Capybara's default
max wait time. Errbit also recommends disabling this option since
Errbit doesn't handle performance stats.

Bumps [airbrake](https://github.com/airbrake/airbrake) from 7.4.0 to 11.0.3.
- [Release notes](https://github.com/airbrake/airbrake/releases)
- [Changelog](https://github.com/airbrake/airbrake/blob/master/CHANGELOG.md)
- [Commits](https://github.com/airbrake/airbrake/compare/v7.4.0...v11.0.3)

---
updated-dependencies:
- dependency-name: airbrake
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-07 04:12:23 +02:00
Javi Martín
4e3f24faf4 Merge pull request #4694 from consul/question_image
Show answers with attachments in additional info
2021-10-06 17:16:45 +02:00
Javi Martín
6d26ce57cb Show answers with attachments in additional info
We weren't showing the details of answers without a description, even if
they had images, videos or documents. Some users found that behavior
unexpected since the description isn't a mandatory field and so they
left it blank, but they added images to that answer and they didn't
appear on the poll page.

Note we had a condition not to show the title of an answer when it had
no description. I think that condition was redundant because answers
without a description weren't loaded in the first place. Anyway, that
condition doesn't make sense anymore because we're displaying answers
with images but no description.
2021-10-06 16:52:23 +02:00
Javi Martín
25465e71ea Merge pull request #4692 from consul/globalize_length
Simplify displaying debate length validation error
2021-10-06 16:49:09 +02:00
Javi Martín
b1c07862b4 Merge pull request #4689 from consul/ie_heading_mode
Fix budget mode selection in Internet Explorer 11
2021-10-06 15:59:16 +02:00
Javi Martín
24d1bd33fb Merge pull request #4671 from consul/gitkeep
Fix .keep file in custom stylesheets.
2021-10-06 15:38:58 +02:00
Javi Martín
4631633adf Simplify displaying debate length validation error
Adding the error to the translation means Rails will automatically show
the error message in the view.

We're also adding a test to make sure the error message is correctly
displayed.

We now have duplication in the validation rules, however. Validating
translatable attributes is still a bit of mess.
2021-10-06 14:46:30 +02:00
Javi Martín
0652d3f52d Fix budget mode selection in Internet Explorer 11
As mentioned in commit b7f6c4c43:

> [In Internet Explorer] the `flex: 1` property doesn't work so well
> when `flex-direction` is set to `column`. We're replacing it with
> `flex-grow: 1`. No need to set other `flex-basis` nor `flex-shrink`
> since in this case the default values will work just fine.
2021-10-06 14:46:08 +02:00
Javi Martín
081b524e03 Fix .keep file in custom stylesheets.
It was accidentally named `.gitkeep` in commit b549eb444. We use `.keep`
everywhere else.
2021-10-06 14:45:51 +02:00
Javi Martín
e11dcf3868 Merge pull request #4670 from consul/remove_simulation_task
Remove unused dashboard tasks
2021-10-06 14:39:56 +02:00
Javi Martín
480bb8cd55 Remove link column in dashboard actions
This column wasn't used in any released Consul version since it was only
used during development. For the same reason, the task to migrate the
information in the `link` column to the `links` table isn't needed
either.
2021-10-06 14:13:44 +02:00
Javi Martín
af8b01c7dc Remove unused dashboard task
It was never used and its data is based on Madrid's requirements for
successful proposals. It was written during the development of the
dashboard, probably for testing purposes.
2021-10-06 14:12:06 +02:00
Javi Martín
67a4ecfdac Merge pull request #4678 from consul/remove_1.3_tasks
Remove tasks to upgrade to version 1.3.0
2021-10-06 14:11:31 +02:00
Javi Martín
a187641f79 Merge pull request #4677 from consul/officing_js_specs
Make officing specs detect bugs in the menu links
2021-10-06 14:08:33 +02:00
Javi Martín
b97da02f98 Remove code to rename already renamed setting
It was already renamed in version 1.1.0.
2021-10-06 13:51:56 +02:00
Javi Martín
1b2256e084 Remove tasks to upgrade to version 1.3.0
These tasks are not needed for new installations, and in existing
installations they've already been executed when upgrading to version
1.3.0.
2021-10-06 13:51:56 +02:00
Javi Martín
d041d06809 Make officing specs detect bugs in the menu links
In commit baaec3a29 we started using the JavaScript driver in tests
dealing with the user menu, and made all tests pass.

However, we didn't update some officing tests that were also passing
when there was a bug in the code. That's because now that these tests
use a JavaScript driver, the link to "Polling officers" is never present
before pressing the "Menu" item. So tests checking the link isn't
present when loading the page always pass.
2021-10-06 13:48:03 +02:00
Javi Martín
0cdddc3647 Merge pull request #4691 from consul/private_following
Hide what users are following unless they allow it
2021-10-05 15:02:56 +02:00
Javi Martín
5c1a7044cd Hide comments when features are disabled
We were already doing so for debates and investments.

We probably never noticed because this is an edge case that requires
enabling a feature, people adding comments, and then disabling the
feature.
2021-10-05 14:43:47 +02:00
Javi Martín
af53b2159c Refactor code getting a user's comments
This way it's more readable and easier to change.
2021-10-05 14:43:47 +02:00
Javi Martín
3cd4f3827e Hide what users are following unless they allow it
It could be argued that seeing which proposals a user follows is a good
indicator of which proposals a user has supported, since we're
automatically creating follows for supported proposals since commit
74fbde09f. So now, we're extending the `public_interests` funcionality,
so it only shows elements users are following if they've enabled it.

This is an improvement over using the `public_activity` attribute in two
ways:

* The `public_interests` attribute is disabled by default, so by default
  other users won't be able to see what a user is following
* Who has created proposals/debates/investments/comments is public
  information, while who is following which elements is not; so enabling
  `public_activity` shouldn't imply potentially private information should
  be displayed as well

We've considered removing the `public_interests` attribute completely
and just hiding the "following" page for everyone except its owner, but
keeping it provides more compatibility with existing installations.
2021-10-05 14:43:09 +02:00
Javi Martín
0875c214ba Make following tab tests easier to understand
The `click_link` part did nothing other than scrolling to the element,
since in these cases we've got a same-page link and the element it links
to is already on the page. Programmers reading the test would expect the
link to load the page or change to a different tab and would think the
element it links to wasn't there before clicking the link (at least I
did).
2021-10-05 14:40:47 +02:00
Javi Martín
9bc529dce1 Group almost identical public interests tests 2021-10-05 14:40:47 +02:00
Javi Martín
64258baf97 Refactor getting the public activity information
We had similar conditions many times and some duplication, particularly
between the code getting records and the code counting records. We can
remove it by returning a generic scope and calling the `count` method to
count the records and the `order` and `page` methods when we want to
pass the records to the view. And, since we only display one partial per
request, we can simplify the code to render all the partials. There's
one minor disadvantage to this approach: searching the code for the
place where these partials are rendered is now a bit harder since
searching the code for something like "render (.+) budget_investments"
won't return any results.

We're also writing conditions about a certain filter just once, by
setting `valid_filters`. This greatly simplifies the logic, although
again there's one minor disadvantage: we have to implement the
`current_filter` method, duplicating the logic already defined in the
`HasFilters` concern.
2021-10-05 14:40:36 +02:00
Javi Martín
62b23f1e56 Extract component to show a user's public activity 2021-10-05 13:26:30 +02:00
Javi Martín
67a13d5fea Use local variables in user profile partials
This way we'll be able to render the partials from places like a
component.
2021-10-05 13:26:30 +02:00
Javi Martín
274abaf290 Remove unused method in users controller
It isn't used since commit fc57bad1c.
2021-10-05 13:26:30 +02:00
Javi Martín
adaa9c021f Merge pull request #4683 from consul/empty_sdg_tags
Don't render empty SDG tag list div
2021-10-04 16:07:28 +02:00
Javi Martín
3a84defce3 Merge pull request #4672 from consul/sdg_target_titles
Add short titles to SDG targets
2021-10-04 16:01:01 +02:00
Javi Martín
2cdfbbe027 Merge pull request #4705 from consul/dependabot/bundler/nokogiri-1.12.5
Bump nokogiri from 1.12.3 to 1.12.5
2021-10-01 22:11:19 +02:00
Javi Martín
b2dd6bcc16 Remove placeholder in SDG related list
Its value is difficult to read due to the low contrast between the color
of the field and the color of the placeholder text, and we already have
the same information in the hint above it.
2021-10-01 16:19:21 +02:00
Javi Martín
c025fef50b Add short titles to SDG targets
Since targets didn't have a title but only a long description, every
form allowing to select targets was pretty much unusable: we either
displayed just the code or the whole description.

Now, with a concise title, it's easier to find and select the desired
target.

The titles have been copied from The Global Goals page [1].

Note we're using the `short_title` I18n key for the `title` method and
the `long_title` I18n key for the `long_title` method. We can't use
`title` as I18n key instead of `short_title` because it would affect
existing translations.

[1] https://www.globalgoals.org/
2021-10-01 16:19:10 +02:00
Javi Martín
391d1083e4 Don't render empty SDG tag list div
The same way we don't render empty regular tags since commit 4d27bbeba.

This way we avoid adding an empty `<div class="sdg-tag-list">` tag,
which might have associated styles (in custom CONSUL installation
styles, for instance) and thus break the layout
2021-10-01 13:54:30 +02:00
Javi Martín
7f9a05d052 Extract method to get SDG code with title 2021-09-30 16:05:57 +02:00
Javi Martín
ead5aa5c31 Merge pull request #4675 from consul/sdg_svg_en
Add SDG icons in SVG format
2021-09-30 16:05:31 +02:00
Javi Martín
e20e468c0f Use sans-serif fonts as fallbacks for SDG titles
This way titles look a little less broken during the time the font is
downloaded.
2021-09-30 15:06:50 +02:00
Javi Martín
c42c8e3c7a Increase minimum size for SDG icons
The icons were a bit hard to click on small screens, even for people
without any motion disabilities.

We might increase the size or the space between icons again in the
future; right now it's hard for users with certain motion disabilities
to click on the right icon.

Coincidentally, the minimum size of the icon is now barely over the 44px
established as minimum required size by the WCAG guideline 2.5.5 (level
AAA) [1].

Also coincidentally, at a screen 320px wide (the minimum screen size we
support), six icons appear on each row, just like in the UN logo.

[1] https://www.w3.org/TR/WCAG21/#target-size
2021-09-30 15:06:50 +02:00
Javi Martín
159a17f16f Add SDG Italian, Greek and Dutch SVG icons
These icons have been converted from EPS pages found at their respective
language UNRIC sites [1, 2, 3].

Since SVG icons are smaller and can be compressed, users browsing the
page in these languages will have to download way less data for the SDG
icons than when using PNGs. Users browsing the web in Italian will have
to download about 70KB for the SDG icons instead of the 575KB. Users
browsing the page in Greek will have to download about 75KB for the SDG
icons instead of 720KB. And users browsing the web in Dutch will have to
download about 115KB for the SDG icons instead of 230KB.

[1] https://unric.org/it/agenda-2030/
[2] https://unric.org/el/17-στοχοι-βιωσιμησ-αναπτυξησ/
[3] https://unric.org/nl/duurzame-ontwikkelingsdoelstellingen/
2021-09-30 15:06:50 +02:00