自动添加讨论区当项目课程创建的时候,学生是否能回复需要在全线报表里配置.

This commit is contained in:
yanxd 2013-11-20 17:02:47 +08:00
parent 9491781b45
commit 0381179536
2 changed files with 15 additions and 6 deletions

View File

@ -524,17 +524,13 @@ class ProjectsController < ApplicationController
@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
# added by bai
@course.term = params[:term]
@course.time = params[:time]
@course.setup_time = params[:setup_time]
@course.endup_time = params[:endup_time]
@course.class_period = params[:class_period]
end
# end
# @course.save
# project = ProjectInfo.create(:user_id => User.current.id, :project_id => @project.id)
# project_status = ProjectStatus.create(:project_id => @project.id)
end
@issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.sorted.all
@ -578,7 +574,7 @@ class ProjectsController < ApplicationController
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end
else
@course.destroy #TODO: yan
@course.destroy
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }

View File

@ -119,6 +119,7 @@ class Project < ActiveRecord::Base
after_save :update_position_under_parent, :if => Proc.new {|project| project.name_changed?}
after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
after_save :create_board_sync #nyan
before_destroy :delete_all_members
def remove_references_before_destroy
return if self.id.nil?
@ -1083,4 +1084,16 @@ class Project < ActiveRecord::Base
after_parent_changed(parent_was)
end
end
# 创建项目后在项目下同步创建一个讨论区
def create_board_sync
@board = self.boards.build
@board.name = self.name
@board.description = self.name.to_s << " #{l(:label_board) }"
if @board.save
logger.debug "[Project Model] ===> #{@board.to_json}"
else
logger.error "[Project Model] ===> Auto create board when project saved, because #{@board.full_messages}"
end
end
end