mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-05 20:23:16 +08:00
Fix inventory activities listing, fix inventory viewable_by_user scope, fix inventory fetching in reports [SCI-10991][SCI-10994]
This commit is contained in:
parent
495618abe4
commit
9eee05f906
4 changed files with 8 additions and 11 deletions
|
@ -47,7 +47,7 @@ module ReportsHelper
|
|||
return my_module.repository_snapshots.find_by(parent_id: repository.parent_id, selected: true)
|
||||
end
|
||||
|
||||
return nil unless my_module.assigned_repositories.viewable_by_user(current_user).exists?(id: repository.id)
|
||||
return nil unless my_module.assigned_repositories.exists?(id: repository.id)
|
||||
|
||||
selected_snapshot = repository.repository_snapshots.find_by(my_module: my_module, selected: true)
|
||||
selected_snapshot || repository
|
||||
|
|
|
@ -51,15 +51,13 @@ class Repository < RepositoryBase
|
|||
scope :viewable_by_user, lambda { |user, teams = user.current_team|
|
||||
readable_repositories = joins(user_assignments: :user_role)
|
||||
.left_outer_joins(:team_shared_objects)
|
||||
.where(team: teams)
|
||||
readable_repositories =
|
||||
readable_repositories
|
||||
.where(user_assignments: { user: user })
|
||||
.where('? = ANY(user_roles.permissions)', RepositoryPermissions::READ)
|
||||
.where(team: teams)
|
||||
.or(readable_repositories.where(team_shared_objects: { team: teams }))
|
||||
.or(readable_repositories
|
||||
.where(permission_level: [Extends::SHARED_OBJECTS_PERMISSION_LEVELS[:shared_read],
|
||||
Extends::SHARED_OBJECTS_PERMISSION_LEVELS[:shared_write]]))
|
||||
.where(permission_level: [Extends::SHARED_OBJECTS_PERMISSION_LEVELS[:shared_read], Extends::SHARED_OBJECTS_PERMISSION_LEVELS[:shared_write]]))
|
||||
readable_repositories.distinct
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@ class ActivitiesService
|
|||
# Create condition for view permissions checking first
|
||||
visible_teams = user.teams.where(id: teams)
|
||||
visible_projects = Project.viewable_by_user(user, visible_teams)
|
||||
visible_repositories = Repository.viewable_by_user(user, visible_teams)
|
||||
# Temporary solution until handling of deleted subjects is fully implemented
|
||||
visible_repository_teams = visible_teams.with_user_permission(user, RepositoryPermissions::READ)
|
||||
visible_by_teams = Activity.where(project: nil, team_id: visible_teams.select(:id))
|
||||
.where.not(subject_type: %w(RepositoryBase RepositoryRow))
|
||||
.order(created_at: :desc)
|
||||
visible_by_repositories = Activity.where(subject_type: %w(RepositoryBase RepositoryRow),
|
||||
subject_id: visible_repositories.select(:id))
|
||||
visible_by_repositories = Activity.where(subject_type: %w(RepositoryBase RepositoryRow), team_id: visible_repository_teams.select(:id))
|
||||
.order(created_at: :desc)
|
||||
visible_by_projects = Activity.where(project_id: visible_projects.select(:id))
|
||||
.order(created_at: :desc)
|
||||
|
@ -26,7 +26,7 @@ class ActivitiesService
|
|||
where_condition = subjects_with_children.to_h.map { '(subject_type = ? AND subject_id IN(?))' }.join(' OR ')
|
||||
where_arguments = subjects_with_children.to_h.flatten
|
||||
if subjects_with_children[:my_module]
|
||||
where_condition = where_condition.concat(' OR (my_module_id IN(?))')
|
||||
where_condition.concat(' OR (my_module_id IN(?))')
|
||||
where_arguments << subjects_with_children[:my_module]
|
||||
end
|
||||
query = query.where(where_condition, *where_arguments)
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
team,
|
||||
subject.repository.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
|
||||
title: subject.repository.name) %>
|
||||
<% elsif type_of == 'delete_item_inventory' && values.dig('message_items', 'repository', 'id') %>
|
||||
<% repository = Repository.find(values.dig('message_items', 'repository', 'id')) %>
|
||||
<% elsif repository = Repository.find_by(id: values.dig('message_items', 'repository', 'id')) %>
|
||||
<%= route_to_other_team(repository_path(repository.id, team: repository.team.id),
|
||||
team,
|
||||
repository.name&.truncate(Constants::NAME_TRUNCATION_LENGTH),
|
||||
|
|
Loading…
Reference in a new issue