Skip to content

Commit

Permalink
Re-assign source owner if deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacall committed Nov 9, 2022
1 parent 830f626 commit a6d78a6
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -317,23 +317,10 @@ def avatar_url(image_params={}, gravatar_params={})
private

def reassign_owner
# Material.where(:user => self).each do |material|
# material.update_attribute(:user, get_default_user)
# end
# Event.where(:user => self).each do |event|
# event.update_attribute(:user_id, get_default_user.id)
# end
# ContentProvider.where(:user => self).each do |content_provider|
# content_provider.update_attribute(:user_id, get_default_user.id)
# end
# Node.where(:user => self).each do |node|
# node.update_attribute(:user_id, get_default_user.id)
# end
default_user = User.get_default_user
self.materials.each { |x| x.update_attribute(:user, default_user) } if self.materials.any?
self.events.each { |x| x.update_attribute(:user, default_user) } if self.events.any?
self.content_providers.each { |x| x.update_attribute(:user, default_user) } if self.content_providers.any?
self.nodes.each { |x| x.update_attribute(:user, default_user) } if self.nodes.any?
[materials, events, content_providers, nodes, sources].each do |type|
type.find_each { |x| x.update_attribute(:user, default_user) }
end
end

def react_to_role_change
Expand Down

0 comments on commit a6d78a6

Please sign in to comment.