修复当前用户为超级管理员时,创建项目后,在个人信息的参与项目栏内无该项目的记录

This commit is contained in:
sw 2014-07-14 14:49:05 +08:00
parent 31245f6fb2
commit ef95835bc6
1 changed files with 10 additions and 9 deletions

View File

@ -490,11 +490,11 @@ class ProjectsController < ApplicationController
end
end
def create
def create
@course_tag = params[:project][:project_type]
if(@course_tag=="1")
if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER)
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]
@ -517,7 +517,7 @@ class ProjectsController < ApplicationController
if @course_tag == '1'
@project.identifier = @course.extra
end
if @course_tag == '1'
if @course_tag == '1'
if User.current.user_extensions.identity == 0
if@course.save
if validate_parent_id && @project.save
@ -528,7 +528,7 @@ class ProjectsController < ApplicationController
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'
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
@ -541,7 +541,7 @@ class ProjectsController < ApplicationController
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
@ -574,10 +574,11 @@ class ProjectsController < ApplicationController
end
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?
#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)
@ -587,7 +588,7 @@ class ProjectsController < ApplicationController
end
@project.members << m
@project.project_infos << project
end
#end
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
@ -595,7 +596,7 @@ class ProjectsController < ApplicationController
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