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

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

@ -531,10 +531,6 @@ class ProjectsController < ApplicationController
@course.endup_time = params[:endup_time] @course.endup_time = params[:endup_time]
@course.class_period = params[:class_period] @course.class_period = params[:class_period]
end 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 end
@issue_custom_fields = IssueCustomField.sorted.all @issue_custom_fields = IssueCustomField.sorted.all
@trackers = Tracker.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) } format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end end
else else
@course.destroy #TODO: yan @course.destroy
respond_to do |format| respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) } 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_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 :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?}
after_save :create_board_sync #nyan
before_destroy :delete_all_members before_destroy :delete_all_members
def remove_references_before_destroy def remove_references_before_destroy
return if self.id.nil? return if self.id.nil?
@ -1083,4 +1084,16 @@ class Project < ActiveRecord::Base
after_parent_changed(parent_was) after_parent_changed(parent_was)
end end
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 end