Merge branch 'hjq_new_course' into szzh

This commit is contained in:
huang 2016-01-13 16:25:56 +08:00
commit 34fde24f09
37 changed files with 370 additions and 160 deletions

View File

@ -17,8 +17,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class FilesController < ApplicationController
layout 'base_projects' #by young
layout 'base_projects' #by young
menu_item :files
before_filter :auth_login1, :only => [:index]
@ -454,6 +453,9 @@ class FilesController < ApplicationController
end
end
end
# 更新资源总数, 根据上传的附件数累加
@project.update_attribute(:attachments_count, @project.attachments_count + attachments[:files].count)
# end
# TODO: 临时用 nyan
sort_init 'created_on', 'desc'
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
@ -482,9 +484,6 @@ class FilesController < ApplicationController
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
Mailer.run.attachments_added(attachments[:files])
end
# 更新课程英雄榜得分
update_contributor_score(@course, attachments[:files].first)
# end
if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array)
params[:course_attachment_type].each do |type|
tag_name = get_tag_name_by_type_number type
@ -506,8 +505,9 @@ class FilesController < ApplicationController
end
end
end
# 更新课程英雄榜得分
update_contributor_score(@course, attachments[:files].first)
# end
# TODO: 临时用 nyan
sort_init 'created_on', 'desc'
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
@ -828,5 +828,5 @@ class FilesController < ApplicationController
def upload_files_menu
end
end
end

View File

@ -344,20 +344,15 @@ update
#Modified by young
# (show_error_not_found; return) unless @entries
g = Gitlab.client
# count = 0
# (0..100).each do |page|
# if g.commits(@project.gpid,:page => page).count == 0
# break
# else
# count = count + g.commits(@project.gpid,:page => page).count
# end
# end
@changesets = g.commits(@project.gpid, :ref_name => @rev)
# @changesets = @repository.latest_changesets(@path, @rev)
# @changesets_count = @repository.latest_changesets(@path, @rev).count
@changesets_all_count = @project.gpid.nil? ? 0 : g.commits_total_count(@project.gpid).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
update_commits_count(@project, @changesets_all_count)
end
# end
@changesets_latest_coimmit = @changesets[0]
@properties = @repository.properties(@path, @rev)
@repositories = @project.repositories
@ -583,6 +578,10 @@ update
end
private
# 更新项目统计数
def update_commits_count project, count
project.update_attribute(:commits_count, count)
end
def find_repository
@repository = Repository.find(params[:id])

View File

@ -49,6 +49,12 @@ module ApplicationHelper
end
end
# 获取项目/课程总分
# 发布缺陷 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
end
# 获取组织成员中文名字
def get_org_member_role_name member
case member.roles[0].name
@ -2784,8 +2790,7 @@ int main(int argc, char** argv){
#代码提交数量
def changesets_num project
g = Gitlab.client
project.gpid.nil? ? 0 : g.commits_total_count(project.gpid).count
# # commits_total_count(project.gpid)
project.gpid.nil? ? 0 : g.project(project.gpid).commit_count
# project.changesets.count
end
end

View File

@ -90,7 +90,7 @@ class Attachment < ActiveRecord::Base
before_save :files_to_final_location,:act_as_course_activity
after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index
after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index
after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index
after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index#, :decrease_attchments_count
# add by nwb
# 获取所有可公开的资源文件列表
@ -617,6 +617,7 @@ class Attachment < ActiveRecord::Base
self.__elasticsearch__.index_document
end
end
def update_attachment_ealasticsearch_index
if self.is_public == 1 && ( ((self.container_type == 'Project' or self.container_type == 'Version') && Project.find(self.container_id).is_public == 1) ||
( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) ||
@ -632,12 +633,20 @@ class Attachment < ActiveRecord::Base
end
end
end
def delete_attachment_ealasticsearch_index
begin
self.__elasticsearch__.delete_document
rescue => e
end
end
# def decrease_attchments_count
# if self.container_type == "Project"
# count = self.container.attachments_count
# #self.container.update_attribute(:attachments_count, self.container.attachments_count - 1)
# end
# end
end
# Delete the previous articles index in Elasticsearch

View File

@ -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
before_destroy :destroy_user_activity, :destroy_org_activity
after_save :add_user_activity, :add_org_activity, :add_acts_count
before_destroy :destroy_user_activity, :destroy_org_activity, :decrease_acts_count
#在个人动态里面增加当前动态
def add_user_activity
@ -45,6 +45,21 @@ 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

View File

@ -83,9 +83,9 @@ class Issue < ActiveRecord::Base
attr_reader :current_journal
# fq
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message, :add_issues_count
after_update :be_user_score
after_destroy :down_user_score
after_destroy :down_user_score, :decrease_issues_count
# after_create :be_user_score
# end
@ -165,6 +165,18 @@ class Issue < ActiveRecord::Base
end
end
# 创建issue的时候issues_count加1
def add_issues_count
issue_count = self.project.issues_count + 1
self.project.update_attribute(:issues_count, issue_count)
end
# 删除issue的时候issues_count减1
def decrease_issues_count
issue_count = self.project.issues_count - 1
self.project.update_attribute(:issues_count, issue_count)
end
# 更新缺陷
#def act_as_forge_message_update
# unless self.author_id == self.assigned_to_id

View File

@ -48,14 +48,14 @@ class Journal < ActiveRecord::Base
:conditions => "#{Journal.table_name}.journalized_type = 'Issue' AND" +
"(#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')"}
before_create :split_private_notes
before_create :split_private_notes, :add_journals_count
# fq
after_save :act_as_activity,:be_user_score, :act_as_forge_message, :act_as_at_message
# end
#after_destroy :down_user_score
#before_save :be_user_score
after_destroy :down_user_score
after_destroy :down_user_score, :decrease_issues_journal_count
scope :visible, lambda {|*args|
user = args.shift || User.current
@ -214,4 +214,20 @@ class Journal < ActiveRecord::Base
end
end
# 减少留言数量统计
def decrease_issues_journal_count
unless self.issue.project.nil?
project = self.issue.project
project.update_attribute(:journals_count, project.journals_count - 1)
end
end
# issue留言总数更新
def add_journals_count
unless self.issue.project.nil? && self.journalized_type == "Issue"
project = self.issue.project
project.update_attribute(:journals_count, project.journals_count + 1)
end
end
end

View File

@ -74,9 +74,9 @@ class Message < ActiveRecord::Base
validates_length_of :subject, :maximum => 255
validate :cannot_reply_to_locked_topic, :on => :create
after_create :add_author_as_watcher, :reset_counters!
after_create :add_author_as_watcher, :reset_counters!, :add_boards_count
after_update :update_messages_board
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, :act_as_at_message
#before_save :be_user_score
@ -125,6 +125,20 @@ class Message < ActiveRecord::Base
end
end
# 发帖精辟更新发帖总数
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)
end
end
end
def reset_counters!
if parent && parent.id
Message.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id})
@ -303,6 +317,20 @@ 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

View File

@ -55,9 +55,9 @@ class News < ActiveRecord::Base
:author_key => :author_id
acts_as_watchable
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail
after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail, :add_news_count
after_destroy :delete_kindeditor_assets
after_destroy :delete_kindeditor_assets, :decrease_news_count
scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
@ -107,10 +107,17 @@ class News < ActiveRecord::Base
end
private
def add_news_count
if self.project
count = self.project.news_count + 1
self.project.update_attribute(:news_count, count)
end
end
def add_author_as_watcher
Watcher.create(:watchable => self, :user => author)
end
## fq
def act_as_activity
self.acts << Activity.new(:user_id => self.author_id)
@ -161,6 +168,13 @@ 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

View File

@ -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,21 +1223,21 @@ 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

View File

@ -76,12 +76,13 @@
<div class="cl"></div>
<div>
<% if @project.project_type == 0 %>
<% unless project_scores(@project) == 0 %>
<% unless static_project_score(@project) == 0 %>
<span class="fb f14 "><%= l(:label_project_score)%> :</span>
<%= link_to(format("%.2f" ,project_scores(@project) ).to_i, {:controller => 'projects',
:action => 'show_projects_score',
:remote => true,
:id => @project.id}, :class => "c_orange f14" ) %>
<%= link_to(format("%.2f" ,static_project_score(@project) ).to_i,
{:controller => 'projects',
:action => 'show_projects_score',
:remote => true,
:id => @project.id}, :class => "c_orange f14" ) %>
<% end %>
<% end %>
</div>
@ -91,12 +92,11 @@
<%= l(:label_member) %><%= link_to "#{@project.members.count}", project_member_path(@project), :class => 'info_foot_num c_blue', :id => 'project_members_number' %>
<span>|&nbsp;</span>
<%= l(:label_user_watcher) %><%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :class => 'info_foot_num c_blue' %>
<% attaments_num = @project.attachments.count %>
<% unless @project.enabled_modules.where("name = 'files'").empty? %>
<span>|&nbsp;</span>
<%= l(:project_module_attachments) %>
<% attaments_num %>
<%= link_to "#{attaments_num}", project_files_path(@project), :class => 'info_foot_num c_blue', :id=>'project_files_count_info' %></span>
<% @project.attachments_count %>
<%= link_to "#{@project.attachments_count}", project_files_path(@project), :class => 'info_foot_num c_blue', :id=>'project_files_count_info' %></span>
<% end %>
</div>
<div class="cl"></div>
@ -120,11 +120,11 @@
<div id="project_memu_list">
<% if @project.project_new_type == 1 || @project.project_new_type.nil? %>
<%= render :partial => 'projects/development_group', :locals => {:project => @project, :attaments_num => attaments_num} %>
<%= render :partial => 'projects/development_group', :locals => {:project => @project} %>
<% elsif @project.project_new_type == 2 %>
<%= render :partial => 'projects/research_team', :locals => {:project => @project, :attaments_num => attaments_num} %>
<%= render :partial => 'projects/research_team', :locals => {:project => @project} %>
<% else %>
<%= render :partial => 'projects/friend_group', :locals => {:project => @project, :attaments_num => attaments_num} %>
<%= render :partial => 'projects/friend_group', :locals => {:project => @project} %>
<% end %>
</div>
@ -213,19 +213,19 @@
if(data == 1)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_development_team), 1))%>");
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/development_group', :locals => {:project => @project, :attaments_num => attaments_num})) %>');
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/development_group', :locals => {:project => @project})) %>');
$("#close_light").attr("onClick","close_window('development_group');");
}
else if(data == 2)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_research_group), 2))%>");
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/research_team', :locals => {:project => @project, :attaments_num => attaments_num})) %>');
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/research_team', :locals => {:project => @project})) %>');
$("#close_light").attr("onClick","close_window('research_group');");
}
else if(data == 3)
{
$("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_friend_organization), 3))%>");
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/friend_group', :locals => {:project => @project, :attaments_num => attaments_num})) %>');
$("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/friend_group', :locals => {:project => @project})) %>');
$("#close_light").attr("onClick","close_window('friend_organization');");
}
else

View File

@ -1,14 +1,14 @@
<div class="subNav">
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
<a class="subnav_num">(<%= ForgeActivity.where("project_id = ?", @project.id).count %>)</a>
<% unless @project.acts_count == 0 %>
<a class="subnav_num">(<%= @project.acts_count %>)</a>
<% end %>
</div>
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<div class="subNav">
<%= link_to l(:label_issue_tracking), project_issues_path(@project), :class => "f14 c_blue02" %>
<% if (issue_count = @project.issues.count) > 0 %>
<a class="subnav_num">(<%= issue_count %>)</a>
<%= link_to l(:label_issue_tracking), project_issues_path(@project, :remote => true), :class => "f14 c_blue02" %>
<% if @project.issues_count > 0 %>
<a class="subnav_num">(<%= @project.issues_count %>)</a>
<% end %>
<% if User.current.member_of?(@project) %>
@ -19,8 +19,8 @@
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<div class="subNav">
<%= link_to l(:project_module_boards), project_boards_path(@project), :class => "f14 c_blue02" %>
<% unless @project.boards.first.topics.count == 0 %>
<a class="subnav_num">(<%= @project.boards.first.topics.count %>)</a>
<% unless @project.boards_count == 0 %>
<a class="subnav_num">(<%= @project.boards_count %>)</a>
<% 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? %>
<div class="subNav">
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
<% unless attaments_num == 0 %>
<%= link_to "(#{attaments_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% unless @project.attachments_count == 0 %>
<%= link_to "(#{@project.attachments_count})", 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" %>

View File

@ -1,14 +1,14 @@
<div class="subNav">
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
<a class="subnav_num">(<%= ForgeActivity.where("project_id = ?", @project.id).count %>)</a>
<% unless @project.acts_count == 0 %>
<a class="subnav_num">(<%= @project.acts_count %>)</a>
<% end %>
</div>
<% unless @project.enabled_modules.where("name = 'boards'").empty? %>
<div class="subNav">
<%= link_to l(:project_module_boards), project_boards_path(@project), :class => "f14 c_blue02" %>
<% unless @project.boards.first.topics.count == 0 %>
<a class="subnav_num">(<%= @project.boards.first.topics.count %>)</a>
<% unless @project.boards_count == 0 %>
<a class="subnav_num">(<%= @project.boards_count %>)</a>
<% 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? %>
<div class="subNav">
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
<% unless attaments_num == 0 %>
<%= link_to "(#{attaments_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% unless @project.attachments_count == 0 %>
<%= link_to "(#{@project.attachments_count})", 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" %>

View File

@ -1,10 +1,9 @@
<!-- added by bai -->
<div style="color: #64BDD9;font-size: 14px;font-weight: bold"><%= l(:label_projects_score) %></div>
<div> = <%= l(:label_issue_score) %> + <%= l(:label_news_score) %> + <%= l(:label_file_score) %> +
<%= l(:label_code_submit_score) %> + <%= l(:label_topic_score) %></div>
<div> = <%= format("%.2f" , issue_score(project)).to_i %> + <%= format("%.2f" , news_score(project)).to_i %> +
<%= format("%.2f" , documents_score(project)).to_i %> + <%= format("%.2f" , changesets_score(project)).to_i %> +
<%= format("%.2f" , board_message_score(project)).to_i %></div>
<div> = <%= format("%.2f" , project_scores(project)).to_i %></div>
<!-- end -->
<div> = <%= l(:label_code_submit_score) %> + <%= l(:label_issue_score) %> + <%= l(:label_file_attachment_score) %> + <%= l(:label_topic_score) %> + <%= l(:label_news_score) %></div>
<div> = <%= @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 %>
</div>
<div> = <%= static_project_score(@project) %></div>

View File

@ -1,14 +1,14 @@
<div class="subNav">
<%= link_to l(:label_activity), {:controller => 'projects', :action => 'show', :id => @project.id}, :class => "f14 c_blue02" %>
<% unless ForgeActivity.where("project_id = ?", @project.id).count == 0 %>
<a class="subnav_num">(<%= ForgeActivity.where("project_id = ?", @project.id).count %>)</a>
<% unless @project.acts_count == 0 %>
<a class="subnav_num">(<%= @project.acts_count %>)</a>
<% end %>
</div>
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>
<div class="subNav">
<%= link_to l(:label_issue_tracking), project_issues_path(@project), :class => "f14 c_blue02" %>
<% if (issue_count = @project.issues.count) > 0 %>
<a class="subnav_num">(<%= issue_count %>)</a>
<% if @project.issues_count > 0 %>
<a class="subnav_num">(<%= @project.issues_count %>)</a>
<% 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? %>
<div class="subNav">
<%= link_to l(:project_module_boards), project_boards_path(@project), :class => "f14 c_blue02" %>
<% unless @project.boards.first.topics.count == 0 %>
<a class="subnav_num">(<%= @project.boards.first.topics.count %>)</a>
<% unless @project.boards_count == 0 %>
<a class="subnav_num">(<%= @project.boards_count %>)</a>
<% 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? %>
<div class="subNav">
<%= link_to l(:project_module_files), project_files_path(@project), :class => "f14 c_blue02" %>
<% unless attaments_num == 0 %>
<%= link_to "(#{attaments_num})", project_files_path(@project), :class => "subnav_num c_orange",:id=>'project_files_count_nav' %>
<% unless @project.attachments_count == 0 %>
<%= link_to "(#{@project.attachments_count})", 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" %>

View File

@ -1,5 +1,3 @@
<!-- added by bai -->
<h3 class="title"><%= l(:label_projects_score) %></h3>
<div class="inf_user_image">
<table style="border-bottom: solid 1px #80a6d2;" width="100%">
@ -14,72 +12,35 @@
<td width="35%">
<table>
<tr class="info_font" style="color: #64BDD9;font-size: 14px;font-weight: bold"><td><%= l(:label_projects_score) %></td></tr>
<tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= format("%.2f" , project_scores(@project) ).to_i %></span></td></tr>
<tr class="buttons_for_score" style="margin-top:30px;margin-left:144px"><td><span style="color:#ec6300"><%= static_project_score(@project) %></span></td></tr>
</table>
</td>
</tr>
</table>
</div>
<script type="text/javascript">
function show_div(url)
{
if(url == 'project_score_index')
{
$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/project_score_index', :locals => {:project => @project}) %>');
}
else if(url == 'issue_score_index')
{
$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/issue_score_index', :locals => {:project => @project}) %>');
}
else if(url == 'news_score_index')
{
$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/news_score_index', :locals => {:project => @project}) %>');
}
else if(url == 'file_score_index')
{
$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/file_score_index', :locals => {:project => @project}) %>');
}
else if(url == 'code_submit_score_index')
{
$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/code_submit_score_index', :locals => {:project => @project}) %>');
}
else if(url == 'projects_topic_score_index')
{
$('#show_score_detail').html('<%= escape_javascript(render :partial => 'projects/projects_topic_score_index', :locals => {:project => @project}) %>');
}
}
</script>
<div class="tabs_new">
<ul>
<li>
<%= link_to l(:label_projects_score),"javascript:void(0)", :onclick => "show_div('project_score_index')"%> :
<%= format("%.2f" , project_scores(@project) ).to_i %>
<%= link_to l(:label_projects_score),"javascript:void(0)", :onclick => "show_div('project_score_index')"%> : <%= static_project_score(@project) %>
</li>
<li>
<%= link_to l(:label_code_submit_score), "javascript:void(0)", :onclick => "show_div('code_submit_score_index')" %> : <%= @project.commits_count * 4 %>
</li>
<li>
<%= link_to l(:label_issue_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> :
<%= format("%.2f" , issue_score(@project)).to_i %>
<%= link_to l(:label_issue_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.issues_count * 4 + @project.journals_count %>
</li>
<li>
<%= link_to l(:label_news_score), "javascript:void(0)", :onclick => "show_div('news_score_index')"%> :
<%= format("%.2f" , news_score(@project)).to_i %>
<li>
<%= link_to l(:label_file_attachment_score), "javascript:void(0)", :onclick => "show_div('issue_score_index')"%> : <%= @project.attachments_count * 5 %>
</li>
<li>
<%= link_to l(:label_topic_score), "javascript:void(0)", :onclick => "show_div('projects_topic_score_index')"%> : <%= @project.boards_count * 2 + @project.boards_reply_count %>
</li>
<li>
<%= link_to l(:label_file_score), "javascript:void(0)", :onclick => "show_div('file_score_index')"%> :
<%= format("%.2f" , documents_score(@project)).to_i %>
</li>
<li>
<%= link_to l(:label_code_submit_score), "javascript:void(0)", :onclick => "show_div('code_submit_score_index')" %> :
<%= format("%.2f" , changesets_score(@project)).to_i %>
</li>
<li>
<%= link_to l(:label_topic_score), "javascript:void(0)", :onclick => "show_div('projects_topic_score_index')"%> :
<%= format("%.2f" , board_message_score(@project)).to_i %>
<%= link_to l(:label_news_score), "javascript:void(0)", :onclick => "show_div('news_score_index')"%> : <%= @project.news_count %>
</li>
</ul>
</div>
<div id="show_score_detail">
<%= render :partial => 'projects/project_score_index', :locals => {:project => @project } %>
</div>
<!-- end -->
</div>

View File

@ -1,10 +1,8 @@
<div class="boxContainer">
<div>
<div class="sendText fl mr10" style="width: auto">发送到</div>
<div class="resourcesSendTo">
<select class="resourcesSendType" onclick="chooseSendType('<%= send_id%>','<%= send_ids%>');">
<select class="resourcesSendType" onclick="chooseSendType('<%= send_id %>','<%= send_ids %>');">
<option value="1">课程</option>
<option value="2" selected>项目</option>
<option value="3">组织</option>
@ -20,13 +18,13 @@
<%= hidden_field_tag(:send_ids, send_ids) %>
<input type="text" id="search_project_input" value="<%= @search %>" name="search" placeholder="输入项目ID或者名称搜索" class="searchResourcePopup" />
<script>
observeSearchfieldOnInput('search_project_input','<%= search_user_project_user_path(user)%>','<%= send_id %>','<%= send_ids%>')
observeSearchfieldOnInput('search_project_input','<%= search_user_project_user_path(user)%>','<%= send_id %>','<%= send_ids %>')
</script>
<!--<a href="javascript:void(0);" class="searchIconPopup"></a>-->
<%= submit_tag '',:class=>'searchIcon2',:onfocus=>"this.blur();",:style=>'border-style:none' %>
<% end %>
</div>
<%= form_tag add_exist_file_to_project_user_path(user),:remote=>true,:id=>'projects_list_form' %>
<%= form_tag add_exist_file_to_project_user_path(user), :remote => true, :id=>'projects_list_form' %>
<div>
<%= hidden_field_tag(:send_id, send_id) %>

View File

@ -1,11 +1,4 @@
//var popupHeight = $(".resourceSharePopup").outerHeight(true);
//$(".resourceSharePopup").css("marginTop",-popupHeight/2);
//
//$("#upload_box").css('left','').css('top','');
//$("#upload_box").html('<%#= escape_javascript( render :partial => "resource_share_for_project_popup" ,:locals => {:projects=>@projects,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
//$("#upload_box").css('display','block');
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_project_popup' ,:locals => {:projects=>@projects,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>');
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_project_popup', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");

View File

@ -432,6 +432,8 @@ zh:
label_file_score: 文档得分
label_file_number: 文档的数量
label_file_attachment_score: 资源得分
label_code_submit_score: 代码提交得分
label_code_submit_number: 代码提交频率

View File

@ -0,0 +1,5 @@
class AddIssuesCountToProject < ActiveRecord::Migration
def change
add_column :projects, :issues_count, :integer, :default => false
end
end

View File

@ -0,0 +1,5 @@
class AddAttachmentsCountToProject < ActiveRecord::Migration
def change
add_column :projects, :attachments_count, :integer, :default => false
end
end

View File

@ -0,0 +1,5 @@
class AddBoardsCountToProject < ActiveRecord::Migration
def change
add_column :projects, :boards_count, :integer, :default => false
end
end

View File

@ -0,0 +1,5 @@
class AddNewsCountToProject < ActiveRecord::Migration
def change
add_column :projects, :news_count, :integer, :default => false
end
end

View File

@ -0,0 +1,14 @@
class StaticProjectBoards < ActiveRecord::Migration
def up
Project.all.each do |project|
puts project.id
unless project.boards.first.nil?
boards_count = project.boards.first.topics.count
project.update_attribute(:boards_count, boards_count)
end
end
end
def down
end
end

View File

@ -0,0 +1,13 @@
class StaticProjectIssues < ActiveRecord::Migration
def up
Project.all.each do |project|
unless project.issues.nil?
issues_count = project.issues.count
project.update_attribute(:issues_count, issues_count)
end
end
end
def down
end
end

View File

@ -0,0 +1,13 @@
class StaticProjectNews < ActiveRecord::Migration
def up
Project.all.each do |project|
unless project.news.nil?
news_count = project.news.count
project.update_attribute(:news_count, news_count)
end
end
end
def down
end
end

View File

@ -0,0 +1,13 @@
class StaticProjectAttachments < ActiveRecord::Migration
def up
Project.all.each do |project|
unless project.attachments.nil?
attachments_count = project.attachments.count
project.update_attribute(:attachments_count, attachments_count)
end
end
end
def down
end
end

View File

@ -0,0 +1,5 @@
class AddActsCountToProject < ActiveRecord::Migration
def change
add_column :projects, :acts_count, :integer, :default => false
end
end

View File

@ -0,0 +1,16 @@
class StaticProjectActs < ActiveRecord::Migration
def up
Project.all.each do |project|
acts = ForgeActivity.where("project_id = ?", project.id)
unless acts.blank?
count = acts.count
puts project.id
puts "acts_count is #{count}"
project.update_attribute(:acts_count, count)
end
end
end
def down
end
end

View File

@ -0,0 +1,5 @@
class AddJournalsCountToProject < ActiveRecord::Migration
def change
add_column :projects, :journals_count, :integer, :default => false
end
end

View File

@ -0,0 +1,12 @@
class StaticsIssueJournal < ActiveRecord::Migration
def up
Project.all.each do |project|
if !project.project_score.nil? && !project.project_score.issue_journal_num.nil?
project.update_attribute(:journals_count, project.project_score.issue_journal_num)
end
end
end
def down
end
end

View File

@ -0,0 +1,19 @@
class StaticsRepositoryCommits < ActiveRecord::Migration
def up
g = Gitlab.client
Project.all.each do |project|
unless project.gpid.nil?
begin
puts project.id
count = g.project(project.gpid).commit_count
rescue
logger.error("The project's rep is not exit!")
end
project.update_attribute(:commits_count, count)
end
end
end
def down
end
end

View File

@ -0,0 +1,5 @@
class AddMessagesCountToProject < ActiveRecord::Migration
def change
add_column :projects, :boards_reply_count, :integer, :default => false
end
end

View File

@ -0,0 +1,14 @@
class StaticsBoardsReply < ActiveRecord::Migration
def up
Project.all.each do |project|
puts project.id
unless project.boards.first.nil?
messages_count = Message.where("board_id =? and parent_id is not ?", project.boards.first.id, nil).count
project.update_attribute(:boards_reply_count, messages_count)
end
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160108024752) do
ActiveRecord::Schema.define(:version => 20160113064153) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1411,6 +1411,13 @@ ActiveRecord::Schema.define(:version => 20160108024752) do
t.integer "forked_count"
t.integer "commits_count", :default => 0
t.integer "publish_resource", :default => 0
t.integer "issues_count", :default => 0
t.integer "attachments_count", :default => 0
t.integer "boards_count", :default => 0
t.integer "news_count", :default => 0
t.integer "acts_count", :default => 0
t.integer "journals_count", :default => 0
t.integer "boards_reply_count", :default => 0
end
add_index "projects", ["lft"], :name => "index_projects_on_lft"

View File

@ -5,6 +5,8 @@ module Trustie
module Gitlab
module ManageMember
attr :g
include Helper
def self.included(base)
base.class_eval {
before_create :add_gitlab_member

View File

@ -52,6 +52,7 @@ table.filecontent th.line-num {
-ms-user-select: none;
-webkit-user-select: none;
font-weight:normal;
white-space: nowrap;
}
table.filecontent th.line-num a {
text-decoration: none;