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 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 @@
ZIP
- -
<%= 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: 更多