-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid hardcoding miq_task product feature
- Loading branch information
Showing
1 changed file
with
5 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
module Api | ||
class TasksController < BaseController | ||
def find_collection(klass) | ||
return klass.all if current_user.role_allows?(:identifier => "miq_task_all_ui") | ||
return klass.where(:userid => [current_user.userid]) if current_user.report_only_my_user_tasks? | ||
|
||
klass.where(:userid => [current_user.userid]) # Role must have product feature miq_task_my_ui | ||
klass.all | ||
end | ||
|
||
def find_resource(klass, key_id, id) | ||
if current_user.role_allows?(:identifier => "miq_task_all_ui") | ||
key_id == "id" ? klass.find(id) : klass.find_by(key_id => id) | ||
else | ||
klass.find_by(key_id => id, :userid => [current_user.userid]) # Role must have product feature miq_task_my_ui | ||
end | ||
return klass.find_by(key_id => id, :userid => [current_user.userid]) if current_user.report_only_my_user_tasks? | ||
|
||
key_id == "id" ? klass.find(id) : klass.find_by(key_id => id) | ||
end | ||
end | ||
end |