解决顶部fork路由错误,已经fork过该项目的添加提示

This commit is contained in:
huang 2016-11-11 10:37:20 +08:00
parent ec39b2d52c
commit aab24ea34a
5 changed files with 21 additions and 6 deletions

View File

@ -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]

View File

@ -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)

View File

@ -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

View File

@ -33,7 +33,7 @@
</div>-->
<li class="mr5 fl">
<!-- <a href="<%#= {:controller => 'repositories', :action => 'forked'} %>" class="pro_new_topbtn_left fl" target="_blank">Fork</a>-->
<%= link_to "<span class='vl_fork'></span>".html_safe+"Fork", {:controller => 'projects', :action => 'forked_pop'},
<%= link_to "<span class='vl_fork'></span>".html_safe+"Fork", forked_pop_project_path(@project),
:class=>"pro_new_topbtn_left fl", :remote => true %>
<a href="<%= member_forked_project_path(@project) %>" class=" pro_new_topbtn fl"><%= @project.forked_count.to_i %></a>
</li>

View File

@ -7,14 +7,17 @@
<div class="sy_popup_con" style="width:380px;">
<ul class="sy_popup_add" >
<li class="center mb5" style="line-height:20px">
Fork将在后台执行<br>平台将为您创建一个新的同名项目和版本库,请问是否继续?
<% if has_forked_cur_project(@project) %>
您已经Fork过该项目点击“确定”将会跳入您Fork的项目主页请问是否继续
<% else %>
Fork将在后台执行<br>平台将为您创建一个新的同名项目和版本库,请问是否继续?
<% end %>
</li>
<li class="mt10">
<label class="mr27">&nbsp;</label>
<a href="javascript:void(0);" class="sy_btn_grey fl " onclick="hideModal()">取&nbsp;&nbsp;消</a>
<!-- <a href="<%#= {:controller => 'repositories', :action => 'forked'} %>" class="sy_btn_blue fl ml20" onclick="hideModal();">确&nbsp;&nbsp;定</a>-->
<%= link_to "确 定", {:controller => 'repositories', :action => 'forked'},
:class=>"sy_btn_blue fl ml20", :onclick=>"hideModal();" %>
<%= link_to "确 定", {:controller => 'repositories', :action => 'forked'}, :class => "sy_btn_blue fl ml20", :onclick => "hideModal();" %>
<div class="cl"></div>
</li>
</ul>