[#98] create home controller; move activity, common issues/pull_requests & root pages here
This commit is contained in:
parent
9ac1cdb2c0
commit
f8f53b198b
|
@ -1,15 +0,0 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class ActivityFeedsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all
|
||||
@activity_feeds = current_user.activity_feeds
|
||||
@activity_feeds = @activity_feeds.where(:kind => "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all
|
||||
@activity_feeds = @activity_feeds.paginate :page => params[:page]
|
||||
respond_to do |format|
|
||||
format.html { request.xhr? ? render('_list', :layout => false) : render('index') }
|
||||
format.atom
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,62 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class HomeController < ApplicationController
|
||||
before_filter :authenticate_user!, :only => [:activity, :issues, :pull_requests]
|
||||
|
||||
def root
|
||||
render 'pages/tour/abf-tour-project-description-1', :layout => 'tour'
|
||||
end
|
||||
|
||||
def activity
|
||||
@filter = t('feed_menu').has_key?(params[:filter].try(:to_sym)) ? params[:filter].to_sym : :all
|
||||
@activity_feeds = current_user.activity_feeds
|
||||
@activity_feeds = @activity_feeds.where(:kind => "ActivityFeed::#{@filter.upcase}".constantize) unless @filter == :all
|
||||
@activity_feeds = @activity_feeds.paginate :page => params[:page]
|
||||
respond_to do |format|
|
||||
format.html { request.xhr? ? render('_list', :layout => false) : render('activity') }
|
||||
format.atom
|
||||
end
|
||||
end
|
||||
|
||||
def issues
|
||||
@created_issues = current_user.issues
|
||||
@assigned_issues = Issue.where(:assignee_id => current_user.id)
|
||||
pr_ids = Project.accessible_by(current_ability, :membered).uniq.pluck(:id)
|
||||
@all_issues = Issue.where(:project_id => pr_ids)
|
||||
@created_issues, @assigned_issues, @all_issues =
|
||||
if action_name == 'issues'
|
||||
[@created_issues.without_pull_requests,
|
||||
@assigned_issues.without_pull_requests,
|
||||
@all_issues.without_pull_requests]
|
||||
else
|
||||
[@created_issues.joins(:pull_request),
|
||||
@assigned_issues.joins(:pull_request),
|
||||
@all_issues.joins(:pull_request)]
|
||||
end
|
||||
|
||||
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', :layout => request.xhr? ? 'with_sidebar' : 'application'
|
||||
end
|
||||
|
||||
def pull_requests
|
||||
issues
|
||||
end
|
||||
end
|
|
@ -1,11 +1,5 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class PagesController < ApplicationController
|
||||
# before_filter :authenticate_user!, :except => [:show, :main, :forbidden]
|
||||
# load_and_authorize_resource
|
||||
|
||||
def root
|
||||
render 'pages/tour/abf-tour-project-description-1', :layout => 'tour'
|
||||
end
|
||||
|
||||
def tour_inside
|
||||
@entries = case params[:id]
|
||||
|
|
|
@ -23,49 +23,6 @@ class Users::UsersController < Users::BaseController
|
|||
render :json => {:name => @user.name}.to_json
|
||||
end
|
||||
|
||||
def issues
|
||||
@created_issues = current_user.issues
|
||||
@assigned_issues = Issue.where(:assignee_id => current_user.id)
|
||||
pr_ids = Project.accessible_by(current_ability, :membered).uniq.pluck(:id)
|
||||
@all_issues = Issue.where(:project_id => pr_ids)
|
||||
@created_issues, @assigned_issues, @all_issues =
|
||||
if action_name == 'issues'
|
||||
[@created_issues.without_pull_requests,
|
||||
@assigned_issues.without_pull_requests,
|
||||
@all_issues.without_pull_requests]
|
||||
else
|
||||
[@created_issues.joins(:pull_request),
|
||||
@assigned_issues.joins(:pull_request),
|
||||
@all_issues.joins(:pull_request)]
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def pull_requests
|
||||
issues
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_user_by_key
|
||||
|
|
|
@ -15,7 +15,7 @@ class ActivityFeed < ActiveRecord::Base
|
|||
self.per_page = 10
|
||||
|
||||
def partial
|
||||
'activity_feeds/partials/' + self.kind
|
||||
'home/partials/' + self.kind
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
%nav
|
||||
%ul
|
||||
- (collection = t 'feed_menu').each do |base, title|
|
||||
%li= link_to title, root_path(:filter => base), :class => controller_name == 'activity_feeds' && @filter == base ? 'active' : ''
|
||||
%li= link_to title, root_path(:filter => base), :class => @filter == base ? 'active' : ''
|
|
@ -2,6 +2,6 @@
|
|||
.sub-menu
|
||||
%nav
|
||||
%ul
|
||||
%li= link_to t('activity_menu.activity_feed'), root_path, :class => controller_name == 'activity_feeds' ? 'active' : ''
|
||||
%li= link_to t('activity_menu.tracker'), issues_path, :class => controller_name == 'users' && action_name == 'issues' ? 'active' : ''
|
||||
%li= link_to t('activity_menu.pull_requests'), pull_requests_path, :class => controller_name == 'users' && action_name == 'pull_requests' ? 'active' : ''
|
||||
%li= link_to t('activity_menu.activity_feed'), root_path, :class => action_name == 'activity' ? 'active' : ''
|
||||
%li= link_to t('activity_menu.tracker'), issues_path, :class => action_name == 'issues' ? 'active' : ''
|
||||
%li= link_to t('activity_menu.pull_requests'), pull_requests_path, :class => action_name == 'pull_requests' ? 'active' : ''
|
|
@ -2,8 +2,8 @@
|
|||
%h3.fix
|
||||
= t("layout.activity_feed.header")
|
||||
= link_to image_tag("rss.ico", :width => '15px', :height => '15px', :class => 'atom_icon'), atom_activity_feeds_path(:format => 'atom', :token => current_user.authentication_token)
|
||||
=render('feed_tabs')
|
||||
=render 'feed_tabs'
|
||||
=render 'list'
|
||||
|
||||
- content_for :sidebar, render('sidebar')
|
||||
-render 'top_menu'
|
||||
- render 'top_menu'
|
|
@ -1,5 +1,5 @@
|
|||
-set_meta_tags :title => t("users.users.#{action_name}_index.title")
|
||||
-render('activity_feeds/top_menu')
|
||||
-render 'top_menu'
|
||||
-content_for :sidebar do
|
||||
=form_tag send("#{action_name}_path"), :id => 'filter_issues', :method => :get do
|
||||
.bordered
|
|
@ -6,11 +6,6 @@ en:
|
|||
settings:
|
||||
profile:
|
||||
title: 'Your Profile'
|
||||
users:
|
||||
issues_index:
|
||||
title: 'Your Issues'
|
||||
pull_requests_index:
|
||||
title: 'Your Pull Requests'
|
||||
projects:
|
||||
build_lists:
|
||||
index:
|
||||
|
@ -38,3 +33,8 @@ en:
|
|||
product_build_lists:
|
||||
index:
|
||||
title: 'Products Monitoring'
|
||||
pages:
|
||||
issues:
|
||||
title: 'Your Issues'
|
||||
pull_requests:
|
||||
title: 'Your Pull Requests'
|
||||
|
|
|
@ -6,11 +6,6 @@ ru:
|
|||
settings:
|
||||
profile:
|
||||
title: 'Ваш профиль'
|
||||
users:
|
||||
issues_index:
|
||||
title: 'Ваши задачи'
|
||||
pull_requests_index:
|
||||
title: 'Ваши пул реквесты'
|
||||
projects:
|
||||
build_lists:
|
||||
index:
|
||||
|
@ -38,3 +33,8 @@ ru:
|
|||
product_build_lists:
|
||||
index:
|
||||
title: 'Мониторинг продуктов'
|
||||
pages:
|
||||
issues:
|
||||
title: 'Ваши задачи'
|
||||
pull_requests:
|
||||
title: 'Ваши пул реквесты'
|
||||
|
|
|
@ -94,16 +94,19 @@ Rosa::Application.routes.draw do
|
|||
get '/forbidden' => 'pages#forbidden', :as => 'forbidden'
|
||||
get '/terms-of-service' => 'pages#tos', :as => 'tos'
|
||||
get '/tour/:id' => 'pages#tour_inside', :as => 'tour_inside', :id => /projects|sources|builds/
|
||||
match '/invite.html' => redirect('/register_requests/new')
|
||||
#match '/invite.html' => redirect('/register_requests/new')
|
||||
|
||||
get '/activity_feeds.:format' => 'home#activity', :as => 'atom_activity_feeds', :format => /atom/
|
||||
get '/issues' => 'home#issues'
|
||||
get '/pull_requests' => 'home#pull_requests'
|
||||
|
||||
get '/activity_feeds.:format' => 'activity_feeds#index', :as => 'atom_activity_feeds', :format => /atom/
|
||||
if APP_CONFIG['anonymous_access']
|
||||
authenticated do
|
||||
root :to => 'activity_feeds#index'
|
||||
root :to => 'home#activity'
|
||||
end
|
||||
root :to => 'pages#root'
|
||||
root :to => 'home#root'
|
||||
else
|
||||
root :to => 'activity_feeds#index'
|
||||
root :to => 'home#activity'
|
||||
end
|
||||
|
||||
namespace :admin do
|
||||
|
@ -209,8 +212,6 @@ Rosa::Application.routes.draw do
|
|||
get '/allowed' => 'users#allowed'
|
||||
get '/check' => 'users#check'
|
||||
get '/discover' => 'users#discover'
|
||||
get '/issues' => 'users#issues'
|
||||
get '/pull_requests' => 'users#pull_requests'
|
||||
end
|
||||
|
||||
scope :module => 'groups' do
|
||||
|
|
Loading…
Reference in New Issue