diff --git a/NEWS.md b/NEWS.md index 72bc8c6cf0..b962aee228 100644 --- a/NEWS.md +++ b/NEWS.md @@ -81,6 +81,7 @@ Development - Fix notifications when organization seats limit is reached [#16359](https://github.com/CartoDB/cartodb/pull/16359) - Fix privacy dropdown when user is editing a map [#16367](https://github.com/CartoDB/cartodb/pull/16367) - Add a new rake to update a user username [#16370](https://github.com/CartoDB/cartodb/pull/16370) +- Add a check before destroying user tables in order to avoid deleting dependent maps [#16381](https://github.com/CartoDB/cartodb/pull/16381) - Fix duplicated attributions in datasets [#16384](https://github.com/CartoDB/cartodb/pull/16384) 4.45.0 (2021-04-14) diff --git a/app/models/carto/user_table.rb b/app/models/carto/user_table.rb index 9e385d2f2f..4014ebc608 100644 --- a/app/models/carto/user_table.rb +++ b/app/models/carto/user_table.rb @@ -13,6 +13,9 @@ end module Carto class UserTable < ActiveRecord::Base + + attr_accessor :skip_destroy_dependent_visualizations + PRIVACY_PRIVATE = 0 PRIVACY_PUBLIC = 1 PRIVACY_LINK = 2 @@ -68,7 +71,7 @@ module Carto before_destroy :ensure_not_viewer before_destroy :cache_dependent_visualizations, unless: :destroyed? before_destroy :backup_visualizations, unless: :destroyed? - after_destroy :destroy_dependent_visualizations + after_destroy :destroy_dependent_visualizations, unless: :skip_destroy_dependent_visualizations after_destroy :service_after_destroy def geometry_types