|
|
|
@ -19,14 +19,15 @@ class ProjectsController < ApplicationController
|
|
|
|
|
layout 'base_projects'# by young
|
|
|
|
|
menu_item :overview
|
|
|
|
|
menu_item :roadmap, :only => :roadmap
|
|
|
|
|
# menu_item :settings, :only => :settings
|
|
|
|
|
menu_item :settings, :only => :settings
|
|
|
|
|
menu_item :homework, :only => :homework
|
|
|
|
|
|
|
|
|
|
before_filter :find_project, :except => [ :index, :list, :new, :create, :copy ]
|
|
|
|
|
before_filter :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback]
|
|
|
|
|
before_filter :find_project, :except => [ :index, :list, :new, :create, :copy, :statistics]
|
|
|
|
|
before_filter :authorize, :except => [:new_homework, :homework, :statistics, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback]
|
|
|
|
|
before_filter :authorize_global, :only => [:new, :create]
|
|
|
|
|
before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ]
|
|
|
|
|
#by young
|
|
|
|
|
before_filter :member, :file, :statistics
|
|
|
|
|
before_filter :member, :file
|
|
|
|
|
#
|
|
|
|
|
accept_rss_auth :index
|
|
|
|
|
accept_api_auth :index, :show, :create, :update, :destroy
|
|
|
|
@ -36,7 +37,9 @@ class ProjectsController < ApplicationController
|
|
|
|
|
controller.send :expire_action, :controller => 'welcome', :action => 'robots'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
helper :bids
|
|
|
|
|
include BidsHelper
|
|
|
|
|
helper :sort
|
|
|
|
|
include SortHelper
|
|
|
|
|
helper :custom_fields
|
|
|
|
@ -51,32 +54,11 @@ class ProjectsController < ApplicationController
|
|
|
|
|
helper :activities
|
|
|
|
|
helper :documents
|
|
|
|
|
helper :watchers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### added by william
|
|
|
|
|
include ActsAsTaggableOn::TagsHelper
|
|
|
|
|
|
|
|
|
|
# Lists visible projects
|
|
|
|
|
# def index
|
|
|
|
|
# respond_to do |format|
|
|
|
|
|
# format.html {
|
|
|
|
|
# scope = Project
|
|
|
|
|
# unless params[:closed]
|
|
|
|
|
# scope = scope.active
|
|
|
|
|
# end
|
|
|
|
|
# @projects = scope.visible.order('lft').all
|
|
|
|
|
# }
|
|
|
|
|
# format.api {
|
|
|
|
|
# @offset, @limit = api_offset_and_limit
|
|
|
|
|
# @project_count = Project.visible.count
|
|
|
|
|
# @projects = Project.visible.offset(@offset).limit(@limit).order('lft').all
|
|
|
|
|
# }
|
|
|
|
|
# format.atom {
|
|
|
|
|
# projects = Project.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
|
|
|
|
# render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
|
|
|
|
# }
|
|
|
|
|
# end
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def index
|
|
|
|
|
#Modified by nie
|
|
|
|
|
# @offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
@ -123,6 +105,33 @@ class ProjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#Added by young
|
|
|
|
|
def homework
|
|
|
|
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
|
|
|
|
@bids = Bid.visible
|
|
|
|
|
@bids = @bids.like(params[:name]) if params[:name].present?
|
|
|
|
|
@bid_count = @bids.count
|
|
|
|
|
@bid_pages = Paginator.new @bid_count, @limit, params['page']
|
|
|
|
|
|
|
|
|
|
@offset ||= @bid_pages.reverse_offset
|
|
|
|
|
#@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
unless @offset == 0
|
|
|
|
|
@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
|
|
|
|
else
|
|
|
|
|
limit = @bid_count % @limit
|
|
|
|
|
@bids = @bids.offset(@offset).limit(limit).all.reverse
|
|
|
|
|
end
|
|
|
|
|
render :layout => 'base_courses'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def new_homework
|
|
|
|
|
@homework = Bid.new
|
|
|
|
|
@homework.safe_attributes = params[:bid]
|
|
|
|
|
render :layout => 'base_courses'
|
|
|
|
|
end
|
|
|
|
|
#Ended by young
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def feedback
|
|
|
|
|
@jours = @project.journals_for_messages.reverse
|
|
|
|
|
@limit = 10
|
|
|
|
@ -134,14 +143,17 @@ class ProjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
|
@course_tag = params[:course]
|
|
|
|
|
@issue_custom_fields = IssueCustomField.sorted.all
|
|
|
|
|
@trackers = Tracker.sorted.all
|
|
|
|
|
@project = Project.new
|
|
|
|
|
@project.safe_attributes = params[:project]
|
|
|
|
|
render :layout => 'base'
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
@course_tag = params[:project][:project_type]
|
|
|
|
|
@issue_custom_fields = IssueCustomField.sorted.all
|
|
|
|
|
@trackers = Tracker.sorted.all
|
|
|
|
|
@project = Project.new
|
|
|
|
@ -163,8 +175,12 @@ class ProjectsController < ApplicationController
|
|
|
|
|
if params[:continue]
|
|
|
|
|
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
|
|
|
|
|
redirect_to new_project_path(attrs)
|
|
|
|
|
#Added by young
|
|
|
|
|
elsif params[:course_continue]
|
|
|
|
|
redirect_to new_project_path(:course => '1')
|
|
|
|
|
#Ended by young
|
|
|
|
|
else
|
|
|
|
|
redirect_to settings_project_path(@project)
|
|
|
|
|
redirect_to settings_project_path(@project, :course => @course_tag)
|
|
|
|
|
end
|
|
|
|
|
}
|
|
|
|
|
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
|
|
|
|
@ -276,8 +292,9 @@ class ProjectsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
@document = @project.documents.build
|
|
|
|
|
#
|
|
|
|
|
@base_courses_tag = @project.project_type
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html
|
|
|
|
|
format.html{render :layout => 'base_courses' if @base_courses_tag }
|
|
|
|
|
format.api
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -289,6 +306,12 @@ class ProjectsController < ApplicationController
|
|
|
|
|
@member ||= @project.members.new
|
|
|
|
|
@trackers = Tracker.sorted.all
|
|
|
|
|
@wiki ||= @project.wiki
|
|
|
|
|
#Added by young
|
|
|
|
|
@course_tag = params[:course]
|
|
|
|
|
if @course_tag == '1'
|
|
|
|
|
render :layout => 'base_courses'
|
|
|
|
|
end
|
|
|
|
|
#Ended by young
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@ -302,9 +325,6 @@ class ProjectsController < ApplicationController
|
|
|
|
|
def file
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def statistics
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
#end
|
|
|
|
|
|
|
|
|
|
def update
|
|
|
|
|