From 74603e1256ccfa2ec2b733ad5e84a969fd33b322 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 26 Jun 2014 17:55:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=9B=B4=E6=8E=A5=E8=AE=BF?= =?UTF-8?q?=E9=97=AEajax=E9=93=BE=E6=8E=A5=E5=9C=B0=E5=9D=80=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 6 +- app/controllers/users_controller.rb | 4 +- .../projects/_show_projects_score.html.erb | 2 +- .../projects/show_projects_score.html.erb | 97 +++++++++++++++++++ app/views/users/show_new_score.html.erb | 91 +++++++++++++++++ 5 files changed, 195 insertions(+), 5 deletions(-) create mode 100644 app/views/projects/show_projects_score.html.erb create mode 100644 app/views/users/show_new_score.html.erb diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 8c27068fc..b357ac44f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -918,11 +918,13 @@ class ProjectsController < ApplicationController # added by bai def show_projects_score - + render :layout => false end def issue_score_index - + respond_to do |format| + format.js + end end def news_score_index diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4995c885f..f78112c21 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -94,11 +94,11 @@ class UsersController < ApplicationController # added by bai def show_score - + end def show_new_score - + render :layout => false end # end diff --git a/app/views/projects/_show_projects_score.html.erb b/app/views/projects/_show_projects_score.html.erb index e9b21e571..d135cfbdb 100644 --- a/app/views/projects/_show_projects_score.html.erb +++ b/app/views/projects/_show_projects_score.html.erb @@ -28,7 +28,7 @@

<%= l(:label_projects_score) %>

- +
<%= image_tag(url_to_avatar(@project), :class => 'avatar2') %> diff --git a/app/views/projects/show_projects_score.html.erb b/app/views/projects/show_projects_score.html.erb new file mode 100644 index 000000000..95a7085d4 --- /dev/null +++ b/app/views/projects/show_projects_score.html.erb @@ -0,0 +1,97 @@ + +<% issue_count = @project.issues.count %> +<% issue_journal_count = @project.issue_changes.count %> +<% issue_score = issue_count * 0.2 %> +<% issue_journal_score = issue_journal_count * 0.1 %> +<% finall_issue_score = issue_score + issue_journal_score %> + +<% new_count = @project.news.count %> +<% new_score = new_count * 0.1 %> +<% finall_new_score = new_score %> + +<% document_count = @project.documents.count %> +<% file_score = document_count * 0.1 %> +<% finall_file_score = file_score %> + +<% changeset_count = @project.changesets.count %> +<% code_submit_score = changeset_count * 0.3 %> +<% finall_code_submit_score = code_submit_score %> + +<% board_message_count = 0 %> +<% @project.boards.each do |board| %> + <% board_message_count += board.messages_count %> +<% end %> +<% topic_score = board_message_count * 0.1 %> +<% finall_topic_score = topic_score %> + +<% finall_project_score = finall_issue_score + finall_new_score + finall_file_score + finall_code_submit_score + topic_score %> + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> + <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= hubspot_head %> + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> + + +

<%= l(:label_projects_score) %>

+
+ + + + + + +
<%= image_tag(url_to_avatar(@project), :class => 'avatar2') %> + + + +
<%= @project.name %>
+
+ + + +
<%= l(:label_projects_score) %>
<%= format("%.2f" , finall_project_score ).to_f %>
+
+
+ +
+
    +
  • + <%= link_to l(:label_projects_score), {:controller => 'projects', :action => 'show_projects_score', :remote => true}%> : + <%= format("%.2f" , finall_project_score ).to_f %> +
  • +
  • + <%= link_to l(:label_issue_score), {:controller => 'projects', :action => 'issue_score_index', :remote => true}%> : + <%= format("%.2f" , finall_issue_score).to_f %> +
  • +
  • + <%= link_to l(:label_news_score), {:controller => 'projects', :action => 'news_score_index', :remote => true}%> : + <%= format("%.2f" , finall_new_score).to_f %> +
  • +
  • + <%= link_to l(:label_file_score), {:controller => 'projects', :action => 'file_score_index', :remote => true}%> : + <%= format("%.2f" , finall_file_score).to_f %> +
  • +
  • + <%= link_to l(:label_code_submit_score), {:controller => 'projects', :action => 'code_submit_score_index', :remote => true}%> : + <%= format("%.2f" , finall_code_submit_score).to_f %> +
  • +
  • + <%= link_to l(:label_topic_score), {:controller => 'projects', :action => 'projects_topic_score_index', :remote => true}%> : + <%= format("%.2f" , finall_topic_score).to_f %> +
  • +
+
+
+ <%= render :partial => 'projects/project_score_index', :locals => {:index => 0 } %> +
+ \ No newline at end of file diff --git a/app/views/users/show_new_score.html.erb b/app/views/users/show_new_score.html.erb new file mode 100644 index 000000000..07e82fd5f --- /dev/null +++ b/app/views/users/show_new_score.html.erb @@ -0,0 +1,91 @@ + +<% messages_count = @user.messages.count %> +<% messages_score = messages_count * 0.05%> +<% finall_messages_score = messages_score %> + +<% journals_count = @user.journals.count %> +<% journals_score = journals_count * 0.1 %> +<% user_changesets_count = @user.changesets.count %> +<% user_changesets_score = user_changesets_count * 0.3 %> +<% finall_user_project_score = journals_score + user_changesets_score %> + +<% journals_for_messages_count = @user.journals_messages.count %> +<% activities_count = @user.activities.count %> +<% journals_for_messages_score = journals_for_messages_count * 0.05 %> +<% activities_score = activities_count * 0.2 %> +<% finall_activity_score = journals_for_messages_score + activities_score %> + +<% news_count = @user.news.count %> +<% news_score = news_count * 0.1 %> +<% wiki_contents_count = @user.wiki_contents.count %> +<% wiki_contents_score = wiki_contents_count * 0.1 %> +<% comments_count = @user.comments.count %> +<% comments_score = comments_count * 0.1 %> +<% finall_influence_score = news_score + wiki_contents_score + comments_score %> +<% finall_user_score = finall_messages_score + finall_user_project_score + finall_activity_score + finall_influence_score %> + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> + <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= hubspot_head %> + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> + +

<%= l(:label_user_score) %>

+
+ + + + + + + + +
<%= image_tag(url_to_avatar(@user), :class => 'avatar2') %> + + + +
<%= h @user.name %>
<%= @user.user_extensions.show_identity %>
+
+ + + +
<%= l(:label_user_score) %>
<%= format("%.2f" , @user.user_score_attr.total_score).to_f %>
+
+ + + + <%= l(:label_user_score) %> : + <%= format("%.2f" , @user.user_score_attr.total_score).to_f %> +
+ + <%= l(:label_user_score_of_collaboration) %> : + <%= format("%.2f" , @user.user_score_attr.collaboration.nil? ? 0:@user.user_score_attr.collaboration).to_f %> +
+ + <%= l(:label_user_score_of_influence) %> : + <%= format("%.2f" , @user.user_score_attr.influence.nil? ? 0:@user.user_score_attr.influence).to_f %> +
+ + <%= l(:label_user_score_of_skill) %> : + <%= format("%.2f" , @user.user_score_attr.skill.nil? ? 0:@user.user_score_attr.skill).to_f %> +
+ + <%= l(:label_user_score_of_active) %> : + <%= format("%.2f" , @user.user_score_attr.active.nil? ? 0:@user.user_score_attr.active).to_f %> +
+
+ +
+ +
+ <%= render :partial => 'users/score_new_index', :locals => {:index => 0 } %> +