Commit Graph

17301 Commits

Author SHA1 Message Date
Javi Martín
35e0477e03 Ignore trailing spaces in postal codes verification
This way both administrators and regular citizens have a certain margin
of error when entering the postal codes.
2021-12-16 13:57:00 +01:00
Javi Martín
5cc10cbadf Allow dashes in postal codes
In some countries, postal codes are defined with a dash in the middle,
so we're using a colon to define ranges instead. We could also use two
dots, like in Ruby ranges, but IMHO this would cause typos since people
would enter codes separated with three dots or just one dot.
2021-12-16 13:57:00 +01:00
Javi Martín
b8b4336266 Compare postal codes with strings and not integers
We can now get rid of the rule forcing a length of 5 digits, which
doesn't apply to all countries.
2021-12-16 13:57:00 +01:00
Javi Martín
edc56b1e1f Avoid using eval in postal code validation
We were getting a warning by Rubocop because we were using eval with a
string defined by administrators, which in theory could be dangerous.
2021-12-16 13:57:00 +01:00
Javi Martín
006269a94b Simplify tests validating postal codes
We weren't using the `be_valid` matcher because we had errors in the
census data.

Removing the `before_validation` callback and using a method to get the
census data instead allows us to stub the `census_data` method in the
tests, and so we can use the `be_valid` matcher instead of calling
`valid?` manually and then checking for errors.
2021-12-16 13:57:00 +01:00
Laura Concepción Rodríguez
f4512b2117 Redefine postal code verification methods to use setting config parameter 2021-12-16 13:57:00 +01:00
Javi Martín
bcce43fd0f Merge pull request #4643 from consul/phone_number_field
Use telephone fields in phone number form controls
2021-12-16 13:48:53 +01:00
Javi Martín
ae91361edb Use telephone fields in phone number form controls
Using a field with `type="tel"` causes most mobile phone browsers to
show a numeric keyboard which makes it easy to enter phone numbers.

We aren't using a number field because some browsers show "spinners" to
increment/decrement numbers (which doesn't make much sense in a phone
number) and because they don't allow characters like spaces. Phone
numbers can have characters like spaces, dashes, parenthesis, asterisks,
the plus sign, ...

Since phone number formats vary depending on the region, and sometimes
even within the same region several different formats can be used, for
now we aren't offering any kind of format validation. We could offer a
format validation that rejects just letters (although there are cases
where letters are actually allowed). However, this causes issues at both
the server side and the client side.

We could use a client-side validation adding a `pattern` attribute to
the field, but that would be something unlike anything else we use in
the application, and we would need to to write some JavaScript in order
to use a proper error message.

On the other hand, if we add a server-side validation, we might find out
existing users are invalid, and it would be impossible to update them in
the many places where we update users assuming they were valid in the
first place. We'd have to add a rake task to update existing user
records and make sure they contain a valid phone number or create a
setting so this validation only applies to new CONSUL installations.
Another option would be to add a per-form validation, so the phone
number is only validated in pages where it is introduced.

All the mentioned scenarios offer certain complexities. So, for now,
we're keeping things simple.

Co-Authored-By: decabeza <alberto@decabeza.es>
2021-12-16 13:24:26 +01:00
Javi Martín
ff0855f0fe Merge pull request #4734 from consul/manager_header
Make management and admin headers consistent
2021-12-15 14:15:29 +01:00
Javi Martín
519a34b1f8 Use the admin header in the management section
Now that we also have the "go back to CONSUL" link, the layouts are so
similar that it isn't worth it maintaining both of them separately.

With this change, people using small screens also get the "menu" button
in the management section, just like they do everywhere else.

We're adding the `namespace != "management"` condition so the menu still
shows up in the officing namespace.
2021-12-15 13:53:56 +01:00
Pierre Mesure
228a1d9090 Add missing link and button on management interface 2021-12-15 12:47:01 +01:00
Javi Martín
031ec8fce1 Merge pull request #4733 from consul/dev_seeds_without_english
Make dev seeds independent on available locales
2021-12-14 20:28:08 +01:00
Javi Martín
d59d9aac3b Check missing/unused translations in seeds.yml
We were making some typos during development in the name of the keys and
tests were still passing.

We're also removing some texts that were never used.
2021-12-14 20:10:35 +01:00
Javi Martín
b90cf572fe Fix typos in dev seeds texts 2021-12-14 20:10:35 +01:00
Javi Martín
490fe5fd11 Make dev seeds independent on available locales
Some developers work on CONSUL installations where Spanish and/or
English aren't part of the available locales. In those cases, the
`dev_seed` task was crashing because we were using attributes like
`name_en` and `name_es`.

So we're using attributes for random locales instead.

We're using a proc so we don't have code like this all over the place:

random_locales.map do |locale|
  I18n.with_locale(locale) do
    phase.name = I18n.t("budgets.phase.#{phase.kind}")
    phase.save!
  end
end

This would make the code harder to read and would execute a `save!` once
per locale, which would make the task much slower.

We could also avoid the procs writing something like:

def random_locales_attributes(**attribute_names_with_values)
  random_locales.each_with_object({}) do |locale, attributes|
    I18n.with_locale(locale) do
      attribute_names_with_values.each do |attribute_name, (i18n_key, i18n_args)|
        value = I18n.t(i18n_key, (i18n_args || {}).merge(language: I18n.t("i18n.language.name")))
        attributes["#{attribute_name}_#{locale.to_s.underscore}"] = value
      end
    end
  end
end

And calling the method with with:

random_locales_attributes(name: ["seeds.budgets.name", year: Date.current.year - 1])

However, this code would also be different that what we usually do, we'd
have to apply some magic to pass the `language:` parameter, and the
strings wouldn't be recognized by i18n-tasks, so we aren't sure we're
really gaining anything.
2021-12-14 20:05:07 +01:00
Javi Martín
e9d7d2744d Simplify code in budget dev seeds
Now changing the code dealing with locales is going to be easier.
2021-12-13 15:15:28 +01:00
Javi Martín
30b9176382 Use default budget phases names in dev seeds
So it's easier to differentiate between them during development.
2021-12-13 15:15:28 +01:00
Javi Martín
9514ece2c2 Prioritize English and Spanish in dev seeds
These locales are officially maintained by CONSUL developers, so we're
using them when available.

This way we'll be able to use `random_locales` in places where we're
manually using English and Spanish, giving support to other locales
while maintaining compatibility with the current version.
2021-12-13 15:15:28 +01:00
Javi Martín
dd28ea7713 Don't enforce available locales in dev seeds
We're using Faker during this task, and it depends on English being
available as a fallback for methods like the Lorem ipsum ones.
2021-12-13 15:15:28 +01:00
Javi Martín
980558c9d2 Merge pull request #4752 from consul/remove_incomplete_text
Remove broken technical assistance text in footer
2021-12-13 14:16:45 +01:00
Javi Martín
baedac8839 Remove broken technical assistance text in footer
Originally there was a link pointing to the FAQ page but it was removed
in commit e14b7b67fb because by default the FAQ page in CONSUL only
contains a placeholder text.

We aren't sure where this link should point:

* FAQ page, only if the FAQ page is published
* Help page, only when the help feature is enabled
* CONSUL technical documentation page

So, for now, we're choosing the easiest solution which is removing the
text completely.
2021-12-13 13:30:24 +01:00
Javi Martín
3b12ff0b81 Merge pull request #4750 from consul/legislation_comment_email
Fix comment notifications on legislation proposals
2021-12-13 13:29:40 +01:00
Javi Martín
d2d79b9926 Merge pull request #4645 from consul/remove_newrelic
Remove newrelic and rollbar gem dependencies
2021-12-08 16:15:11 +01:00
Javi Martín
0349f0b1a3 Remove obsolete comments in Gemfile_custom
The CUSTOMIZE files don't exist anymore.
2021-12-08 15:56:17 +01:00
Javi Martín
b544ec8988 Remove rollbar gem dependency
We already support Errbit and Airbrake as error monitoring services.
Since some people might not want to setup Errbit and might prefer
Rollbar over Airbrake, we're referencing it in the custom gemfile.
2021-12-08 15:56:17 +01:00
Javi Martín
dc44dda30c Remove newrelic gem dependency
We haven't updated the gem for years and don't know whether it
still works with our current Ruby and Rails versions.

Besides, dependabot keeps opening pull requests to update it. In theory
we could just ignore the dependabot pull requests for this dependency,
but unfortunately right now we can't add a dependabot config file
because it would open pull requests on forks as well.

Finally, there are other companies offering similar services for Rails
applications, and it's up to each CONSUL installation to decide which
one is better for them. We might add a self-hosted performance
monitoring tool in the future.

Since other CONSUL installations might be using Newrelic, and in general
we recommend adding an application monitoring tool, we're suggesting it
in the custom gemfile. In the name of neutrality, we're also adding
Sentry. We might add other services in the future.
2021-12-08 15:56:09 +01:00
Javi Martín
735f99f877 Fix comment notifications on legislation proposals
The `commentable_url` method wasn't updated when we added legislation
proposals.

Back when we first created this method, we couldn't pass budget
investments or topics directly to `polymorphic_url` because they are
nested resources. That isn't the case since commit ff93f5a59, so now we
can simplify this method.

We're keeping the `commentable_url` method for now in order to keep
compatibility with custom changes that might use it, although this
method isn't consistent with the `commentable_path` method (which
receives a comment, and not a commentable), and so we might have to
revisit this code in the future.
2021-11-29 16:16:15 +01:00
Sebastia
51da643f2a Merge pull request #4749 from consul/release_1.4.1
Release version 1.4.1
2021-11-25 14:25:24 +01:00
Senén Rodero
ca5a718326 Merge pull request #4748 from consul/crowdin_integration
Change the way we handle source strings updates
2021-11-25 13:42:57 +01:00
Senén Rodero
5485aef670 Merge pull request #4747 from consul/i18n_master
New Crowdin updates
2021-11-25 13:41:12 +01:00
taitus
70b19cb290 Release version 1.4.1 2021-11-25 13:13:45 +01:00
Senén Rodero Rodríguez
30a0235ea3 Change the way we handle source strings updates
With the `update_without_changes`, previous translations are kept
even when the source string changed utterly. Using this option caused
some problems when updating source language strings, as the
translators do not get any notification, and the old translation keeps
approved, so translators do not have an easy way to find those strings
in Crowdin.

With the `update_as_unapproved` option, translators and Crowdin
managers can find those translations that need to be updated by
searching among not approved translations.

Quoting Crowdin's docs [1]:

> update_without_changes - preserve translations and validations of
   changed strings
> update_as_unapproved - preserve translations of changed strings
   and remove validations of those translations if they exist

[1] https://support.crowdin.com/configuration-file/#changed-strings-update
2021-11-25 12:06:14 +01:00
Consul Bot
aea5cf46a9 New translations admin.yml (Turkish) 2021-11-25 11:23:13 +01:00
Consul Bot
e54cc6206d New translations admin.yml (Swedish) 2021-11-25 11:23:12 +01:00
Consul Bot
c1b85a7704 New translations admin.yml (Italian) 2021-11-25 11:23:09 +01:00
Consul Bot
799eba8733 New translations admin.yml (German) 2021-11-25 11:23:08 +01:00
Consul Bot
e1dab4b016 New translations admin.yml (Romanian) 2021-11-25 11:14:59 +01:00
Javi Martín
b9ccfcf0ae Merge pull request #4720 from consul/release_1.4.0
Release version 1.4.0
2021-11-24 14:47:14 +01:00
Javi Martín
8ccadde131 Release version 1.4.0 2021-11-23 17:57:58 +01:00
Javi Martín
0f136d65f0 Update help wanted links to include pull requests
There are some pull requests where we also want help.
2021-11-23 17:57:58 +01:00
Javi Martín
a1785b0621 Remove note about Semantic Versioning
We don't have a public API, so this system doesn't apply to us.
2021-11-23 17:57:58 +01:00
Senén Rodero
cd376f90fb Merge pull request #4745 from consul/spanish_translation
Fix user edit page title
2021-11-23 17:47:32 +01:00
Senén Rodero
d6673475f3 Merge pull request #4743 from consul/i18n_crowdin
Update translations from Crowdin
2021-11-23 17:47:17 +01:00
Senén Rodero Rodríguez
a52517a9f7 Fix user edit page title
The error is only present at the Spanish language.
2021-11-23 16:55:42 +01:00
Senén Rodero Rodríguez
fff30e0a1c Update translations from Crowdin 2021-11-23 13:56:53 +01:00
Senén Rodero
64fc2a836a Merge pull request #4738 from consul/i18n_crowdin
Update translations from Crowdin
2021-11-19 16:12:39 +01:00
Javi Martín
43994e054c Merge pull request #4741 from consul/track_invalid_id_spec
Query the database before a visit in campaigns test
2021-11-19 13:00:00 +01:00
Javi Martín
e9abb153d6 Merge pull request #4739 from consul/investment_filters_visibility
Make investment filters less prominent
2021-11-19 12:58:24 +01:00
Javi Martín
006128da57 Query the database before a visit in campaigns test
This test was failing sometimes. One possible cause (although it might
not be the only one) is we were querying the database with
`Campaing.last` after starting the process running the browser with a
`visit`. In the past doing so has resulted in database inconsistencies
while running the tests.

Since after running the test more than 1500 times we weren't able to
reproduce the failure, it's possible that this change doesn't fix the
issue which caused the test to fail, but in the worst case scenario we
reduce the number of possible reasons why it fails.
2021-11-18 15:04:22 +01:00
Senén Rodero
f64377ad5a Merge pull request #4740 from consul/flake
Fix flaky spec in campaign-tracking tests
2021-11-18 10:15:07 +01:00