2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-09-21 14:39:02 +00:00
|
|
|
|
2021-09-22 07:02:16 +00:00
|
|
|
class Issue3751MissingWorkflowScreens < ActiveRecord::Migration[6.0]
|
2021-09-21 14:39:02 +00:00
|
|
|
def change
|
|
|
|
return if !Setting.exists?(name: 'system_init_done')
|
|
|
|
|
|
|
|
fix_organization_screens_create
|
|
|
|
fix_user_screens_create
|
|
|
|
end
|
|
|
|
|
|
|
|
def fix_organization_screens_create
|
|
|
|
%w[name shared domain_assignment active].each do |name|
|
|
|
|
field = ObjectManager::Attribute.find_by(name: name, object_lookup: ObjectLookup.find_by(name: 'Organization'))
|
2021-10-01 10:25:06 +00:00
|
|
|
next if field.blank?
|
|
|
|
|
2021-09-21 14:39:02 +00:00
|
|
|
field.screens['create'] ||= {}
|
|
|
|
field.screens['create']['-all-'] ||= {}
|
|
|
|
field.screens['create']['-all-']['null'] = false
|
|
|
|
field.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def fix_user_screens_create
|
|
|
|
%w[firstname lastname active].each do |name|
|
|
|
|
field = ObjectManager::Attribute.find_by(name: name, object_lookup: ObjectLookup.find_by(name: 'User'))
|
2021-10-01 10:25:06 +00:00
|
|
|
next if field.blank?
|
|
|
|
|
2021-09-21 14:39:02 +00:00
|
|
|
field.screens['create'] ||= {}
|
|
|
|
field.screens['create']['-all-'] ||= {}
|
|
|
|
field.screens['create']['-all-']['null'] = false
|
|
|
|
field.save
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|