PopulateTools / gobierto

Plataforma de gobierno abierto open source
https://gobierto.es
GNU Affero General Public License v3.0
74 stars 32 forks source link

Gobierto Calendars / Clear event description before storing #3906

Closed ferblape closed 3 years ago

ferblape commented 3 years ago

In calendars integration, the description of the events is imported without any kind of cleanup. There are some issues with events created with inline HTML that are resulting in invalid content.

Review the import calendar process and update the form responsible of storing imported events to cleanup any HTML from the description.

Keep in mind that the text should be cleanup from html tags, not removed. There are Ruby libs and Rails libs (html-sanitizer) to do this. Investigate and propose one.

ferblape commented 3 years ago

Video updated https://www.loom.com/share/22e2cb4ef4404c8db5196e4657bc85ae

ferblape commented 3 years ago

@stbnrivas there some errors in staging when the description is nil:

NoMethodError: undefined method `transform_values' for nil:NilClass
  File "/var/www/gobierto_staging/releases/20210623105442/app/forms/gobierto_calendars/event_form.rb", line 146, in block in assign_event_attributes
  File "/var/www/gobierto_staging/releases/20210623105442/app/forms/gobierto_calendars/event_form.rb", line 140, in tap
  File "/var/www/gobierto_staging/releases/20210623105442/app/forms/gobierto_calendars/event_form.rb", line 140, in assign_event_attributes
  File "/var/www/gobierto_staging/releases/20210623105442/app/forms/gobierto_calendars/event_form.rb", line 160, in save_event
  File "/var/www/gobierto_staging/releases/20210623105442/app/forms/gobierto_calendars/event_form.rb", line 54, in save
  File "/var/www/gobierto_staging/releases/20210623105442/app/extensions/gobierto_common/trackable.rb", line 32, in save
  File "/var/www/gobierto-etl-gencat/releases/20210211100206/utils/events_importer.rb", line 73, in save_new
  File "/var/www/gobierto-etl-gencat/releases/20210211100206/utils/events_importer.rb", line 55, in block in import!
  File "/var/www/gobierto_staging/releases/20210623105442/app/decorators/collection_decorator.rb", line 18, in block in each
  File "/usr/lib/fullstaq-ruby/versions/2.7.1-jemalloc/lib/ruby/2.7.0/csv/table.rb", line 337, in each
  File "/usr/lib/fullstaq-ruby/versions/2.7.1-jemalloc/lib/ruby/2.7.0/csv/table.rb", line 337, in each

Could you send another PR with the fix and add a test that checks nothing is broken when the description is missing in the imported event?