创建项目的时候创建项目得分记录

This commit is contained in:
huang 2016-01-14 12:52:44 +08:00
parent e808f0bc61
commit 5fe4e9e813
2 changed files with 10 additions and 0 deletions

View File

@ -203,6 +203,8 @@ class ProjectsController < ApplicationController
end end
end end
# 注意修改该方法的时候注意同步修改forked方法
# forked方法也会创建项目
def create def create
unless User.current.login? unless User.current.login?
redirect_to signin_url redirect_to signin_url
@ -222,6 +224,11 @@ class ProjectsController < ApplicationController
#unless User.current.admin? #unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first 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]) 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) 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) user_grades = UserGrade.create(:user_id => User.current.id, :project_id => @project.id)
Rails.logger.debug "UserGrade created: #{user_grades.to_json}" Rails.logger.debug "UserGrade created: #{user_grades.to_json}"

View File

@ -122,6 +122,9 @@ class RepositoriesController < ApplicationController
if project.save if project.save
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first 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]) 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) 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) user_grades = UserGrade.create(:user_id => User.current.id, :project_id => project.id)
Rails.logger.debug "UserGrade created: #{user_grades.to_json}" Rails.logger.debug "UserGrade created: #{user_grades.to_json}"