Commit Graph

429 Commits

Author SHA1 Message Date
Javi Martín
4f5de5be3b Add aria-describedby attribute automatically
We were manually adding the attribute in many places, but not
everywhere. I'm assuming adding it where we didn't have it is doing no
harm.
2019-10-06 19:32:03 +02:00
Javi Martín
4a19bb6b77 Simplify generating fields with hints
We were already using this code in translatable forms. Using it on every
form means we can reduce the code we need to generate a field with a
hint.
2019-10-06 18:03:38 +02:00
Javi Martín
ae6fab9f5e Inherit from builder instead of monkey patching it
We were monkey-patching FoundationRailsHelper::Formbuilder, which made
form customization difficult. We can inherit from it, which is the
standard way of extending what an existing class does, and make our form
the default one.
2019-10-05 16:01:58 +02:00
Javi Martín
871fa020a5 Add and apply ParenthesesAsGroupedExpression rule 2019-10-05 15:03:26 +02:00
Javi Martín
93a2ebd46f Add and apply DuplicateMethods rubocop rule
These methods were defined with `attr_reader` (or accessor in some
cases) and then they were redefined.
2019-10-05 15:03:26 +02:00
voodoorai2000
71e6c5713a Add rake task to set the original_heading_id value
By default we want this attribute to be the current heading id for existing investments. If there have been reclassifications, this field should be updated accordingly.
2019-09-12 16:49:01 +02:00
Javier Martín
8670cafa2e Merge pull request #3611 from PierreMesure/adding-missing-subtasks-to-upgrade-task
Adding missing subtasks to upgrade task and adding info log
2019-09-11 21:26:45 +02:00
Javi Martín
d639cd587a Remove unnecessary uniq calls
The code `where(id: ids)` is equivalent to `where(id: ids.uniq)`.

Since Rails 5 uses `distinct` instead of `uniq` and in most cases where
we use `uniq` with `pluck` we should simply remove the `uniq` call (as
done in this commit), we're also removing the `Rails/UniqBeforePluck`
rubocop rule.
2019-09-10 22:27:33 +02:00
Javi Martín
a5ba13b599 Apply Rails/Presence rubocop rule 2019-09-10 21:43:38 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
488461b8ac Remove consecutive blank lines 2019-09-10 20:02:15 +02:00
Javi Martín
47b2c42a1d Apply IndentationConsistency rubocop rule 2019-09-10 20:02:15 +02:00
Javi Martín
e252d82cdb Apply IndentationWidth rubocop rule 2019-09-10 20:02:15 +02:00
Javi Martín
71d9ddd849 Apply rule to end files with a newline character 2019-09-10 20:02:15 +02:00
Javi Martín
53abc57578 Fix Infinity exceptions in hot score calculator
There was a rare case we've found on some Travis builds where the system
time suddenly moved back to the past a couple of tenths of a second,
meaning `Time.current - resource.created_at` returned a negative number,
which lead to a division by zero.
2019-09-10 16:00:21 +02:00
Javi Martín
852d3b0ed6 Extract methods to calculate hot score period 2019-09-10 16:00:21 +02:00
Javi Martín
a21240b230 Use Date.current and Time.current
Using Date.today and Time.now might lead to inconsistencies if the time
zone the application uses is not the same as the system time zone.
2019-08-28 20:32:40 +02:00
Javi Martín
d981e23cd7 Remove custom dashboard task
It was made for Madrid's repository, but was accidentally added to
CONSUL as well.
2019-08-07 20:37:02 +02:00
taitus
292a1adbbe Boy scout: rename variables with correct order 2019-07-29 13:10:09 +02:00
taitus
090390c09f Boy Scout: Create document parser spec file
Regroup DocumentParser spec. Now they're duplicates in
local_census_specs and census_api_spec.

Move duplicate private method "dni?(document_type) from
LocalCensus and CensusAPI to DocumentParser
2019-07-29 13:10:09 +02:00
taitus
4dfce4f245 RemoteCensusAPI accept :date_of_birth and :postal_code
New RemoteCensusAPI allow receive :date_of_birth and
:postal_code and use in request to endpoint always that have
been configured on remote_census_configuration:
  - Setting["remote_census.request.date_of_birth"]
  - Setting["remote_census.request.postal_code"]

Add new params to CensusCaller 'call' method.
2019-07-29 13:10:09 +02:00
taitus
3f16157418 Create new RemoteCensusAPI
Create a new RemoteCensusAPI with the same functionality as
the old CensusAPI.

In the new RemoteCensusAPI both the request and the
processing of the response are made according to the
parameters defined in the "Remote Census Configuration"
page.

Same as old Census API we only consider document_type and
document_number on API request.

* request(document_type, document_number))

On "Remote Census Configuration" we allow to define request
structure on Setting["remote_census.request.structure"]

The information text of this field on "Remote Census Configuration" is:
> The "static" values of this request should be filled.
> Values related to Document Type, Document Number, Date of Birth and
  Postal Code should be nil value.

An Example with the expected value for this field:
"{ request:
    {
      codigo_institucion: 1,
      codigo_portal: 1,
      codigo_usuario: 1,
      documento: nil,
      tipo_documento: nil,
      codigo_idioma: '102',
      nivel: '3'
    }
  }"
Where 'codigo_institucion', 'codigo_portal', 'codigo_usuario' and
'nivel' are "static" and filled in with their expected static values.
On the other hand 'documento' and 'tipo_documento' are fields
related with 'document_type','document_number' and filled in with
 nil value.

On 'request' method we fill in thats 'nil values' with their
correct argument value. We can fill_in correctly because on
"Remote Census Configuration" we allow to define request path for
'document_type','document_number'

Setting["remote_census.request.document_type"]
Setting["remote_census.request.document_number"]

An Example with the expected values:
Setting["remote_census.request.document_type"] = "request.tipo_documento"
Setting["remote_census.request.document_number"] = "request.documento"

With this information with 'fill_in(structure, path_value, value)'
method, we can update structure with correct argument ('document_type',
'document_number', 'date_of_birth' and 'postal_code') value.

An Example of fill_in(structure, path_value, value) where:
structure = "{ request:
                {
                  codigo_institucion: 1,
                  codigo_portal: 1,
                  codigo_usuario: 1,
                  documento: nil,
                  tipo_documento: nil,
                  codigo_idioma: '102',
                  nivel: '3'
                }
              }"
path_value = "request.documento"
value = "12345678X"

The result expected is:
{ request:
  {
    codigo_institucion: 1,
    codigo_portal: 1,
    codigo_usuario: 1,
    documento: "12345678X",
    tipo_documento: nil,
    codigo_idioma: '102',
    nivel: '3'
  }
}
2019-07-29 13:10:09 +02:00
taitus
dc5c316caf Allow new call to RemoteCensusApi on CensusCaller
When Setting["feature.remote_census"] is active, we allow and
ability the calls to new RemoteCensusAPI througth CensusCaller
2019-07-29 13:10:09 +02:00
taitus
064235d29f Add rake task to create remote census setting 2019-07-29 13:10:09 +02:00
taitus
44da3126d6 Convert AvailableLocales from Module to Class 2019-06-27 09:21:19 +02:00
taitus
3a154a57cb Fix houncibot offenses: Style/StringLiterals 2019-06-27 09:21:19 +02:00
taitus
72d1893703 Manage the remote translation button display
- Add remote_translation_button partial to layout
- Only display button when we have remote_translations and if current
  locale is include on available locales from remote translations service.
- Recover available locales from remote translations service.
  Use daily_cache to detect every day if remote translation service has
  added new available locale.

Co-Authored-By: alessandro <agileontheweb@gmail.com>
2019-06-27 09:21:18 +02:00
taitus
6ad294e71f Fix houncibot offenses. 2019-06-27 09:21:18 +02:00
taitus
1d3dd6f727 Add RemoteTranslationsCaller to new namespace
- Rename to Caller
 - Add to new namespace RemoteTranslations
 - Update references to new namespace
2019-06-27 09:21:18 +02:00
taitus
510307b0bd Add SentencesParser to new namespace
Add to new name space RemoteTranslations::Microsoft
2019-06-27 09:21:18 +02:00
taitus
4c1704a5a3 Add RemoteAvailableLocales to new namespace
Add to new name space RemoteTranslations::Microsoft and rename to
AvailableLocales.
2019-06-27 09:21:18 +02:00
taitus
d29656d78f Add MicrososftTranslateClient to new namespace
- Rename to Client
- Add to new namespace RemoteTranslations::Microsoft
- Update references to new namespace
2019-06-27 09:21:18 +02:00
taitus
d2506358ef Fix found Hound violations 2019-06-27 09:21:18 +02:00
taitus
4272b60339 Create Remote Translations Caller
This module is used in a callback model and in charge of
  - extracting resources associated from RemoteTranslation and preparing
    its fields to be sent to the MicrosoftTranslateClient thought DelayedJobs
  - receive the response from MicrosoftTranslateClient and update resource
    with his translates

Co-authored-by: javierm <elretirao@gmail.com>
2019-06-27 09:21:18 +02:00
taitus
95f848f021 Fix specs after rebase with translations branch
- Fix spec spec/features/management/proposals_spec.rb:24 adding single quotes.
- Remove spec related with 'proposal improvement info link' as master branch.
- Fix proposal rake task (now proposals have translations). We put the 'validate: false' to keep the existing html tags in the  proposal's description. Without the sanitizable module deleting them.
2019-06-27 09:19:37 +02:00
taitus
90df1faf07 Maganement of available locales in MicrosoftTranslateClient
- Create remote_available_locales method to recover available locales from microsoft tanslate client. This method will be useful to display the translation button as long as the locale sent is valid.
- Create parse_locale method: Need parse available locales in Consul to will be valid on Microsoft Translate Client
2019-06-27 09:19:36 +02:00
taitus
31011033a7 Create MicrosoftTranslateClient
- Conect to remote translation service and translate array of strings
- Create SentencesParser module with texts management methods:
  - Detect split position method: When the text requested to translate is too large, we need split it in smaller parts for we can translate. This method search first valid point (dot or whitespace) for split this text so then we can get an response without dividing the word in half.
2019-06-27 09:19:36 +02:00
Senén Rodero Rodríguez
458fb750eb Fix restore method for paranoid models
Do not try to update confirmed_hide_at column from models without this column.
2019-06-27 09:19:35 +02:00
Pierre Mesure
2705416842 Adding missing subtasks to upgrade task and adding info log 2019-06-11 22:35:57 +02:00
Javier Martín
42f8ce99a0 Merge pull request #3590 from consul/add_upgrade_task
Add task to upgrade to a new release
2019-06-06 13:07:41 +02:00
Javi Martín
1d0b05832c Add info messages for release 1.0.0 tasks
So users know what's going on when they upgrade CONSUL.
2019-06-05 20:23:56 +02:00
Javi Martín
3ab2085e05 Move calculate_ballot_lines task to the right file
We already have a file with the proper budgets namespace.
2019-06-05 20:23:56 +02:00
Javi Martín
c78211af49 Add task to upgrade to version 1.0.0
It includes every task needed for the upgrade.
2019-06-05 20:23:54 +02:00
lalo
28815cb290 Create new email template for new evaluation comment created and add it to system_emails view 2019-06-05 16:22:12 +02:00
Javi Martín
e339ed94d1 Add new settings every time we deploy
This way we don't need to add and execute rake tasks every time we add a
new setting.
2019-05-31 19:33:31 +02:00
voodoorai2000
2f5d153581 Delete migration to budget investments 2019-05-31 18:23:03 +02:00
voodoorai2000
d0b8fef6b3 Delete spending proposals 2019-05-31 18:22:59 +02:00
Javier Martín
087a21b4ca Merge pull request #3565 from consul/fix_annotation_comments_order
Fix order in annotation comments with same score
2019-05-30 18:25:04 +02:00
Javi Martín
dbcc5fb724 Use AR relations when merging comments
Using arrays made it difficult to order by more than one field (like the
`most_voted` scope does), and so we were ordering by `confidence_score`
and ignoring the `created_at` column.

Using an AR relation makes it easy to reuse the existing `most_voted`
scope.

This change has one side effect: now comments with equal votes are
ordered in descending order instead of having no specific order. That
means flaky specs which failed sometimes because they assumed comments
were ordered by date are now always green.

I've also re-added the `oldest` scope removed in 792b15b thinking it was
removed because using it with arrays was too hard.
2019-05-29 20:50:53 +02:00
Javi Martín
7b5ce80593 Simplify MergedCommentTree#initialize
By setting the comments lazily in a different method, we can share its
code with the parent class.
2019-05-29 20:50:53 +02:00