mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-30 11:41:19 +08:00
Merge pull request #3513 from okriuchykhin/ok_SCI_5663
Allow project management to it's creator if project has no assigned users [SCI-5663]
This commit is contained in:
commit
3ca593d7f9
1 changed files with 8 additions and 3 deletions
|
@ -7,7 +7,6 @@ module User::ProjectRoles
|
|||
# Check if user is member of project
|
||||
around %i(
|
||||
is_member_of_project?
|
||||
is_owner_of_project?
|
||||
is_user_of_project?
|
||||
is_user_or_higher_of_project?
|
||||
is_technician_of_project?
|
||||
|
@ -15,7 +14,7 @@ module User::ProjectRoles
|
|||
is_viewer_of_project?
|
||||
) do |proxy, *args, &block|
|
||||
if args[0]
|
||||
@user_project = user_projects.where(project: args[0]).take
|
||||
@user_project = user_projects.find_by(project: args[0])
|
||||
@user_project ? proxy.call(*args, &block) : false
|
||||
else
|
||||
false
|
||||
|
@ -33,7 +32,13 @@ module User::ProjectRoles
|
|||
end
|
||||
|
||||
def is_owner_of_project?(project)
|
||||
@user_project.owner?
|
||||
# if project has no assigned users, creator can manage it
|
||||
if project.user_projects.none? && project.created_by_id == id
|
||||
true
|
||||
else
|
||||
user_project = user_projects.find_by(project: project)
|
||||
user_project.present? ? user_project.owner? : false
|
||||
end
|
||||
end
|
||||
|
||||
def is_user_of_project?(project)
|
||||
|
|
Loading…
Reference in a new issue