From aab24ea34a64504019a938165fcbe6721be6ff40 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 11 Nov 2016 10:37:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=A1=B6=E9=83=A8fork?= =?UTF-8?q?=E8=B7=AF=E7=94=B1=E9=94=99=E8=AF=AF=EF=BC=8C=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?fork=E8=BF=87=E8=AF=A5=E9=A1=B9=E7=9B=AE=E7=9A=84=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 2 +- app/helpers/application_helper.rb | 12 ++++++++++++ app/models/journals_for_message.rb | 2 +- app/views/projects/_applied_status.html.erb | 2 +- app/views/repositories/_forked_popbox.html.erb | 9 ++++++--- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 107f2ff88..a2a78fd9d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -27,7 +27,7 @@ class ProjectsController < ApplicationController menu_item :feedback, :only => :feedback menu_item :share, :only => :share - before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project, :forked_pop] + before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project] before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :unarchive, :destroy, :calendar] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c32f6c175..e8cb002a8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -54,6 +54,18 @@ module ApplicationHelper Project.find(forked_from_project_id) end + # 判断当前用户是否已经fork过当前项目 + # project: current_project + def has_forked_cur_project project + cur_user_projects = Project.where(:user_id => User.current.id) + if cur_user_projects.count == 0 + false + else + has_forked = cur_user_projects.select{|cur_user_project| cur_user_project.forked_from_project_id == project.id} + has_forked.length > 0 ? true : false + end + end + # 通过系统外部邮箱查找用户,如果用户不存在则用邮箱替换 def get_user_by_mail mail user = User.find_by_mail(mail) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 2a432d42f..4a9601d07 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -78,7 +78,7 @@ class JournalsForMessage < ActiveRecord::Base :act_as_principal_activity, :act_as_student_score after_create :reset_counters! #after_update :update_activity - after_destroy :reset_counters! + # after_destroy :reset_counters! after_save :be_user_score after_destroy :down_user_score, :down_course_score diff --git a/app/views/projects/_applied_status.html.erb b/app/views/projects/_applied_status.html.erb index 17392f2c5..41bb08cbc 100644 --- a/app/views/projects/_applied_status.html.erb +++ b/app/views/projects/_applied_status.html.erb @@ -33,7 +33,7 @@ -->
  • - <%= link_to "".html_safe+"Fork", {:controller => 'projects', :action => 'forked_pop'}, + <%= link_to "".html_safe+"Fork", forked_pop_project_path(@project), :class=>"pro_new_topbtn_left fl", :remote => true %> <%= @project.forked_count.to_i %>
  • diff --git a/app/views/repositories/_forked_popbox.html.erb b/app/views/repositories/_forked_popbox.html.erb index bb277e46f..a8c249b3a 100644 --- a/app/views/repositories/_forked_popbox.html.erb +++ b/app/views/repositories/_forked_popbox.html.erb @@ -7,14 +7,17 @@