[#98] Add common issues tracker

This commit is contained in:
Alexander Machehin 2013-04-30 00:13:45 +06:00
parent d59a94df42
commit d3ac9d1a2c
13 changed files with 67 additions and 10 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -13,7 +13,7 @@ class Projects::IssuesController < Projects::BaseController
def index(status = 200) def index(status = 200)
@labels = params[:labels] || [] @labels = params[:labels] || []
@issues = @project.issues.without_pull_requests @issues = @project.issues.without_pull_requests
@issues = @issues.where(:assignee_id => current_user.id) if @is_assigned_to_me = params[:filter] == 'to_me' @issues = @issues.where(:assignee_id => current_user.id) if @is_assigned_to_me = params[:filter] == 'assigned'
@issues = @issues.joins(:labels).where(:labels => {:name => @labels}) unless @labels == [] @issues = @issues.joins(:labels).where(:labels => {:name => @labels}) unless @labels == []
# Using mb_chars for correct transform to lowercase ('Русский Текст'.downcase => "Русский Текст") # Using mb_chars for correct transform to lowercase ('Русский Текст'.downcase => "Русский Текст")
@issues = @issues.search(params[:search_issue]) if params[:search_issue] !~ /#{t('layout.issues.search')}/ @issues = @issues.search(params[:search_issue]) if params[:search_issue] !~ /#{t('layout.issues.search')}/

View File

@ -1,6 +1,6 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
class Users::UsersController < Users::BaseController class Users::UsersController < Users::BaseController
skip_before_filter :authenticate_user! skip_before_filter :authenticate_user!, :only => [:allowed, :check, :discover]
before_filter :find_user_by_key, :only => [:allowed, :discover] before_filter :find_user_by_key, :only => [:allowed, :discover]
def allowed def allowed
@ -23,6 +23,35 @@ class Users::UsersController < Users::BaseController
render :json => {:name => @user.name}.to_json render :json => {:name => @user.name}.to_json
end end
def issues
@created_issues = current_user.issues.without_pull_requests
@assigned_issues = Issue.where(:assignee_id => current_user.id).without_pull_requests
pr_ids = Project.accessible_by(current_ability, :membered).uniq.pluck(:id)
@all_issues = Issue.where(:project_id => pr_ids).without_pull_requests
case params[:filter]
when 'created'
@issues = @created_issues
when 'assigned'
@issues = @assigned_issues
else
params[:filter] = 'all' # default
@issues = @all_issues
end
@filter = params[:filter]
@opened_issues, @closed_issues = @issues.not_closed_or_merged.count, @issues.closed_or_merged.count
@status = params[:status] == 'closed' ? :closed : :open
@issues = @issues.send( (@status == :closed) ? :closed_or_merged : :not_closed_or_merged )
@sort = params[:sort] == 'updated' ? :updated : :created
@direction = params[:direction] == 'asc' ? :asc : :desc
@issues = @issues.order("issues.#{@sort}_at #{@direction}")
.includes(:assignee, :user, :pull_request).uniq
.paginate :per_page => 20, :page => params[:page]
render 'issues_index', :layout => request.xhr? ? 'with_sidebar' : 'application'
end
protected protected
def find_user_by_key def find_user_by_key

View File

@ -28,6 +28,7 @@ class User < Avatar
has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy has_many :own_projects, :as => :owner, :class_name => 'Project', :dependent => :destroy
has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy has_many :own_groups, :foreign_key => :owner_id, :class_name => 'Group', :dependent => :destroy
has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy has_many :own_platforms, :as => :owner, :class_name => 'Platform', :dependent => :destroy
has_many :issues
has_many :assigned_issues, :foreign_key => :assignee_id, :class_name => 'Issue', :dependent => :nullify has_many :assigned_issues, :foreign_key => :assignee_id, :class_name => 'Issue', :dependent => :nullify
has_many :key_pairs has_many :key_pairs

View File

@ -2,4 +2,7 @@
%nav %nav
%ul %ul
- (collection = t 'feed_menu').each do |base, title| - (collection = t 'feed_menu').each do |base, title|
%li= link_to title, root_path(:filter => base), :class => @filter == base ? 'active' : '' %li= link_to title, root_path(:filter => base), :class => controller_name == 'activity_feeds' && @filter == base ? 'active' : ''
%li
= image_tag 'menu-delimiter.png', :style => 'margin-bottom: -7px;'
%li=link_to t('users.users.issues_index.title'), issues_path, :class => controller_name== 'users' && action_name == 'issues' ? 'active' : ''

View File

@ -5,11 +5,11 @@
%table %table
%tr %tr
%td.width18=radio_button_tag :myradio, 'all', !@is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'} %td.width18=radio_button_tag :myradio, 'all', !@is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'}
%td.width135=t("layout.issues.all") %td.width135=t('layout.issues.all')
%td.width30.right=@project.issues.without_pull_requests.count %td.width30.right=@project.issues.without_pull_requests.count
%tr %tr
%td=radio_button_tag :myradio, 'to_me', @is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'} %td=radio_button_tag :myradio, 'assigned', @is_assigned_to_me, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'}
%td=t("layout.issues.to_me") %td=t('layout.issues.assigned')
%td.width30.right=@project.issues.without_pull_requests.where(:assignee_id => current_user.id).count %td.width30.right=@project.issues.without_pull_requests.where(:assignee_id => current_user.id).count
=form_tag project_issues_path(@project), :id => 'search_issue', :class => 'ajax_search_form', :method => :get do =form_tag project_issues_path(@project), :id => 'search_issue', :class => 'ajax_search_form', :method => :get do
.bordered.bpadding20 .bordered.bpadding20

View File

@ -1,4 +1,4 @@
- path = polymorphic_path [@project, issue.pull_request ? issue.pull_request : issue] - path = polymorphic_path [@project || issue.project, issue.pull_request ? issue.pull_request : issue]
%tr#row1{:name => "row", :class => issue.labels.map(&:name).compact} %tr#row1{:name => "row", :class => issue.labels.map(&:name).compact}
%td.td0 %td.td0
@ -6,7 +6,9 @@
%td.td1=issue.serial_id %td.td1=issue.serial_id
%td %td
%a{:href => path} %a{:href => path}
%div.issue_title=issue.title %div.issue_title
-prefix = @project ? '' : "<span style=\"color: #999;\">#{issue.project.name}</span>: "
="#{prefix} #{issue.title}".html_safe
.smalltext .smalltext
=issue.send(@sort == :created ? :created_at : :updated_at).to_s(:long) =issue.send(@sort == :created ? :created_at : :updated_at).to_s(:long)
=t("layout.by") if issue.user =t("layout.by") if issue.user

View File

@ -0,0 +1,12 @@
-set_meta_tags :title => t('.title')
-content_for :feed_tabs, render('activity_feeds/feed_tabs')
-content_for :sidebar do
=form_tag issues_path, :id => 'filter_issues', :method => :get do
.bordered
%table
-%w[all assigned created].each do |filter|
%tr
%td.width18=radio_button_tag :myradio, filter, filter == @filter, {:id => 'myradio1', :class => 'niceRadio', :name => 'filter'}
%td.width135=t("layout.issues.#{filter}")
%td.width30.right=instance_variable_get("@#{filter}_issues").count
=render 'projects/issues/issues_table', :issues => @issues

View File

@ -20,7 +20,8 @@ en:
assign_someone: Assign someone to this issue assign_someone: Assign someone to this issue
list: List list: List
all: All issues all: All issues
to_me: Assigned to me assigned: Assigned to me
created: Created by you
edit: Edit edit: Edit
search: Find issue... search: Find issue...
comments_header: Comments comments_header: Comments

View File

@ -20,7 +20,8 @@ ru:
assign_someone: Назначить кого-либо на задачу assign_someone: Назначить кого-либо на задачу
list: Список list: Список
all: Все задачи all: Все задачи
to_me: Назначенные мне assigned: Назначенные мне
created: Созданные мной
edit: Редактировать edit: Редактировать
search: Найти задачу... search: Найти задачу...
comments_header: Комментарии comments_header: Комментарии

View File

@ -6,6 +6,9 @@ en:
settings: settings:
profile: profile:
title: 'Your Profile' title: 'Your Profile'
users:
issues_index:
title: 'Your Issues'
projects: projects:
build_lists: build_lists:
index: index:

View File

@ -6,6 +6,9 @@ ru:
settings: settings:
profile: profile:
title: 'Ваш профиль' title: 'Ваш профиль'
users:
issues_index:
title: 'Ваши задачи'
projects: projects:
build_lists: build_lists:
index: index:

View File

@ -209,6 +209,8 @@ Rosa::Application.routes.draw do
get '/allowed' => 'users#allowed' get '/allowed' => 'users#allowed'
get '/check' => 'users#check' get '/check' => 'users#check'
get '/discover' => 'users#discover' get '/discover' => 'users#discover'
get '/issues' => 'users#issues'
get '/pull_requests' => 'users#pull_requests'
end end
scope :module => 'groups' do scope :module => 'groups' do