Conflicts:
	db/schema.rb
This commit is contained in:
z9hang 2014-07-28 10:38:23 +08:00
commit 1daec14ab5
9 changed files with 302 additions and 169 deletions

View File

@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ProjectsController < ApplicationController
layout :select_project_layout
menu_item :overview
menu_item :roadmap, :only => :roadmap
menu_item :settings, :only => :settings
@ -459,24 +460,10 @@ class ProjectsController < ApplicationController
end
def new
@project_type = params[:project_type] ||= params[:course]
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
case @project_type
when '0' # Project
@project = Project.new
@project.safe_attributes = params[:project]
when '1' # Course
@project = Project.new
@project.safe_attributes = params[:project]
@course_tag = params[:course]
@course = Course.new
@course.safe_attributes = params[:course]
else # default Project
@project = Project.new
@project.safe_attributes = params[:project]
end
@project = Project.new
@project.safe_attributes = params[:project]
render :layout => 'base'
end
@ -490,128 +477,43 @@ class ProjectsController < ApplicationController
end
def create
@course_tag = params[:project][:project_type]
if(@course_tag=="1")
if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER)
@course = Course.new
@course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
@course.safe_attributes = params[:project][:course]
@course.tea_id = User.current.id
# added by bai
@course.term = params[:term]
@course.time = params[:time]
#@course.school_id = params[:occupation]
@course.school_id = User.current.user_extensions.school_id
@course.setup_time = params[:setup_time]
@course.endup_time = params[:endup_time]
@course.class_period = params[:class_period]
end
end
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@project = Project.new
@project.user_id = User.current.id
@project.dts_test = params[:project][:dts_test]
@project.safe_attributes = params[:project]
if @course_tag == '1'
@project.identifier = @course.extra
end
if @course_tag == '1'
if User.current.user_extensions.identity == 0
if@course.save
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
# Add current user as a project member if he is not admin
unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
if params[:project][:is_public] == '1'
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :project_type => @course_tag)
end
@project.members << m
@project.project_infos << project
end
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_path(attrs, :course => '0')
#Added by young
elsif params[:course_continue]
redirect_to new_project_path(:course => '1')
#Ended by young
else
redirect_to settings_project_path(@project,:project_type => 1)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
# Add current user as a project member if he is not admin
#unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
Rails.logger.debug "UserGrade created: #{user_grades.to_json}"
if params[:project][:is_public] == '1'
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type)
Rails.logger.debug "ProjectStatus created: #{project_status.to_json}"
end
@project.members << m
@project.project_infos << project_info
#end
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_path(attrs, :course => '0')
else
@course.destroy
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
redirect_to settings_project_path(@project)
end
else
if validate_parent_id && @project.save
@project.delete
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
else
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
end
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end
else
#@project.memberships.create
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
# Add current user as a project member if he is not admin
#unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
if params[:project][:is_public] == '1' || @course_tag=="1"
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @project.project_type)
end
@project.members << m
@project.project_infos << project
#end
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_path(attrs, :course => '0')
#Added by young
elsif params[:course_continue]
redirect_to new_project_path(:course => '1')
#Ended by young
else
redirect_to settings_project_path(@project)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end
else
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
end
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
end
end

View File

@ -758,6 +758,7 @@ class Project < ActiveRecord::Base
'tracker_ids',
'issue_custom_field_ids',
'project_type',
'dts_test',
'attachmenttype'

View File

@ -1,6 +1,6 @@
<%= raw @issues.map {|issue| {
'id' => issue.id,
'label' => "#{issue.tracker} ##{issue.id}: #{truncate issue.subject.to_s, :length => 60}",
'label' => "#{issue.tracker} ##{issue.project_index}: #{truncate issue.subject.to_s, :length => 60}",
'value' => issue.id
}
}.to_json

View File

@ -1,28 +1,15 @@
<% @nav_dispaly_project_label = 1
@nav_dispaly_forum_label = 1 %>
<%= labelled_form_for @project do |f| %>
<!--Added by young-->
<% if @course_tag == '1' %>
<h3><%=l(:label_course_new)%></h3>
<div class="box tabular">
<%= render :partial => 'course_form', :locals => { :f => f } %>
<span style="padding-left: 60px">
<%= submit_tag l(:button_create), :class => "enterprise"%>
</span>
</div>
<!-- <%#= submit_tag l(:button_create_and_continue), :name => 'course_continue' %> -->
<% else %>
<h3><%=l(:label_project_new)%></h3>
<div class="box tabular" >
<p style="font-weight: bold; color: rgb(237,137,36)"> <%=raw l(:label_project_new_description)%> </p>
<%= render :partial => 'form', :locals => { :f => f } %>
<span style="padding-left: 60px">
<%= submit_tag l(:button_create), :class => "enterprise"%>
</span>
</div>
<!-- <%#= submit_tag l(:button_create_and_continue), :name => 'continue' %> -->
<% end %>
<%= javascript_tag "$('#project_name').focus();" %>
<h3><%=l(:label_project_new)%></h3>
<div class="box tabular" >
<p style="font-weight: bold; color: rgb(237,137,36)"> <%=raw l(:label_project_new_description)%> </p>
<%= render :partial => 'form', :locals => { :f => f } %>
<span style="padding-left: 60px">
<%= submit_tag l(:button_create), :class => "enterprise"%>
</span>
</div>
<%#= submit_tag l(:button_create_and_continue), :name => 'continue' %>
<%= javascript_tag "$('#project_name').focus();" %>
<% end %>
<!--Ended by young-->

View File

@ -137,7 +137,12 @@
<% end %>
</tr>
<tr>
<td colspan="2" width="580"><p class="font_description"> <%= act.notes.html_safe %> </p>
<% if act.notes.nil? %>
<% desStr = '' %>
<% else %>
<% desStr=act.notes.html_safe %>
<% end %>
<td colspan="2" width="580"><p class="font_description"> <%= desStr %> </p>
</td>
</tr>
<tr>

View File

@ -498,7 +498,7 @@ zh:
project_module_time_tracking: 时间跟踪
project_module_news: 新闻
project_module_documents: 文档
project_module_files: 资料下载
project_module_files: 作品下载
project_module_wiki: Wiki
project_module_repository: 版本库
project_module_boards: 讨论区

122
test/fixtures/journals_for_messages.yml vendored Normal file
View File

@ -0,0 +1,122 @@
jfm_001:
id: 45
jour_id: 2
jour_type: Project
user_id: 2
notes: 我觉得这个系统挺实用,界面挺简洁美观!
status:
reply_id: 0
created_on: 2013-08-16 15:27:2
updated_on: 2013-08-16 15:27:2
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:
jfm_048:
id: 48
jour_id: 2
jour_type: Project
user_id: 2
notes: aqfbLT <a href=\"http://wcqmhgdpgfvy.com/\">wcqmhgdpgfvy</a>, [url=http://flyhqtjjtskb.com/]flyhqtjjtskb[/url],
[link=http://idlilqzxissn.com/]idlilqzxissn[/link], http://sfeezearevbp.com/
status:
reply_id: 0
created_on: 2013-08-18 20:44:18
updated_on: 2013-08-18 20:44:18
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:
jfm_049:
id: 49
jour_id: 2
jour_type: Project
user_id: 2
notes: 搜索用户时,若无对应结果,没有返回提示信息,比如不会提示:暂无此人
status:
reply_id: 0
created_on: 2013-08-19 08:45:27
updated_on: 2013-08-19 08:45:27
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:
jfm_058:
id: 58
jour_id: 2
jour_type: Project
user_id: 2
notes: 问题板块中 “新建问题”能不能移动到靠右~
status:
reply_id: 0
created_on: 2013-08-20 00:24:44
updated_on: 2013-08-20 00:24:44
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:
jfm_060:
id: 60
jour_id: 2
jour_type: Project
user_id: 2
notes: something very nice
status:
reply_id: 0
created_on: 2013-08-21 07:04:43
updated_on: 2013-08-21 07:04:43
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:
jfm_086:
id: 86
jour_id: 2
jour_type: Project
user_id: 2
notes: 谢谢大家的反馈!
status:
reply_id: 0
created_on: 2013-08-23 02:36:48
updated_on: 2013-08-23 02:36:48
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:
jfm_087:
id: 87
jour_id: 2
jour_type: Project
user_id: 2
notes: ”与我相关“处不可以直接回复
status:
reply_id: 0
created_on: 2013-08-23 02:44:56
updated_on: 2013-08-23 02:44:56
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:
jfm_088:
id: 88
jour_id: 2
jour_type: Project
user_id: 2
notes: 任何有关回复的地方可在任意显示处回复
status:
reply_id: 0
created_on: 2013-08-23 02:45:45
updated_on: 2013-08-23 02:45:45
m_parent_id:
is_readed:
m_reply_count:
m_reply_id:
is_comprehensive_evaluation:

View File

@ -11,18 +11,18 @@ projects_001:
parent_id:
lft: 1
rgt: 10
projects_002:
created_on: 2006-07-19 19:14:19 +02:00
name: OnlineStore
updated_on: 2006-07-19 19:14:19 +02:00
id: 2
description: E-commerce web site
homepage: ""
is_public: false
identifier: onlinestore
parent_id:
lft: 11
rgt: 12
#projects_002:
# created_on: 2006-07-19 19:14:19 +02:00
# name: OnlineStore
# updated_on: 2006-07-19 19:14:19 +02:00
# id: 2
# description: E-commerce web site
# homepage: ""
# is_public: false
# identifier: onlinestore
# parent_id:
# lft: 11
# rgt: 12
projects_003:
created_on: 2006-07-19 19:15:21 +02:00
name: eCookbook Subproject 1
@ -71,3 +71,24 @@ projects_006:
parent_id: 5
lft: 3
rgt: 4
trustie:
id: 2
name: SocialForge
description: "SocialForge是TrustieForge的升级版支持社交化协同开发与合作。 SocialForge aims to provide a socialized and crowd sourcing enabled collaboration development platform. It is combining and will combine TrustieForge, Influx, Redmine and other open source projects."
homepage: http://forge.trustie.net
is_public: true
parent_id:
created_on: 2013-06-25 06:02:19.000000000 Z
updated_on: 2013-11-13 12:52:42.000000000 Z
identifier: trustie
status: 1
lft: 11
rgt: 12
# lft: 115
# rgt: 116
project_type: 0
hidden_repo: true
attachmenttype: 1
user_id:
dts_test: 0

View File

@ -0,0 +1,95 @@
require File.expand_path('../../test_helper', __FILE__)
class ProjectsControllerTest < ActionController::TestCase
fixtures :projects,
:issues,
:issue_statuses,
:enumerations,
:users,
:issue_categories,
:trackers,
:projects_trackers,
:roles,
:member_roles,
:members,
:enabled_modules,
:journals,
:journal_details,
:journals_for_messages
def setup
@request.session[:user_id] = nil
@request.session[:ctime] = Time.now
@request.session[:atime] = Time.now
Setting.default_language = 'en'
end
test 'get :index' do
get :index
assert_response :success
end
test ':new by admin should accept get' do
@request.session[:user_id] = 1
get :new
assert_response :success
end
test ':new by non-admin user with add_project permission should accept get' do
Role.non_member.add_permission! :add_project
@request.session[:user_id] = 9
get :new
assert_response :success
assert_template 'new'
end
test ':create by admin user should create a new project' do
@request.session[:user_id] = 1
post :create, :project => {
name: "blog1",
description: 'weblog',
homepage: 'http://weblog',
identifier: 'blog',
is_public: 1,
custom_field_values: {'3' => 'Beta'},
tracker_ids: ['1', '3'],
:issue_custom_field_ids => ['9'],
:enabled_module_names => ['issue_tracking', 'news', 'repository']
}
project = Project.find_by_name(blog)
assert_not_nil project
assert_redirected_to "/projects/#{project.id}/settings"
assert_kind_of Project, project
assert project.active?
assert_equal 'weblog', project.description
assert_equal 'http://weblog', project.homepage
assert_equal true, project.is_public?
assert_nil project.parent
assert_equal 'Beta', project.custom_value_for(3).value
assert_equal [1, 3], project.trackers.map(&:id).sort
assert_equal ['issue_tracking', 'news', 'repository'], project.enabled_module_names.sort
assert project.issue_custom_fields.include?(IssueCustomField.find(9))
end
test 'get :show trustie' do
get :show, {id: 2}
assert_response :success
end
test 'get :search, forge' do
query_condition = "forge"
get :search, {'name' => query_condition }
projects = assigns(:projects_all)
assert projects.any?, "projects should have anything."
projects.each do |project|
assert project.name.downcase.include?(query_condition), "project name is invalid: #{project.name}"
end
end
test 'get :feedback' do
get :feedback, {id: 2}
assert_response :success
# prject_id = 2 总有8个留言
assert_equal assigns(:jour).count, 8
end
end