未完善个人资料的用户创建可以报错
This commit is contained in:
parent
78181e5e43
commit
7338f0d44e
|
@ -443,26 +443,19 @@ class CoursesController < ApplicationController
|
|||
def create
|
||||
cs = CoursesService.new
|
||||
@course = cs.create_course(params,User.current)[:course]
|
||||
if @course.new_record?
|
||||
if @course
|
||||
respond_to do |format|
|
||||
format.html { render :action => 'new', :layout => 'new_base' } #Added by young
|
||||
format.api { render_validation_errors(@course) }
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
format.html {redirect_to settings_course_url(@course, :course_type => 1)}
|
||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
|
||||
end
|
||||
else
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
# render :layout => 'base_courses'
|
||||
flash[:notice] = l(:notice_successful_create)
|
||||
if params[:continue]
|
||||
redirect_to new_course_url(attrs, :course => '0')
|
||||
elsif params[:course_continue]
|
||||
redirect_to new_course_url(:course => '1')
|
||||
else
|
||||
redirect_to settings_course_url(@course, :course_type => 1)
|
||||
end
|
||||
}
|
||||
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
|
||||
end
|
||||
flash[:notice] = l(:notice_create_failed)
|
||||
# @course = Course.new
|
||||
format.html { redirect_to new_course_path } #Added by young
|
||||
format.api { render_validation_errors(@course) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -532,7 +525,7 @@ class CoursesController < ApplicationController
|
|||
@trackers = Tracker.sorted.all
|
||||
@course = Course.new
|
||||
@course.safe_attributes = params[:course]
|
||||
month = Time.now.month
|
||||
# month = Time.now.month
|
||||
render :layout => 'new_base'
|
||||
end
|
||||
|
||||
|
|
|
@ -201,12 +201,14 @@ class CoursesService
|
|||
@course.class_period = params[:class_period].to_i
|
||||
params[:course][:is_public] ? @course.is_public = 1 : @course.is_public = 0
|
||||
params[:course][:open_student] ? @course.open_student = 1 : @course.open_student = 0
|
||||
else
|
||||
|
||||
end
|
||||
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@trackers = Tracker.sorted.all
|
||||
|
||||
if @course.save
|
||||
if @course && @course.save
|
||||
#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 => current_user, :roles => [r])
|
||||
|
|
|
@ -12,6 +12,7 @@ zh:
|
|||
notice_account_wrong_password: 密码错误
|
||||
name_can_be_empty: 可以不填写真实姓名[保密所需]
|
||||
notice_successful_create: 创建成功
|
||||
notice_create_failed: 创建失败,请先完善个人信息
|
||||
notice_failed_create: 创建失败
|
||||
notice_successful_update: 更新成功
|
||||
notice_successful_edit: 修改成功
|
||||
|
|
Loading…
Reference in New Issue