[refs #90] add pulls to tracker

This commit is contained in:
Alexander Machehin 2012-06-04 23:00:19 +06:00
parent 8ed8e10cd6
commit 4b8def5bd0
5 changed files with 25 additions and 13 deletions

View File

@ -10,22 +10,24 @@ class Projects::IssuesController < Projects::BaseController
layout 'application'
def index(status = 200)
@is_assigned_to_me = params[:filter] == 'to_me'
@status = params[:status] == 'closed' ? 'closed' : 'open'
@labels = params[:labels] || []
@issues = @project.issues
@issues = @issues.where(:assignee_id => current_user.id) if @is_assigned_to_me
@issues = @project.issues.includes(:pull_request).includes(:assignee, :user)
@issues = @issues.where(:assignee_id => current_user.id) if @is_assigned_to_me = params[:filter] == 'to_me'
@issues = @issues.joins(:labels).where(:labels => {:name => @labels}) unless @labels == []
if params[:search_issue]
@issues = @issues.where('issues.title ILIKE ?', "%#{params[:search_issue].mb_chars.downcase}%")
@issues = @issues.where('issues.title ILIKE ?', "%#{params[:search_issue].mb_chars.downcase}%") if params[:search_issue]
@opened_issues = @issues.not_closed_or_merged.count
@closed_issues = @issues.closed_or_merged.count
@issues = @issues
if params[:status] == 'closed'
@issues = @issues.closed_or_merged
@status = params[:status]
else
@issues = @issues.not_closed_or_merged
@status = 'open'
end
@opened_issues = @issues.opened.count
@closed_issues = @issues.closed.count
@issues = @issues.where(:status => @status)
@issues = @issues.includes(:assignee, :user).order('serial_id desc').uniq.paginate :per_page => 10, :page => params[:page]
@issues = @issues.order('issues.serial_id desc').uniq.paginate :per_page => 10, :page => params[:page]
if status == 200
render 'index', :layout => request.xhr? ? 'issues' : 'application'
else

View File

@ -25,6 +25,10 @@ class Issue < ActiveRecord::Base
scope :opened, where(:status => 'open')
scope :closed, where(:status => 'closed')
scope :needed_checking, where(:issues => {:status => ['open', 'blocked', 'ready', 'already']})
scope :not_closed_or_merged, needed_checking
scope :closed_or_merged, where(:issues => {:status => ['closed', 'merged']})
def assign_uname
assignee.uname if assignee
end

View File

@ -1,8 +1,9 @@
class PullRequest < ActiveRecord::Base
STATUSES = %w(ready already blocked merged closed)
belongs_to :issue, :autosave => true, :dependent => :destroy, :touch => true, :validate => true
belongs_to :base_project, :class_name => 'Project', :foreign_key => 'base_project_id'
belongs_to :head_project, :class_name => 'Project', :foreign_key => 'head_project_id'
delegate :user, :title, :body, :serial_id, :assignee, :status, :to_param, :to => :issue, :allow_nil => true
delegate :user, :title, :body, :serial_id, :assignee, :status, :to_param, :created_at, :updated_at, :to => :issue, :allow_nil => true
validate :uniq_merge
validates_each :head_ref, :base_ref do |record, attr, value|

View File

@ -16,4 +16,5 @@
%li= link_to t("project_menu.readme"), "#" #pending
- if can? :update, @project
%li= link_to t("project_menu.settings"), edit_project_path(@project), :class => (act == :edit && contr == :projects ? 'active' : nil)
/
%li=link_to t("project_menu.pull_requests"), project_pull_requests_path(@project), :class => (contr == :pull_requests ? 'active' : nil)

View File

@ -14,6 +14,10 @@
.label.selected.tracker.left
.labeltext.selected{:style => "background: ##{label.color};"}=label.name
%td.td3
-if issue.pull_request
%a{:href => project_pull_request_path(@project, issue.pull_request)}
.code
\#
.avatar
=link_to image_tag(avatar_url(issue.assignee), :alt => 'avatar'), user_path(issue.assignee) if issue.assignee
%a{:href => "#{project_issue_path @project, issue}#block-list"}