From f67386e8a0dda4903f6dabd1c6d3fd455fbc62d9 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 7 Dec 2015 10:06:51 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E4=BB=A3=E7=A0=81=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index b326051e6..85f57917b 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -37,6 +37,19 @@ class OrganizationsController < ApplicationController @organization = Organization.new render :layout => 'new_base' end + + def edit + @organization = Organization.find(params[:id]) + end + + def destroy + @organization = Organization.find(params[:id]) + @organization.destroy + respond_to do |format| + format.html{ redirect_to admin_organization_path } + end + end + def create @organization = Organization.new @organization.name = params[:organization][:name] @@ -142,6 +155,12 @@ class OrganizationsController < ApplicationController # end end + def cancel_homepage + @org = Organization.find(params[:id]) + @org.home_id = nil + @org.save + end + def autocomplete_search @project = Project.find(params[:project_id]) #@flag = params[:flag] || false From ab1c945a305c938ea7e44ae76ba204f24201f62e Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 7 Dec 2015 10:34:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=BA=93=E5=BA=93=E6=9D=83=E9=99=90=20=E8=87=AA=E5=B7=B1?= =?UTF-8?q?=E4=B8=8D=E8=83=BDfork=E8=87=AA=E5=B7=B1=E7=9A=84=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 15 +++++++-------- app/views/repositories/show.html.erb | 5 +++-- config/locales/projects/zh.yml | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index c1e124063..ca07dccdc 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -31,7 +31,7 @@ class RepositoriesController < ApplicationController default_search_scope :changesets before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo] - before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] + before_filter :find_repository, :only => [:edit, :update, :destroy, :committers, :forked] before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo,:to_gitlab] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked] @@ -69,9 +69,11 @@ class RepositoriesController < ApplicationController project = project_from_current_project(@project.id, User.current.id) redirect_to project_path(project) else - # 单个用户只能拥有一个名字一样的版本库,否则不能fork - # if is_sigle_identifier?(User.current, @repository.identifier) - # REDO: 那些人有权限forked项目 + # 自己不能fork自己的项目 + if User.current.id == @project.user_id + flash[:notice] = l(:project_gitlab_fork_own) + redirect_to repository_url(@repository) + else g = Gitlab.client gproject = g.fork(@project.gpid, User.current.gid) if gproject @@ -79,10 +81,7 @@ class RepositoriesController < ApplicationController forked_count = @project.forked_count.to_i + 1 @project.update_attributes(:forked_count => forked_count) end - # else - # flash[:notice] = l(:project_gitlab_fork_double_message) - # redirect_to settings_project_url(@project, :tab => 'repositories') - # end + end end end diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index e7875b49c..be303a2ab 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -26,8 +26,9 @@ - -
<%= link_to "".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'}, :class=>"vl_btn"%> + <% unless User.current.id == @project.user_id %> +
<%= link_to "".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'}, :class=>"vl_btn"%> + <% end %> <%#= link_to "My span #{@user.profile.my_data}".html_safe, "#", class: 'button white' %> <%= @project.forked_count.to_i %>
diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index aebdebd2c..3f86b4b60 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -91,6 +91,7 @@ zh: project_gitlab_create_repository: 新版本库 project_gitlab_create_double_message: 亲,您已经创建了一个同名的版本库,换个特别点的名字同名的概率就会变小哦~ project_gitlab_fork_double_message: 亲,您已经有了一个相同名字的版本库,所以不能fork改版本库~ + project_gitlab_fork_own: 您好,您当前所fork的项目为您自己创建的项目,平台暂时不提供fork自己项目的功能,敬请谅解! label_project_more: 更多