mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-01 17:17:04 +08:00
Fix ProjectOverviewService and automatic project assignment [SCI_6117] (#3572)
This commit is contained in:
parent
31d77cc7c4
commit
75d6a17cb7
4 changed files with 10 additions and 16 deletions
|
|
@ -26,10 +26,14 @@ module Assignable
|
|||
UserAssignment.create!(
|
||||
user: created_by,
|
||||
assignable: self,
|
||||
assigned: :manually, # we set this to manually since was the user action to create the item
|
||||
user_role: UserRole.find_by(name: I18n.t('user_roles.predefined.owner'))
|
||||
)
|
||||
|
||||
UserAssignments::GenerateUserAssignmentsJob.perform_later(self, created_by)
|
||||
# project is top level, so we do not need to create any more assignments for it
|
||||
unless self.class.instance_of?(Project)
|
||||
UserAssignments::GenerateUserAssignmentsJob.perform_later(self, created_by)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ class Project < ApplicationRecord
|
|||
|
||||
scope :templates, -> { where(template: true) }
|
||||
|
||||
after_create :assign_project_ownership
|
||||
after_create :auto_assign_project_members, if: :visible?
|
||||
before_update :sync_project_assignments, if: :visibility_changed?
|
||||
|
||||
|
|
@ -366,15 +365,6 @@ class Project < ApplicationRecord
|
|||
self.project_folder = nil
|
||||
end
|
||||
|
||||
def assign_project_ownership
|
||||
UserAssignment.create!(
|
||||
user: created_by,
|
||||
assignable: self,
|
||||
assigned: :manually, # we set this to manually since was the user action to create the project
|
||||
user_role: UserRole.find_by(name: I18n.t('user_roles.predefined.owner'))
|
||||
)
|
||||
end
|
||||
|
||||
def auto_assign_project_members
|
||||
UserAssignments::GroupAssignmentJob.perform_now(
|
||||
team,
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ class ProjectsOverviewService
|
|||
.includes(user_assignments: :user_role)
|
||||
.visible_to(@user, @team)
|
||||
.left_outer_joins(:project_comments)
|
||||
.preload(:user_projects, team: :user_teams)
|
||||
.preload(team: :user_teams)
|
||||
.select('projects.*')
|
||||
.select('COUNT(DISTINCT comments.id) AS comment_count')
|
||||
.group('projects.id')
|
||||
|
|
@ -112,7 +112,7 @@ class ProjectsOverviewService
|
|||
records = records.active if @view_mode == 'active'
|
||||
records = records.where_attributes_like('projects.name', @params[:search]) if @params[:search].present?
|
||||
if @params[:members].present?
|
||||
records = records.joins(:user_projects).where('user_projects.user_id IN (?)', @params[:members])
|
||||
records = records.joins(:user_assignments).where(user_assignments: { user_id: params[:members] })
|
||||
end
|
||||
records = records.where('projects.created_at > ?', @params[:created_on_from]) if @params[:created_on_from].present?
|
||||
records = records.where('projects.created_at < ?', @params[:created_on_to]) if @params[:created_on_to].present?
|
||||
|
|
|
|||
|
|
@ -2498,9 +2498,9 @@ en:
|
|||
new_resource_assignments: "Grant new access to %{resource}"
|
||||
new_assignments_form:
|
||||
title: "Select members"
|
||||
submit: "Grand access"
|
||||
submit_singular: "Grand access to 1 user"
|
||||
submit_plural: "Grand access to {num} users"
|
||||
submit: "Grant access"
|
||||
submit_singular: "Grant access to 1 user"
|
||||
submit_plural: "Grant access to {num} users"
|
||||
find_people_html: "🔍 Find people"
|
||||
projects:
|
||||
modals:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue