Commit Graph

14280 Commits

Author SHA1 Message Date
taitus
30c9445c53 Allow parse :date_of_birth on Officing::Residence initialize 2019-07-29 13:10:09 +02:00
taitus
230d1a4e9d Not display :year_of_birth when :date_of_birth is present 2019-07-29 13:10:09 +02:00
taitus
3e383d7c1f Add new fields to form
- Add :date_of_birth and :postal_code
- Only display new fields when aplication has configured the
custom census API and contains alias values for fields. Add 2
class Setting methods to check this feature:
  - force_presence_date_of_birth?
  - force_presence_postal_code?
2019-07-29 13:10:09 +02:00
taitus
2ba722a711 Allow to Officing::Residence works with CustomCensusAPI
- Allow receive new fields :date_of_birth and :postal_code
- Send new fields to CensusCaller call method to allow use on CustomCensusAPI
2019-07-29 13:10:09 +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
a382f7c301 Update all CensusCaller calls with new arguments. 2019-07-29 13:10:09 +02:00
taitus
4f52d8bf76 Verification::Residence allow to use new RemoteCensusAPI
Verification::Residence allow send params :date_of_birth and
:postal_code to CensusCaller 'call' method.
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
9e94cf060e Refactor specs 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
71af3e8789 Add :tab param to others calls to _setting_table partial
Allow redirect to their tab after update a Setting
2019-07-29 13:10:09 +02:00
taitus
ca0979bd45 Allow redirect to remote census configuration tab
Currently after each update of any Settings is redirected to the first
tab by default.
As this new tab remote_census_configuation has a lot of fields to fill
in it is a bit uncomfortable to have to go back to the tab after each
update.

- Add hidden field :tag to set current tag value
- After update add tag value to request.referer
- To avoid errors when partial call has not param :tag, add the "define?"
  method on hidden_field value.
2019-07-29 13:10:09 +02:00
taitus
37f20198da Add setting_name param to others calls to _setting_table partial
In these cases "setting" is the value expected by the new helper method for
everything to continue rendering in the usual way.

Note:
All the new calls to _setting_table partial will need add setting_name param.
2019-07-29 13:10:09 +02:00
taitus
12b6b1df05 Add new param to partial '_setting_table'
When we reuse the partial '_setting_table' to render the 3 types
of remote census settings, we need customize setting_name key by
default to clarify the information to render.

- Add new param 'setting_name' to partial '_setting_table'
- Create new setting helper method to use new setting_name param
  to display a more clarify setting name on table.
2019-07-29 13:10:09 +02:00
taitus
0a901cb82f Enable remote census configuration when remote census is active
According to the feature setting["remote_census"]:
  - Display info to enable tab when remote_census feature is disabled.
  - Display all related setting to remote_census when feature is enabled
2019-07-29 13:10:09 +02:00
taitus
637675a1f5 Add content to the Remote Census Configuration tab
- Render remote census configuration content on settings index.
 - Update type method from Setting
   On Admin::SettingsController#index we are using 'all_settings' to
   group all settings by 'type' method.
   'type' method return the first part of key when split by '.'
   To allow use by example: all_settings["remote_census.general"]
   and recover only settings related with this key we have added new
   'elsif' on 'type' method.
2019-07-29 13:10:09 +02:00
taitus
3df856ff7e Add new Settings related to the remote census
These Settings will store all the values needed to
connect to the remote census.
2019-07-29 13:10:09 +02:00
taitus
db7ca9b4f4 Add new settings tab 'Remote Census Configuration'
This tab shows all settings related to the connection
configuration to the remote census.
2019-07-29 13:10:09 +02:00
taitus
f6beff91be Add new feature setting 'remote_census'
It will allow to enable remote census configuration.
2019-07-29 13:10:09 +02:00
Senén Rodero Rodríguez
b4d13816fa Add feature specs 2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
76e474db67 Specify load_and_authorize class to cancancan to avoid class loading errors
After adding new namespace `admin/local_census_records` cancancan
`load_and_authorize` method started to crash because it was getting
confused when loading and authorizing controller resources. Specifying
class to load and authorize solves this situation.
2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
afd3644ace Activate menu entry when administrator is at importation pages 2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
1c6775ecc4 Add link to new importation to local census records index page 2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
9b5f5e653a Add local census importations controller 2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
615bfadca8 Add local_census_records importation model
This model without database allow us to validate incoming file extension and
headers and also does the following during importation process:

* Ignore empty rows
* Classifiy rows in two groups: created_records, invalid_records
2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
0239efef9d Allow administrators to run local census records importation
Allow only administrator users to run local census records importation
process
2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
d221198106 Use sequence for local_census_record factory
After adding uniqueness validation we need this to be able to create many local_census_records
2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
3c39dccad4 Add uniqueness validation to document_number and document_type pair 2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
d1587ecc62 Add sanitization to clear trailing whitespaces 2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
c4ef33e6f8 Add index to local census records document_number
This will speed up searching by document_number
2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
c72f4bfabf Add the ability to destroy a local census record 2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
a8a3f334ce Add edit and update actions 2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
fd7cc624db Add new and create actions 2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
f071ca6cb5 Create LocalCensusRecords index page
* Create admin controller and routes
* Add pagination
* Add search by document_number
* Add EN and ES translations
* Add index specs
* Add missing model specs
2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
76400a8c23 Add LocalCensusRecords link to admin menu
* Add to menu as a Settings sub-options
* Add translations for EN and ES locales
* Activate menu sub-option when user is at any LocalCensusRecords page
2019-07-29 13:07:24 +02:00
Senén Rodero Rodríguez
5fa1bd8a6f Allow administrator users the ability to manage all LocalCensusRecords
Also check that other kind of users are not able to manage
LocalCensusRecords.
2019-07-29 13:07:24 +02:00
Raimond Garcia
b9574b3179 Merge pull request #3359 from consul/translations
Translate user generated content
2019-07-23 14:53:48 +02:00
Raimond Garcia
7a00590fd0 Merge pull request #3599 from rockandror/block-updates-without-translations
Block translatable resource updates with no translations
2019-07-05 21:28:06 +02:00
Raimond Garcia
14c1bbb812 Merge pull request #3579 from rockandror/translations-new-interface
Responsive translation interface
2019-07-05 21:26:19 +02:00
Senén Rodero Rodríguez
907fc18ff7 Override translations _destroy value depending of our translations managment logic
During any translatable resource edit, if you remove all translations
you will be redirected to same form with errors showing you one of
persisted but marked to destroy translations, without this patch
_destroy field value wil be true and you will no able to persist without
re-addding the same language through translation interface.
2019-07-02 17:15:39 +02:00
Senén Rodero Rodríguez
966b5b19ba Mark all translations that do not exist for destruction
When a translation not exists yet we can mark them all for destruction
by default. They already should be initialized correctly from database
or via nested attributes.
2019-07-02 17:15:34 +02:00
Senén Rodero Rodríguez
58164ee2ec Show validation error at translation interface
Only when present
2019-07-02 17:15:27 +02:00
Senén Rodero Rodríguez
041abe9044 Add persisted but marked for destruction translations to logic
Now we take into consideration locales persisted but marked for
destruction to complete some logic and to be able to show best
translations on different situations.
2019-07-02 17:15:22 +02:00
Senén Rodero Rodríguez
d3422acbb7 Add validation to check translations amount on updates
In order to not allow users to remove all persited
translations from any resource. A few exceptions were
added:

* Does not apply to globalizable models without
   translatable attributes required
* Make a copy of main model error on current translations to be more realistic
2019-07-02 17:15:16 +02:00
Senén Rodero Rodríguez
12d20b481d Fix error during rebase 2019-07-01 16:40:24 +02:00
taitus
58962186cd Add tracking as backend path 2019-07-01 15:03:48 +02:00
taitus
a5a62b7471 Add Tracking to backend_translations_enabled? 2019-07-01 15:03:48 +02:00