Skip to content

Commit

Permalink
Don't error when checking user roles on a project
Browse files Browse the repository at this point in the history
Substitute the call to the overwritten `Project.find_by_name` finder
method with plain ActiveRecord finder methods.
  • Loading branch information
eduardoj committed Dec 13, 2024
1 parent 5bd82fe commit 22d7d50
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/api/app/controllers/webui/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,10 @@ def addreview_opts
end

def any_project_maintained_by_current_user?
projects = @actions.select(:target_project).distinct.pluck(:target_project)
maintainer_role = Role.find_by_title('maintainer')
projects.any? { |project| Project.find_by_name(project).user_has_role?(User.possibly_nobody, maintainer_role) }
projects = Project.where(name: @actions.select(:target_project)).distinct
user = User.possibly_nobody

Relationship.maintainers.where(project: projects, user: user).or(Relationship.where(group: [user.groups.unscope(:order)])).any?
end

def new_state
Expand Down

0 comments on commit 22d7d50

Please sign in to comment.