mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-07 05:03:26 +08:00
Change role assigning role on object creation [SCI-6247] (#3645)
Co-authored-by: Anton <anton@scinote.net>
This commit is contained in:
parent
3862e780ee
commit
3372b679da
1 changed files with 7 additions and 1 deletions
|
@ -29,11 +29,17 @@ module Assignable
|
|||
}
|
||||
|
||||
after_create do
|
||||
role = if self.class == Project
|
||||
UserRole.find_by(name: I18n.t('user_roles.predefined.owner'))
|
||||
else
|
||||
permission_parent.user_assignments.find_by(user: created_by).user_role
|
||||
end
|
||||
|
||||
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'))
|
||||
user_role: role
|
||||
)
|
||||
|
||||
UserAssignments::GenerateUserAssignmentsJob.perform_later(self, created_by)
|
||||
|
|
Loading…
Reference in a new issue