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

25 lines
830 B
Ruby
Raw Normal View History

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]}%"
2014-04-09 22:20:39 +01:00
@users = @project.collaborators.where("users.uname ILIKE ?", search)
@users |= @project.owner.members.where("users.uname ILIKE ?", search) if @project.owner.is_a?(Group)
@users = @users.sort_by(&:uname).first(10)
2013-03-21 21:20:36 +00:00
end
def find_project
2014-03-20 22:56:59 +00:00
@project = Project.find_by_owner_and_name! params[:name_with_owner] if params[:name_with_owner].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