From 228a0df54a857aec43ee2f002f48bcef1b7fd086 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 16 Oct 2017 15:45:04 +0200 Subject: [PATCH] Improved code layout. --- app/models/ticket/overviews.rb | 2 +- app/models/user/assets.rb | 5 ++++- lib/sessions/backend/ticket_overview_list.rb | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/ticket/overviews.rb b/app/models/ticket/overviews.rb index 664a09046..87e0d16fb 100644 --- a/app/models/ticket/overviews.rb +++ b/app/models/ticket/overviews.rb @@ -44,7 +44,7 @@ returns overviews_list = [] overviews.each do |overview| user_ids = overview.user_ids - next if !user_ids.empty? && !user_ids.include?(current_user.id) + next if user_ids.present? && !user_ids.include?(current_user.id) overviews_list.push overview end overviews_list diff --git a/app/models/user/assets.rb b/app/models/user/assets.rb index a494eaacd..77dcd8473 100644 --- a/app/models/user/assets.rb +++ b/app/models/user/assets.rb @@ -58,6 +58,7 @@ returns # get roles if local_attributes['role_ids'] local_attributes['role_ids'].each do |role_id| + next if data[:Role] && data[:Role][role_id] role = Role.lookup(id: role_id) data = role.assets(data) end @@ -66,6 +67,7 @@ returns # get groups if local_attributes['group_ids'] local_attributes['group_ids'].each do |group_id, _access| + next if data[:Group] && data[:Group][group_id] group = Group.lookup(id: group_id) next if !group data = group.assets(data) @@ -75,6 +77,7 @@ returns # get organizations if local_attributes['organization_ids'] local_attributes['organization_ids'].each do |organization_id| + next if data[:Organization] && data[:Organization][organization_id] organization = Organization.lookup(id: organization_id) next if !organization data = organization.assets(data) @@ -86,7 +89,7 @@ returns # add organization if self.organization_id - if !data[ Organization.to_app_model ] || !data[ Organization.to_app_model ][ self.organization_id ] + if !data[:Organization] || !data[:Organization][self.organization_id] organization = Organization.lookup(id: self.organization_id) if organization data = organization.assets(data) diff --git a/lib/sessions/backend/ticket_overview_list.rb b/lib/sessions/backend/ticket_overview_list.rb index 6f0d8cafb..806b6fe4f 100644 --- a/lib/sessions/backend/ticket_overview_list.rb +++ b/lib/sessions/backend/ticket_overview_list.rb @@ -23,7 +23,7 @@ class Sessions::Backend::TicketOverviewList < Sessions::Backend::Base index_and_lists = Ticket::Overviews.index(@user) # no data exists - return if !index_and_lists || index_and_lists.empty? + return if index_and_lists.blank? # no change exists return if @last_change == index_and_lists