From 2a1a0513624a35a53263d22b63b198f7ccc00003 Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 14 Jul 2014 15:15:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AF=86=E7=BA=A7BUG=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 113 ++++++++++-------- .../_course_show_all_attachment.html.erb | 2 +- .../_course_sort_by_attachtypel.html.erb | 2 +- db/schema.rb | 3 +- 4 files changed, 69 insertions(+), 51 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index b86630d98..a89f224b6 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -92,57 +92,74 @@ class RepositoriesController < ApplicationController end def create - ##xianbo - @root_path=RepositoriesHelper::ROOT_PATH - @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" - @project_path=@root_path+"htdocs/"+@repository_name - @repository_tag=params[:repository][:upassword] - @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] - logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag - logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name - attrs = pickup_extra_info - if((@repository_tag!="")&¶ms[:repository_scm]=="Git") + if params[:repository_scm].to_s == 'Gitlab' + # add by nwb + # 增加对gitlab版本库的支持 + attrs = pickup_extra_info + @repository = Repository.factory(params[:repository_scm]) + @repository.safe_attributes = params[:repository] + if attrs[:attrs_extra].keys.any? + @repository.merge_extra_info(attrs[:attrs_extra]) + end + @repository.project = @project + if request.post? && @repository.save + redirect_to settings_project_path(@project, :tab => 'repositories') + else + render :action => 'new' + end + else # 原逻辑 + ##xianbo + @root_path=RepositoriesHelper::ROOT_PATH + @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" + @project_path=@root_path+"htdocs/"+@repository_name + @repository_tag=params[:repository][:upassword] + @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] + logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag + logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name + attrs = pickup_extra_info + if((@repository_tag!="")&¶ms[:repository_scm]=="Git") params[:repository][:url]=@project_path - end - ###xianbo - @repository = Repository.factory(params[:repository_scm]) - @repository.safe_attributes = params[:repository] - if attrs[:attrs_extra].keys.any? - @repository.merge_extra_info(attrs[:attrs_extra]) - end - #by xianbo - - @repository.project = @project - if request.post? && @repository.save - if(params[:repository_scm]=="Git") - system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag - system "echo -e '"+@repo_name+"-write:"+ - " "+@repo_name+"' >> "+@root_path+"group.passwd" - system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s - system "git init --bare "+@project_path - system "mv "+@project_path+"/hooks/post-update{.sample,}" - system "chmod a+x "+@project_path+"/hooks/post-update" - system "echo -e 'Allow from all \n Order Deny,Allow \n "+ - " \n"+ - "Require group "+@repo_name+"-write \n "+ - " \n ' >> "+ - @root_path+"htdocs/"+ @repository_name+"/.htaccess" - system "cd "+@project_path+" ;git update-server-info" - # if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info) - # else - # logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+ - # crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+ - # "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info - # end + end + ###xianbo + @repository = Repository.factory(params[:repository_scm]) + @repository.safe_attributes = params[:repository] + if attrs[:attrs_extra].keys.any? + @repository.merge_extra_info(attrs[:attrs_extra]) + end + #by xianbo + + @repository.project = @project + if request.post? && @repository.save + if(params[:repository_scm]=="Git") + system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag + system "echo -e '"+@repo_name+"-write:"+ + " "+@repo_name+"' >> "+@root_path+"group.passwd" + system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s + system "git init --bare "+@project_path + system "mv "+@project_path+"/hooks/post-update{.sample,}" + system "chmod a+x "+@project_path+"/hooks/post-update" + system "echo -e 'Allow from all \n Order Deny,Allow \n "+ + " \n"+ + "Require group "+@repo_name+"-write \n "+ + " \n ' >> "+ + @root_path+"htdocs/"+ @repository_name+"/.htaccess" + system "cd "+@project_path+" ;git update-server-info" + # if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info) + # else + # logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+ + # crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+ + # "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info + # end @repository.update_attributes(:login => User.current.login.to_s) - end - redirect_to settings_project_path(@project, :tab => 'repositories') - else if(@repository_tag) - render :action => 'newrepo', :layout =>'base_projects' - else - render :action => 'new', :layout =>'base_projects' + end + redirect_to settings_project_path(@project, :tab => 'repositories') + else if(@repository_tag) + render :action => 'newrepo', :layout =>'base_projects' + else + render :action => 'new', :layout =>'base_projects' + end + end end - end end def edit diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb index a6da426c6..f94ddc20b 100644 --- a/app/views/files/_course_show_all_attachment.html.erb +++ b/app/views/files/_course_show_all_attachment.html.erb @@ -35,7 +35,7 @@ <% end -%> <% container.attachments.each do |file| %> - <%if file.is_public == 0 && !User.current.member_of?(@project)%> + <%if file.is_public == 0 && !User.current.member_of_course?(@course)%> <%next%> <%end%> "> diff --git a/app/views/files/_course_sort_by_attachtypel.html.erb b/app/views/files/_course_sort_by_attachtypel.html.erb index cda832493..f0f6c8270 100644 --- a/app/views/files/_course_sort_by_attachtypel.html.erb +++ b/app/views/files/_course_sort_by_attachtypel.html.erb @@ -28,7 +28,7 @@ <% @containers.each do |container| %> <% next if container.attachments.empty? -%> <% container.attachments.each do |file| %> - <% if file.is_public == 0 && !User.current.member_of?(@project) %> + <% if file.is_public == 0 && !User.current.member_of_course?(@course) %> <% next %> <% end %> <% if isTypeOk(file, selAttachType, selContentType) %> diff --git a/db/schema.rb b/db/schema.rb index fa41ed1d5..a304bf94f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140711012924) do +ActiveRecord::Schema.define(:version => 20140714021812) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -379,6 +379,7 @@ ActiveRecord::Schema.define(:version => 20140711012924) do t.text "description" t.datetime "created_on" t.integer "user_id", :default => 0 + t.integer "is_public", :default => 1 end add_index "documents", ["category_id"], :name => "index_documents_on_category_id"