rosa-build/app/controllers/projects/base_controller.rb

26 lines
954 B
Ruby
Raw Normal View History

# -*- encoding : utf-8 -*-
class Projects::BaseController < ApplicationController
prepend_before_filter :find_project
2013-02-15 11:16:34 +00:00
before_filter :init_statistics
protected
2013-03-21 21:20:36 +00:00
def find_collaborators
search = "%#{params[:search_user]}%"
users = User.joins(:groups => :projects).where(:projects => {:id => @project.id}).where("users.uname ILIKE ?", search)
users2 = @project.collaborators.where("users.uname ILIKE ?", search)
@users = (users + users2).uniq.sort {|x,y| x.uname <=> y.uname}.first(10)
end
def find_project
@project = Project.find_by_owner_and_name!(params[:owner_name], params[:project_name]) if params[:owner_name].present? && params[:project_name].present?
end
2013-02-15 11:16:34 +00:00
def init_statistics
2013-02-15 12:00:34 +00:00
if @project
@opened_issues_count = @project.issues.without_pull_requests.not_closed_or_merged.count
@opened_pull_requests_count = @project.issues.joins(:pull_request).not_closed_or_merged.count
end
2013-02-15 11:16:34 +00:00
end
end