diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index efff6efdf..c4932b1b2 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -456,7 +456,9 @@ class FilesController < ApplicationController
end
end
# 更新资源总数, 根据上传的附件数累加
- @project.update_attribute(:attachments_count, @project.attachments_count + attachments[:files].count)
+ unless @project.project_score.nil?
+ @project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count)
+ end
# end
# TODO: 临时用 nyan
sort_init 'created_on', 'desc'
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 708fbf6cb..f2de6085f 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..0a9de787a 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}"
@@ -349,7 +352,10 @@ update
# @changesets_count = @repository.latest_changesets(@path, @rev).count
@changesets_all_count = @project.gpid.nil? ? 0 : g.project(@project.gpid).commit_count
# 访问该页面的是会后则刷新
- if @changesets_all_count != @project.commits_count && @changesets_all_count != 0
+ if @project.project_score.nil?
+ ProjectScore.create(:project_id => @project.id, :score => false)
+ end
+ if @changesets_all_count != @project.project_score.changeset_num && @changesets_all_count != 0
update_commits_count(@project, @changesets_all_count)
end
# end
@@ -580,7 +586,7 @@ update
private
# 更新项目统计数
def update_commits_count project, count
- project.update_attribute(:commits_count, count)
+ project.project_score.update_attribute(:changeset_num, count)
end
def find_repository
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index 2f6c4ecc7..63f152eb2 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -683,7 +683,7 @@ class StudentWorkController < ApplicationController
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
- @project_ids = Project.where("user_id = #{User.current.id} and name like '#{condition}'")
+ @project_ids = Project.visible.where("user_id = #{User.current.id} and name like '#{condition}'")
@first = params[:first].to_i
respond_to do |format|
format.js
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 17f80cec8..be9c59992 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -52,7 +52,7 @@ module ApplicationHelper
# 获取项目/课程总分
# 发布缺陷 4分 回复缺陷 1分 提交一次 4分 讨论帖子 2分 回复帖子 1分 发布新闻 1分
def static_project_score obj
- score = obj.issues_count * 4 + obj.journals_count + obj.commits_count * 4 + obj.boards_count * 2 + obj.boards_reply_count + obj.news_count + obj.attachments_count * 5
+ score = obj.issue_num * 4 + obj.issue_journal_num + obj.changeset_num * 4 + obj.board_num * 2 + obj.board_message_num + obj.news_num + obj.attach_num * 5
end
# 获取组织成员中文名字
diff --git a/app/models/course.rb b/app/models/course.rb
index 4e3b4fff0..24e955d15 100644
--- a/app/models/course.rb
+++ b/app/models/course.rb
@@ -1,6 +1,7 @@
require 'elasticsearch/model'
class Course < ActiveRecord::Base
include Redmine::SafeAttributes
+ include ApplicationHelper
STATUS_ACTIVE = 1
STATUS_CLOSED = 5
diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb
index 310d194a0..c98c5475b 100644
--- a/app/models/forge_activity.rb
+++ b/app/models/forge_activity.rb
@@ -20,8 +20,8 @@ class ForgeActivity < ActiveRecord::Base
validates :forge_act_id,presence: true
validates :forge_act_type, presence: true
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
- after_save :add_user_activity, :add_org_activity, :add_acts_count
- before_destroy :destroy_user_activity, :destroy_org_activity, :decrease_acts_count
+ after_save :add_user_activity, :add_org_activity
+ before_destroy :destroy_user_activity, :destroy_org_activity
#在个人动态里面增加当前动态
def add_user_activity
@@ -45,21 +45,6 @@ class ForgeActivity < ActiveRecord::Base
end
end
- # 更新动态数
- def add_acts_count
- if self.project
- count = self.project.acts_count + 1
- self.project.update_attribute(:acts_count, count)
- end
- end
-
- def decrease_acts_count
- if self.project
- count = self.project.acts_count - 1
- self.project.update_attribute(:acts_count, count)
- end
- end
-
def add_org_activity
org_activity = OrgActivity.where("org_act_type = '#{self.forge_act_type.to_s}' and org_act_id = #{self.forge_act_id}").first
if org_activity
diff --git a/app/models/issue.rb b/app/models/issue.rb
index e898296af..e1de4cd9e 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -19,6 +19,7 @@ class Issue < ActiveRecord::Base
include Redmine::SafeAttributes
include Redmine::Utils::DateCalculation
include UserScoreHelper
+ include ApplicationHelper
belongs_to :project,:touch=> true
belongs_to :tracker
belongs_to :status, :class_name => 'IssueStatus', :foreign_key => 'status_id'
@@ -173,14 +174,18 @@ class Issue < ActiveRecord::Base
# 创建issue的时候,issues_count加1
def add_issues_count
- issue_count = self.project.issues_count + 1
- self.project.update_attribute(:issues_count, issue_count)
+ unless self.project.project_score.nil?
+ issue_count = self.project.project_score.issue_num + 1
+ self.project.project_score.update_attribute(:issue_num, issue_count)
+ end
end
# 删除issue的时候,issues_count减1
def decrease_issues_count
- issue_count = self.project.issues_count - 1
- self.project.update_attribute(:issues_count, issue_count)
+ unless self.project.project_score.nil?
+ issue_count = self.project.project_score.issue_num - 1
+ self.project.project_score.update_attribute(:issue_num, issue_count)
+ end
end
# 更新缺陷
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 62f0d1d69..88b71d9ff 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -225,9 +225,9 @@ class Journal < ActiveRecord::Base
# issue留言总数更新
def add_journals_count
- unless self.issue.project.nil? && self.journalized_type == "Issue"
+ if !self.issue.project.nil? && self.journalized_type == "Issue" && self.issue.project.project_score.nil?
project = self.issue.project
- project.update_attribute(:journals_count, project.journals_count + 1)
+ project.project_score.update_attribute(:issue_journal_num, project.project_score.journals_count + 1)
end
end
end
diff --git a/app/models/message.rb b/app/models/message.rb
index 2a83011f1..618fb4659 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -36,7 +36,6 @@ class Message < ActiveRecord::Base
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
- has_many :user_acts, :class_name => 'UserActivity',:as =>:user_act ,:dependent => :destroy
# end
# 课程/项目 消息
@@ -129,14 +128,32 @@ class Message < ActiveRecord::Base
# 发帖精辟更新发帖总数
def add_boards_count
- if self.project
- # 讨论区
- if self.parent_id.nil?
- count = self.project.boards_count + 1
- self.project.update_attribute(:boards_count, count)
- else # 回复
- count = self.project.boards_reply_count + 1
- self.project.update_attribute(:boards_reply_count, count)
+ unless self.project.project_score.nil?
+ if self.project
+ # 讨论区
+ if self.parent_id.nil?
+ count = self.project.project_score.board_num + 1
+ self.project.project_score.update_attribute(:board_num, count)
+ else # 回复
+ count = self.project.project_score.board_message_num + 1
+ self.project.project_score.update_attribute(:board_message_num, count)
+ end
+ end
+ end
+ end
+
+ # 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少
+ def decrease_boards_count
+ unless self.project.project_score.nil?
+ if self.project && self.parent_id.nil?
+ # 讨论区
+ if self.parent_id.nil?
+ count = self.project.project_score.board_num - 1
+ self.project.project_score.update_attribute(:board_num, count)
+ else # 回复
+ count = self.project.project_score.board_message_num - 1
+ self.project.project_score.update_attribute(:board_message_num, count)
+ end
end
end
end
@@ -326,20 +343,6 @@ class Message < ActiveRecord::Base
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE
end
- # 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少
- def decrease_boards_count
- if self.project && self.parent_id.nil?
- # 讨论区
- if self.parent_id.nil?
- count = self.project.boards_count - 1
- self.project.update_attribute(:boards_count, count)
- else # 回复
- count = self.project.boards_reply_count - 1
- self.project.update_attribute(:boards_reply_count, count)
- end
- end
- end
-
# 课程成员得分(英雄榜)
def act_as_student_score
if self.course
diff --git a/app/models/news.rb b/app/models/news.rb
index 4903003e8..7c44f7e8a 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -116,9 +116,16 @@ class News < ActiveRecord::Base
private
def add_news_count
- if self.project
- count = self.project.news_count + 1
- self.project.update_attribute(:news_count, count)
+ if self.project && !self.project.project_score.nil?
+ count = self.project.project_score.news_num + 1
+ self.project.project_score.update_attribute(:news_num, count)
+ end
+ end
+
+ def decrease_news_count
+ if self.project && !self.project.project_score.nil?
+ count = self.project.project_score.news_num - 1
+ self.project.project_score.update_attribute(:news_num, count)
end
end
@@ -176,13 +183,6 @@ class News < ActiveRecord::Base
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::NEWS
end
- def decrease_news_count
- if self.project
- count = self.project.news_count - 1
- self.project.update_attribute(:news_count, count)
- end
- end
-
def send_mail
Mailer.run.news_added(self) if Setting.notified_events.include?('news_added')
end
diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb
index 75db910c3..5aa3c1dab 100644
--- a/app/models/org_document_comment.rb
+++ b/app/models/org_document_comment.rb
@@ -1,6 +1,7 @@
class OrgDocumentComment < ActiveRecord::Base
attr_accessible :content, :creator_id, :organization_id, :parent_id, :reply_id, :title,:sticky,:locked
include Redmine::SafeAttributes
+ include ApplicationHelper
belongs_to :organization
belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id'
has_many :editor_of_documents, :dependent => :destroy
diff --git a/app/models/poll.rb b/app/models/poll.rb
index 41bfe8a72..b0499b572 100644
--- a/app/models/poll.rb
+++ b/app/models/poll.rb
@@ -1,7 +1,8 @@
class Poll < ActiveRecord::Base
#attr_accessible :closed_at, :polls_group_id, :polls_name, :polls_status, :polls_type, :published_at, :user_id
include Redmine::SafeAttributes
-
+ include ApplicationHelper
+
belongs_to :user
has_many :poll_questions, :dependent => :destroy,:order => "#{PollQuestion.table_name}.question_number"
has_many :poll_users, :dependent => :destroy
diff --git a/app/models/project.rb b/app/models/project.rb
index f17124478..32677143d 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -155,7 +155,7 @@ class Project < ActiveRecord::Base
# 创建project之后默认创建一个board,之后的board去掉了board的概念
after_create :create_board_sync,:acts_as_forge_activities,:create_project_ealasticsearch_index
before_destroy :delete_all_members,:delete_project_ealasticsearch_index
- # after_update :update_project_ealasticsearch_index
+ after_update :update_project_ealasticsearch_index
def remove_references_before_destroy
return if self.id.nil?
Watcher.delete_all ['watchable_id = ?', id]
@@ -1223,26 +1223,27 @@ class Project < ActiveRecord::Base
self.__elasticsearch__.index_document
end
end
- # def update_project_ealasticsearch_index
- # if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
- # begin
- # self.__elasticsearch__.update_document
- # rescue => e
- # self.__elasticsearch__.index_document
- # end
- # else #如果是更新成为私有的,那么索引就要被删除
- # begin
- # self.__elasticsearch__.delete_document
- # rescue => e
- #
- # end
- # end
- # end
+
+ def update_project_ealasticsearch_index
+ if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性
+ begin
+ self.__elasticsearch__.update_document
+ rescue => e
+ self.__elasticsearch__.index_document
+ end
+ else #如果是更新成为私有的,那么索引就要被删除
+ begin
+ self.__elasticsearch__.delete_document
+ rescue => e
+
+ end
+ end
+ end
+
def delete_project_ealasticsearch_index
begin
self.__elasticsearch__.delete_document
rescue => e
-
end
end
diff --git a/app/views/layouts/_project_info.html.erb b/app/views/layouts/_project_info.html.erb
index 51758ea4c..60fc6f96d 100644
--- a/app/views/layouts/_project_info.html.erb
+++ b/app/views/layouts/_project_info.html.erb
@@ -1,92 +1,99 @@
-<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
-<% teacher_num = searchTeacherAndAssistant(@course).count %>
-<% student_num = studentCount(@course) %>
-<% course_file_num = visable_attachemnts_incourse(@course).count%>
-
-
-<%= image_tag(url_to_avatar(@course), :width => "60", :height => "60") %>
-
-<%= @course.is_public == 0 ? "私有课程" : "公开课程" %>
-
-ID:<%= @course.id%>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%= @course.name %>
-
- <%# if @course.is_public == 0%>
-
-
- <%# end %>
-
- <%if User.current && @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %>
-
- <% elsif User.current && @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0%>
-
- <% elsif User.current && @course.tea_id != User.current.id && !@course.is_public? && User.current.member_of_course?(@course) && @course.outline != 0%>
-
- <% elsif User.current && @course.tea_id != User.current.id && @course.is_public? && @course.outline != 0%>
-
- <%else%>
- <%end %>
-
-
-
-
-
-
-<% if is_teacher %>
-
-
- -
-
- - <%= link_to "课程配置", {:controller => 'courses', :action => 'settings', :id => @course}, :class => "postOptionLink" %>
- - <%= link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => @course},:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗", :class => "postOptionLink" %>
- - <%= link_to "复制学期", copy_course_course_path(@course.id),:remote=>true, :class => "postOptionLink" %>
-
-
-
-
-<% end %>
+<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
+<% teacher_num = searchTeacherAndAssistant(@course).count %>
+<% student_num = studentCount(@course) %>
+<% course_file_num = visable_attachemnts_incourse(@course).count%>
+
+ <% if @course.id == 370 %>
+
+ <% end %>
+
+<%= image_tag(url_to_avatar(@course), :width => "60", :height => "60") %>
+
+<%= @course.is_public == 0 ? "私有课程" : "公开课程" %>
+ <% if @course.id == 370 %>
+
+ <% end %>
+
+
+ID:<%= @course.id%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%= @course.name %>
+
+ <%# if @course.is_public == 0%>
+
+
+ <%# end %>
+
+ <%if User.current && @course.tea_id == User.current.id && (@course.outline == 0 || BlogComment.where(:id=>@course.outline).count == 0) %>
+
+ <% elsif User.current && @course.tea_id == User.current.id && @course.outline != 0 && BlogComment.where(:id=>@course.outline).count != 0%>
+
+ <% elsif User.current && @course.tea_id != User.current.id && !@course.is_public? && User.current.member_of_course?(@course) && @course.outline != 0%>
+
+ <% elsif User.current && @course.tea_id != User.current.id && @course.is_public? && @course.outline != 0%>
+
+ <%else%>
+ <%end %>
+
+
+
+
+
+
+<% if is_teacher %>
+
+
+ -
+
+ - <%= link_to "课程配置", {:controller => 'courses', :action => 'settings', :id => @course}, :class => "postOptionLink" %>
+ - <%= link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => @course},:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗", :class => "postOptionLink" %>
+ - <%= link_to "复制学期", copy_course_course_path(@course.id),:remote=>true, :class => "postOptionLink" %>
+
+
+
+
+<% end %>
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index 8ecc6fb54..58289b352 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -76,9 +76,9 @@
<% if @project.project_type == 0 %>
- <% unless static_project_score(@project) == 0 %>
+ <% unless static_project_score(@project.project_score) == 0 %>
<%= l(:label_project_score)%> :
- <%= link_to(format("%.2f" ,static_project_score(@project) ).to_i,
+ <%= link_to(format("%.2f" ,static_project_score(@project.project_score)).to_i,
{:controller => 'projects',
:action => 'show_projects_score',
:remote => true,
@@ -95,8 +95,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
|
<%= l(:project_module_attachments) %>(
- <% @project.attachments_count %>
- <%= link_to "#{@project.attachments_count}", project_files_path(@project), :class => 'info_foot_num c_blue', :id=>'project_files_count_info' %>)
+ <% @project.project_score.attach_num %>
+ <%= link_to "#{@project.project_score.attach_num }", project_files_path(@project), :class => 'info_foot_num c_blue', :id=>'project_files_count_info' %>)
<% end %>
diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb
index 4f2a7b662..4245be9eb 100644
--- a/app/views/organizations/_org_course_homework.html.erb
+++ b/app/views/organizations/_org_course_homework.html.erb
@@ -173,7 +173,7 @@
<% time=project.updated_on %>
<% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
<%=(User.find project.user_id).show_name %>(组长)
- <%=time_from_now time %>
+ <%=time_from_now time %> <%= project.commits_count %>提交
项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
diff --git a/app/views/organizations/_project_create.html.erb b/app/views/organizations/_project_create.html.erb
index 3b35838a7..6b45a2a13 100644
--- a/app/views/organizations/_project_create.html.erb
+++ b/app/views/organizations/_project_create.html.erb
@@ -23,7 +23,7 @@
创建时间:<%= format_time(project.created_on) %>
- 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
+ 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='ProjectCreateInfo' and forge_act_id =#{project.id}").first.updated_at) %>
diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb
index 0c33f70a6..4f13278cd 100644
--- a/app/views/projects/_development_group.html.erb
+++ b/app/views/projects/_development_group.html.erb
@@ -1,14 +1,14 @@
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<%= link_to l(:label_issue_tracking), project_issues_path(@project, :remote => true), :class => "f14 c_blue02" %>
- <% if @project.issues_count > 0 %>
-
(<%= @project.issues_count %>)
+ <% if @project.project_score.issue_num > 0 %>
+
(<%= @project.project_score.issue_num %>)
<% end %>
<% if User.current.member_of?(@project) %>
@@ -19,8 +19,8 @@
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<%= link_to l(:project_module_boards), project_boards_path(@project), :class => "f14 c_blue02" %>
- <% unless @project.boards_count == 0 %>
-
(<%= @project.boards_count %>)
+ <% unless @project.project_score.board_num == 0 %>
+
(<%= @project.project_score.board_num %>)
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
@@ -30,8 +30,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
- <% unless @project.attachments_count == 0 %>
- <%= link_to "(#{@project.attachments_count})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
+ <% unless @project.project_score.attach_num == 0 %>
+ <%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% end %>
<% if User.current.member_of?(@project) %>
<%#= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
diff --git a/app/views/projects/_friend_group.html.erb b/app/views/projects/_friend_group.html.erb
index 1e29c7552..0e3db7bae 100644
--- a/app/views/projects/_friend_group.html.erb
+++ b/app/views/projects/_friend_group.html.erb
@@ -1,14 +1,14 @@
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<%= link_to l(:project_module_boards), project_boards_path(@project), :class => "f14 c_blue02" %>
- <% unless @project.boards_count == 0 %>
-
(<%= @project.boards_count %>)
+ <% unless @project.project_score.board_num == 0 %>
+
(<%= @project.project_score.board_num %>)
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
@@ -18,8 +18,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
- <% unless @project.attachments_count == 0 %>
- <%= link_to "(#{@project.attachments_count})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
+ <% unless @project.project_score.attach_num == 0 %>
+ <%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
diff --git a/app/views/projects/_project_create.html.erb b/app/views/projects/_project_create.html.erb
index d966d8e18..f647f1a38 100644
--- a/app/views/projects/_project_create.html.erb
+++ b/app/views/projects/_project_create.html.erb
@@ -18,9 +18,13 @@
<%= link_to project.name, project_path(project.id,:host=>Setting.host_course), :class => "postGrey" %>
-
+
创建时间:<%= format_time(project.created_on) %>
+
+ 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='ProjectCreateInfo' and forge_act_id =#{project.id}").first.updated_at) %>
+
+
-
diff --git a/app/views/projects/_project_score_index.html.erb b/app/views/projects/_project_score_index.html.erb
index beff3552e..aefac603e 100644
--- a/app/views/projects/_project_score_index.html.erb
+++ b/app/views/projects/_project_score_index.html.erb
@@ -1,9 +1,9 @@
<%= l(:label_projects_score) %>
= <%= l(:label_code_submit_score) %> + <%= l(:label_issue_score) %> + <%= l(:label_file_attachment_score) %> + <%= l(:label_topic_score) %> + <%= l(:label_news_score) %>
- = <%= @project.commits_count * 4 %> +
- <%= @project.issues_count * 4 + @project.journals_count %> +
- <%= @project.attachments_count * 5 %> +
- <%= @project.boards_count * 2 + @project.boards_reply_count %> +
- <%= @project.news_count %>
+
= <%= @project.project_score.changeset_num * 4 %> +
+ <%= @project.project_score.issue_num * 4 + @project.project_score.issue_journal_num %> +
+ <%= @project.project_score.attach_num * 5 %> +
+ <%= @project.project_score.board_num * 2 + @project.project_score.board_message_num %> +
+ <%= @project.project_score.news_num %>
-
= <%= static_project_score(@project) %>
+
= <%= static_project_score(@project.project_score) %>
diff --git a/app/views/projects/_research_team.html.erb b/app/views/projects/_research_team.html.erb
index 2c5fb67c7..86b617e31 100644
--- a/app/views/projects/_research_team.html.erb
+++ b/app/views/projects/_research_team.html.erb
@@ -1,14 +1,14 @@
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<%= link_to l(:label_issue_tracking), project_issues_path(@project), :class => "f14 c_blue02" %>
- <% if @project.issues_count > 0 %>
-
(<%= @project.issues_count %>)
+ <% if @project.project_score.issue_num > 0 %>
+
(<%= @project.project_score.issue_num %>)
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_release_issue), new_project_issue_path(@project) , :class => "subnav_green" %>
@@ -18,8 +18,8 @@
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<%= link_to l(:project_module_boards), project_boards_path(@project), :class => "f14 c_blue02" %>
- <% unless @project.boards_count == 0 %>
-
(<%= @project.boards_count %>)
+ <% unless @project.project_score.board_num == 0 %>
+
(<%= @project.project_score.board_num %>)
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
@@ -29,8 +29,8 @@
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
- <% unless @project.attachments_count == 0 %>
- <%= link_to "(#{@project.attachments_count})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
+ <% unless @project.project_score.attach_num == 0 %>
+ <%= link_to "(#{@project.project_score.attach_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% end %>
<% if User.current.member_of?(@project) %>
<%= link_to "+"+l(:label_upload_source), project_files_path(@project,:flag => true), :class => "subnav_green ml95" %>
diff --git a/app/views/projects/_show_projects_score.html.erb b/app/views/projects/_show_projects_score.html.erb
index c188bad98..c18060257 100644
--- a/app/views/projects/_show_projects_score.html.erb
+++ b/app/views/projects/_show_projects_score.html.erb
@@ -12,7 +12,7 @@
<%= l(:label_projects_score) %> |
- <%= static_project_score(@project) %> |
+ <%= static_project_score(@project.project_score) %> |
|
@@ -22,22 +22,22 @@
-
- <%= link_to l(:label_projects_score),"javascript:void(0)", :onclick => "show_div('project_score_index')"%> : <%= static_project_score(@project) %>
+ <%= link_to l(:label_projects_score),"javascript:void(0)", :onclick => "show_div('project_score_index')"%> : <%= static_project_score(@project.project_score) %>
-
- <%= link_to l(:label_code_submit_score), "javascript:void(0)", :onclick => "show_div('code_submit_score_index')" %> : <%= @project.commits_count * 4 %>
+ <%= link_to l(:label_code_submit_score), "javascript:void(0)", :onclick => "show_div('code_submit_score_index')" %> : <%= @project.project_score.changeset_num * 4 %>
-
- <%= link_to l(:label_issue_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.issues_count * 4 + @project.journals_count %>
+ <%= link_to l(:label_issue_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.project_score.issue_num * 4 + @project.project_score.issue_journal_num %>
-
- <%= link_to l(:label_file_attachment_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.attachments_count * 5 %>
+ <%= link_to l(:label_file_attachment_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.project_score.attach_num * 5 %>
-
- <%= link_to l(:label_topic_score), "javascript:void(0)", :onclick => "show_div('projects_topic_score_index')"%> : <%= @project.boards_count * 2 + @project.boards_reply_count %>
+ <%= link_to l(:label_topic_score), "javascript:void(0)", :onclick => "show_div('projects_topic_score_index')"%> : <%= @project.project_score.board_num * 2 + @project.project_score.board_message_num %>
-
- <%= link_to l(:label_news_score), "javascript:void(0)", :onclick => "show_div('news_score_index')"%> : <%= @project.news_count %>
+ <%= link_to l(:label_news_score), "javascript:void(0)", :onclick => "show_div('news_score_index')"%> : <%= @project.project_score.news_num %>
diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb
index 7c6959935..2c1af1b83 100644
--- a/app/views/users/_course_homework.html.erb
+++ b/app/views/users/_course_homework.html.erb
@@ -173,7 +173,7 @@
<% time=project.updated_on %>
<% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
<%=(User.find project.user_id).show_name %>(组长)
-
<%=time_from_now time %>
+
<%=time_from_now time %> <%= project.commits_count %>提交
项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
diff --git a/app/views/users/_project_create.html.erb b/app/views/users/_project_create.html.erb
index 6214833f1..ae25312f3 100644
--- a/app/views/users/_project_create.html.erb
+++ b/app/views/users/_project_create.html.erb
@@ -23,7 +23,7 @@
创建时间:<%= format_time(project.created_on) %>
- 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %>
+ 更新时间:<%= format_time(ForgeActivity.where("forge_act_type='ProjectCreateInfo' and forge_act_id =#{project.id}").first.updated_at) %>
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb
index 85e426e92..802723936 100644
--- a/app/views/users/_user_homework_detail.html.erb
+++ b/app/views/users/_user_homework_detail.html.erb
@@ -174,7 +174,7 @@
<% time=project.updated_on %>
<% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
<%=(User.find project.user_id).show_name %>(组长)
-
<%=time_from_now time %>
+
<%=time_from_now time %> <%= project.commits_count %>提交
项目名称:<%=project.name %>
创建者:<%=(User.find project.user_id).show_name %>(组长)
diff --git a/db/migrate/20160113090435_update_forge_and_user_activity.rb b/db/migrate/20160113090435_update_forge_and_user_activity.rb
new file mode 100644
index 000000000..01cedded0
--- /dev/null
+++ b/db/migrate/20160113090435_update_forge_and_user_activity.rb
@@ -0,0 +1,42 @@
+class UpdateForgeAndUserActivity < ActiveRecord::Migration
+ def up
+ user_count = UserActivity.all.count / 30 + 2
+ transaction do
+ for i in 1 ... user_count do i
+ UserActivity.page(i).per(30).each do |user_act|
+ if user_act.act_type == 'Issue'
+ if user_act.act
+ if user_act.act.journals.count > 0
+ user_act.updated_at = user_act.act.journals.maximum("created_on")
+ user_act.save
+ end
+ else
+ user_act.destroy
+ end
+ end
+ end
+ end
+ end
+
+ for_count = ForgeActivity.all.count / 30 + 2
+ transaction do
+ for i in 1 ... for_count do i
+ ForgeActivity.page(i).per(30).each do |for_act|
+ if for_act.forge_act_type == 'Issue'
+ if for_act.forge_act
+ if for_act.forge_act.journals.count > 0
+ for_act.updated_at = for_act.forge_act.journals.maximum("created_on")
+ for_act.save
+ end
+ else
+ for_act.destroy
+ end
+ end
+ end
+ end
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/migrate/20160114022833_add_board_num_to_project_score.rb b/db/migrate/20160114022833_add_board_num_to_project_score.rb
new file mode 100644
index 000000000..4ee56a56b
--- /dev/null
+++ b/db/migrate/20160114022833_add_board_num_to_project_score.rb
@@ -0,0 +1,6 @@
+class AddBoardNumToProjectScore < ActiveRecord::Migration
+ def change
+ add_column :project_scores, :board_num, :integer, :default => false
+ add_column :project_scores, :attach_num, :integer, :default => false
+ end
+end
diff --git a/db/migrate/20160114022928_update_project_score.rb b/db/migrate/20160114022928_update_project_score.rb
new file mode 100644
index 000000000..8a632c2bc
--- /dev/null
+++ b/db/migrate/20160114022928_update_project_score.rb
@@ -0,0 +1,61 @@
+class UpdateProjectScore < ActiveRecord::Migration
+ def up
+ project_count = Project.all.count / 30 + 2
+ transaction do
+ for i in 1 ... project_count do i
+ Project.page(i).per(30).each do |project|
+ puts project.id
+ if ProjectScore.where("project_id=?", project.id).first.nil?
+ puts "create project ==>#{project.id}"
+ ProjectScore.create(:project_id => project.id, :score => false)
+ end
+ unless project.project_score.nil?
+ # update boards
+ unless project.boards.first.nil?
+ boards_count = project.boards.first.topics.count
+ project.project_score.update_attribute(:board_num, boards_count)
+ end
+ # update boards reply
+ unless project.boards.first.nil?
+ messages_count = Message.where("board_id =? and parent_id is not ?", project.boards.first.id, nil).count
+ project.project_score.update_attribute(:board_message_num, messages_count)
+ end
+ # update issues
+ unless project.issues.nil?
+ issues_count = project.issues.count
+ project.project_score.update_attribute(:issue_num, issues_count)
+ end
+ # update issue's journal
+ # if !project.project_score.nil? && !project.project_score.issue_journal_num.nil?
+ # project.project_score.update_attribute(:issue_journal_num, project.project_score.issue_journal_num)
+ # end
+ # update news
+ unless project.news.nil?
+ news_count = project.news.count
+ project.project_score.update_attribute(:news_num, news_count)
+ end
+ # update attach
+ unless project.attachments.nil?
+ attachments_count = project.attachments.count
+ project.project_score.update_attribute(:attach_num, attachments_count)
+ end
+ # update commits
+ unless project.gpid.nil?
+ g = Gitlab.client
+ begin
+ puts project.id
+ count = g.project(project.gpid).commit_count
+ rescue
+ logger.error("The project's rep is not exit!")
+ end
+ project.project_score.update_attribute(:changeset_num, count)
+ end
+ end
+ end
+ end
+ end
+ end
+
+ def down
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 85eec4d85..3b51fe0db 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1365,6 +1365,8 @@ ActiveRecord::Schema.define(:version => 20160112085834) do
t.integer "documents_num", :default => 0
t.integer "changeset_num", :default => 0
t.integer "board_message_num", :default => 0
+ t.integer "board_num", :default => 0
+ t.integer "attach_num", :default => 0
end
create_table "project_statuses", :force => true do |t|
diff --git a/public/images/course/boutique.png b/public/images/course/boutique.png
new file mode 100644
index 000000000..4a73020e1
Binary files /dev/null and b/public/images/course/boutique.png differ
diff --git a/public/images/course/medal.png b/public/images/course/medal.png
new file mode 100644
index 000000000..3ddba6b4a
Binary files /dev/null and b/public/images/course/medal.png differ
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index 6e9631d80..d92697e93 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -1255,3 +1255,4 @@ div.disable_link {background-color: #c1c1c1 !important;}
.boxShadow {box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5);}
.fn {font-weight:normal}
+.boutiqueP {position:absolute; left:0px; top:0px;}