diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index e3b5fb98a..68d2d012a 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -5,6 +5,7 @@ class Api::V1::SearchController < Api::V1::BaseController @results = Search.by_term_and_type( params[:query], (params[:type] || 'all'), + current_ability, paginate_params ) respond_to :json diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 03b69a6d6..596069078 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -8,6 +8,7 @@ class SearchController < ApplicationController Search.by_term_and_type( @query, @type, + current_ability, {page: params[:page]} ).each do |k, v| var = :"@#{k}" diff --git a/app/models/search.rb b/app/models/search.rb index e62de9dd5..fcde85821 100644 --- a/app/models/search.rb +++ b/app/models/search.rb @@ -1,13 +1,13 @@ class Search TYPES = ['projects', 'users', 'groups', 'platforms'] - def self.by_term_and_type(term, type, paginate_params) + def self.by_term_and_type(term, type, ability, paginate_params) results = {} case type when 'all' - TYPES.each{ |t| results[t] = find_collection(t, term, paginate_params) } + TYPES.each{ |t| results[t] = find_collection(t, term, ability, paginate_params) } when *TYPES - results[type] = find_collection(type, term, paginate_params) + results[type] = find_collection(type, term, ability, paginate_params) end results end @@ -15,11 +15,15 @@ class Search class << self protected - def find_collection(type, term, paginate_params) - type.classify.constantize.opened. - search(term). - search_order. - paginate(paginate_params) + def find_collection(type, term, ability, paginate_params) + scope = if type == 'users' + User.opened + else + type.classify.constantize.accessible_by(ability, :read) + end + scope.search(term). + search_order. + paginate(paginate_params) end end end \ No newline at end of file diff --git a/app/views/projects/git/commits/_commits.html.haml b/app/views/projects/git/commits/_commits.html.haml index bae720729..4dc4aa169 100644 --- a/app/views/projects/git/commits/_commits.html.haml +++ b/app/views/projects/git/commits/_commits.html.haml @@ -1,3 +1,4 @@ +- project ||= @project - commits = split_commits_by_date(commits) - cur_year = Date.today.year - counter = 1 @@ -12,7 +13,7 @@ .date= raw l(commits.first.committed_date, format: :date_block_format) .messages - commits.each_with_index do |commit| - - GitPresenters::CommitAsMessagePresenter.present(commit, project: @project) do |presenter| + - GitPresenters::CommitAsMessagePresenter.present(commit, project: project) do |presenter| = render 'shared/feed_message', presenter: presenter, item_no: counter - counter += 1 .both diff --git a/app/views/projects/pull_requests/_diff_commits_tabs.html.haml b/app/views/projects/pull_requests/_diff_commits_tabs.html.haml index 6cc922c31..7eb57c7c0 100644 --- a/app/views/projects/pull_requests/_diff_commits_tabs.html.haml +++ b/app/views/projects/pull_requests/_diff_commits_tabs.html.haml @@ -18,4 +18,4 @@ #commits.tab-pane - if @total_commits > @commits.count %div= t("projects.pull_requests.is_big", count: @commits.count) - = render partial: 'projects/git/commits/commits', object: @commits + = render partial: 'projects/git/commits/commits', object: @commits, locals: { project: @pull.from_project } diff --git a/app/views/projects/pull_requests/_pull_diff.html.haml b/app/views/projects/pull_requests/_pull_diff.html.haml index 440cf4de7..3cec1ae3d 100644 --- a/app/views/projects/pull_requests/_pull_diff.html.haml +++ b/app/views/projects/pull_requests/_pull_diff.html.haml @@ -3,7 +3,7 @@ %a{name: "diff-#{pull_diff_counter}"} .top .l= h(pull_diff.renamed_file ? "#{pull_diff.a_path.rtruncate 60}=>#{pull_diff.b_path.rtruncate 60}" : pull_diff.b_path.rtruncate(120)) - .r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, pull_diff.b_path) + .r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@pull.from_project, commit_id, pull_diff.b_path) .clear -if pull_diff.diff.present? && !(@pull.repo.tree(commit_id) / pull_diff.b_path).binary? .diff_data=render_diff(pull_diff, diff_counter: pull_diff_counter, comments: @comments)