Merge branch 'master' into 432-repositories-with-empty-metadata

This commit is contained in:
Vokhmin Alexey V 2014-10-01 22:28:33 +04:00
commit a60c78f6fb
6 changed files with 18 additions and 11 deletions

View File

@ -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

View File

@ -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}"

View File

@ -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

View File

@ -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

View File

@ -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 }

View File

@ -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)