diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index ff2d172b..685003c8 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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) } diff --git a/app/models/project.rb b/app/models/project.rb index bead38ce..730a1060 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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