|
|
|
@ -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
|
|
|
|
|