From 5fe4e9e8133a29de20954b03cafccfeaefd2a22e Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 14 Jan 2016 12:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=A1=B9=E7=9B=AE=E7=9A=84?= =?UTF-8?q?=E6=97=B6=E5=80=99=E5=88=9B=E5=BB=BA=E9=A1=B9=E7=9B=AE=E5=BE=97?= =?UTF-8?q?=E5=88=86=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 7 +++++++ app/controllers/repositories_controller.rb | 3 +++ 2 files changed, 10 insertions(+) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 31c70e92a..a93585827 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -203,6 +203,8 @@ class ProjectsController < ApplicationController end end + # 注意:修改该方法的时候注意同步修改forked方法 + # forked方法也会创建项目 def create unless User.current.login? redirect_to signin_url @@ -222,6 +224,11 @@ class ProjectsController < ApplicationController #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's score + if ProjectScore.where("project_id=?", @project.id).first.nil? + ProjectScore.create(:project_id => @project.id, :score => false) + end + # end project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id) user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id) Rails.logger.debug "UserGrade created: #{user_grades.to_json}" diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 4d407e35e..9cb6c6bd8 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -122,6 +122,9 @@ class RepositoriesController < ApplicationController if project.save 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]) + if ProjectScore.where("project_id=?", @project.id).first.nil? + ProjectScore.create(:project_id => @project.id, :score => false) + end project_info = ProjectInfo.new(:user_id => User.current.id, :project_id => project.id) user_grades = UserGrade.create(:user_id => User.current.id, :project_id => project.id) Rails.logger.debug "UserGrade created: #{user_grades.to_json}"