5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2025-03-19 21:28:16 +00:00

Merge branch 'issue-13077' into production.panel.sutty.nl

This commit is contained in:
f 2024-03-26 12:44:51 -03:00
commit 7ff8358e9a
No known key found for this signature in database

View file

@ -96,19 +96,21 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
end end
def rename(name) def rename(name)
return if name == site.name return if name == site.name
moved = false moved = false
site.name = name site.name = name
Site.transaction do Site.transaction do
raise ActiveRecord::Rollback if File.exists?(site.path) raise ActiveRecord::Rollback if File.exist?(site.path)
FileUtils.mv (site.path_was, site.path)
FileUtils.mv(site.path_was, site.path)
moved = true moved = true
ActiveStorage::Blob.where(service_name: site.name_was).update_all(service_name: site.name) ActiveStorage::Blob.where(service_name: site.name_was).update_all(service_name: site.name)
site.save site.save
rescue StandardError rescue StandardError
FileUtils.mv (site.path, site.path_was) if moved FileUtils.mv(site.path, site.path_was) if moved
raise raise
end end
end end
@ -254,7 +256,7 @@ SiteService = Struct.new(:site, :usuarie, :params, keyword_init: true) do
@current_role ||= usuarie.rol_for_site(site) @current_role ||= usuarie.rol_for_site(site)
end end
def with_all_locales(&block) def with_all_locales
site.locales.map do |locale| site.locales.map do |locale|
next unless I18n.available_locales.include? locale next unless I18n.available_locales.include? locale