课程资源文件密级BUG修正

This commit is contained in:
nwb 2014-07-14 15:15:28 +08:00
parent 0950ac2329
commit 2a1a051362
4 changed files with 69 additions and 51 deletions

View File

@ -92,57 +92,74 @@ class RepositoriesController < ApplicationController
end end
def create def create
##xianbo if params[:repository_scm].to_s == 'Gitlab'
@root_path=RepositoriesHelper::ROOT_PATH # add by nwb
@repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git" # 增加对gitlab版本库的支持
@project_path=@root_path+"htdocs/"+@repository_name attrs = pickup_extra_info
@repository_tag=params[:repository][:upassword] @repository = Repository.factory(params[:repository_scm])
@repo_name=User.current.login.to_s+"_"+params[:repository][:identifier] @repository.safe_attributes = params[:repository]
logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag if attrs[:attrs_extra].keys.any?
logger.info "the value of create repository"+@root_path+": "+@repository_name+": "+@project_path+": "+@repo_name @repository.merge_extra_info(attrs[:attrs_extra])
attrs = pickup_extra_info end
if((@repository_tag!="")&&params[:repository_scm]=="Git") @repository.project = @project
params[:repository][:url]=@project_path if request.post? && @repository.save
end redirect_to settings_project_path(@project, :tab => 'repositories')
###xianbo else
@repository = Repository.factory(params[:repository_scm]) render :action => 'new'
@repository.safe_attributes = params[:repository] end
if attrs[:attrs_extra].keys.any? else # 原逻辑
@repository.merge_extra_info(attrs[:attrs_extra]) ##xianbo
end @root_path=RepositoriesHelper::ROOT_PATH
#by xianbo @repository_name=User.current.login.to_s+"/"+params[:repository][:identifier]+".git"
@project_path=@root_path+"htdocs/"+@repository_name
@repository.project = @project @repository_tag=params[:repository][:upassword]
if request.post? && @repository.save @repo_name=User.current.login.to_s+"_"+params[:repository][:identifier]
if(params[:repository_scm]=="Git") logger.info "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+": "+@repository_tag
system "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
system "echo -e '"+@repo_name+"-write:"+ attrs = pickup_extra_info
" "+@repo_name+"' >> "+@root_path+"group.passwd" if((@repository_tag!="")&&params[:repository_scm]=="Git")
system "mkdir "+@root_path+"htdocs/"+User.current.login.to_s params[:repository][:url]=@project_path
system "git init --bare "+@project_path end
system "mv "+@project_path+"/hooks/post-update{.sample,}" ###xianbo
system "chmod a+x "+@project_path+"/hooks/post-update" @repository = Repository.factory(params[:repository_scm])
system "echo -e 'Allow from all \n Order Deny,Allow \n "+ @repository.safe_attributes = params[:repository]
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+ if attrs[:attrs_extra].keys.any?
"Require group "+@repo_name+"-write \n "+ @repository.merge_extra_info(attrs[:attrs_extra])
"</Limit> \n ' >> "+ end
@root_path+"htdocs/"+ @repository_name+"/.htaccess" #by xianbo
system "cd "+@project_path+" ;git update-server-info"
# if(create_repo_file&&create_passwd&&create_group&&init_repository&&add_privilege&&init_server_info) @repository.project = @project
# else if request.post? && @repository.save
# logger.info "An error occured when authenticating "+"create passwd"+@creat_passwd+"create_group"+ if(params[:repository_scm]=="Git")
# crate_group+"create repository file "+create_repo_file+"init repository"+init_repostory+ system "htpasswd -mb "+@root_path+"user.passwd "+@repo_name+" "+@repository_tag
# "aad privilege to rpository"+add_privilege+"init server infos"+init_server_info system "echo -e '"+@repo_name+"-write:"+
# end " "+@repo_name+"' >> "+@root_path+"group.passwd"
@repository.update_attributes(:login => User.current.login.to_s) 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 "+
"<Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK> \n"+
"Require group "+@repo_name+"-write \n "+
"</Limit> \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
end 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 def edit

View File

@ -35,7 +35,7 @@
</tr> </tr>
<% end -%> <% end -%>
<% container.attachments.each do |file| %> <% 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%> <%next%>
<%end%> <%end%>
<tr class="file <%= cycle("odd", "odd") %>"> <tr class="file <%= cycle("odd", "odd") %>">

View File

@ -28,7 +28,7 @@
<% @containers.each do |container| %> <% @containers.each do |container| %>
<% next if container.attachments.empty? -%> <% next if container.attachments.empty? -%>
<% container.attachments.each do |file| %> <% 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 %> <% next %>
<% end %> <% end %>
<% if isTypeOk(file, selAttachType, selContentType) %> <% if isTypeOk(file, selAttachType, selContentType) %>

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # 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| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -379,6 +379,7 @@ ActiveRecord::Schema.define(:version => 20140711012924) do
t.text "description" t.text "description"
t.datetime "created_on" t.datetime "created_on"
t.integer "user_id", :default => 0 t.integer "user_id", :default => 0
t.integer "is_public", :default => 1
end end
add_index "documents", ["category_id"], :name => "index_documents_on_category_id" add_index "documents", ["category_id"], :name => "index_documents_on_category_id"