From 16c31e254e5f21a9f63be6c149b90964d886bb9e Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 11 Nov 2015 15:33:43 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=8C=BA=E5=88=86Gitlab=E5=85=AC=E5=BC=80?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=92=8C=E7=A7=81=E6=9C=89=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/trustie/gitlab/sync.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/trustie/gitlab/sync.rb b/lib/trustie/gitlab/sync.rb index a303b22fb..ac01a44ec 100644 --- a/lib/trustie/gitlab/sync.rb +++ b/lib/trustie/gitlab/sync.rb @@ -10,6 +10,9 @@ module Trustie DEVELOPER = 30 MASTER = 40 OWNER = 50 + # 项目公开和私有 + PUBLIC = 20 + PRIVATE = 0 end class Sync @@ -45,7 +48,8 @@ module Trustie issues_enabled: false, snippets_enabled: false, public: false, - user_id: gid + user_id: gid, + visibility_level: project.is_public? ? UserLevel::PUBLIC : UserLevel::PRIVATE ) project.gpid = gproject.id project.save! @@ -84,7 +88,8 @@ module Trustie merge_requests_enabled: true, public: false, user_id: gid, - import_url: import_url + import_url: import_url, + visibility_level: project.is_public? ? UserLevel::PUBLIC : UserLevel::PRIVATE ) puts "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" project.gpid = gproject.id From a01de011ca2fbdfc17c345b14050b78014cc33fe Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 11 Nov 2015 16:02:37 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=9A=84=20=E7=A1=AE=E5=AE=9A=E6=8C=89=E9=92=AE=E7=9A=84?= =?UTF-8?q?=E8=81=94=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_attachement_list.html.erb | 2 +- .../files/_new_style_attachment_list.html.erb | 2 +- app/views/files/_upload_course_files.erb | 5 +- app/views/files/_upload_show.html.erb | 3 +- app/views/student_work/new.html.erb | 8 ++- app/views/users/_attachment_list.html.erb | 2 +- ..._special_user_homework_attachment.html.erb | 61 +++++++++++++++++++ app/views/users/_upload_resource.html.erb | 4 +- public/javascripts/attachments.js | 53 ++++++++++------ public/stylesheets/courses.css | 12 ++++ 10 files changed, 121 insertions(+), 31 deletions(-) create mode 100644 app/views/users/_special_user_homework_attachment.html.erb diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index c5a3b9af0..25cc7f68a 100644 --- a/app/views/files/_attachement_list.html.erb +++ b/app/views/files/_attachement_list.html.erb @@ -6,7 +6,7 @@ :id => '_file', :class => ie8? ? '':'file_selector', :multiple => true, - :onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'");', + :onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'","'+'submit_resource'+'");', :style => ie8? ? '': 'display:none', :data => { :max_file_size => Setting.attachment_max_size.to_i.kilobytes, diff --git a/app/views/files/_new_style_attachment_list.html.erb b/app/views/files/_new_style_attachment_list.html.erb index 174a05047..cd33b6507 100644 --- a/app/views/files/_new_style_attachment_list.html.erb +++ b/app/views/files/_new_style_attachment_list.html.erb @@ -5,7 +5,7 @@ :id => "_file#{container.id}", :class => ie8? ? '':'file_selector', :multiple => true, - :onchange => "addInputFiles_board(this, '#{container.id}');", + :onchange => "addInputFiles_board(this, '#{container.id}','"+"submit_resource"+"');", :style => ie8? ? '': 'display:none', :data => { :max_file_size => Setting.attachment_max_size.to_i.kilobytes, diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index 9c7021383..f023e8413 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -22,9 +22,10 @@ <%= render :partial => 'files/new_style_attachment_list',:locals => {:container => course} %>
- <%= l(:button_cancel)%> - <%= l(:button_confirm)%> + <%= l(:button_cancel)%> + + <%= submit_tag '确定',:onclick=>'submit_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %> <% end %> diff --git a/app/views/files/_upload_show.html.erb b/app/views/files/_upload_show.html.erb index 21cd94d8d..dbd0277d7 100644 --- a/app/views/files/_upload_show.html.erb +++ b/app/views/files/_upload_show.html.erb @@ -11,7 +11,8 @@ <%= render :partial => 'attachement_list',:locals => {:course => course} %>
<%= l(:button_cancel)%> - <%= l(:button_confirm)%> + + <%= submit_tag '确定',:onclick=>'submit_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %> <% end %> diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index fdf1e31a3..b71d36f97 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -95,7 +95,7 @@
- <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %> + <%= render :partial => 'users/special_user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %>
@@ -111,9 +111,11 @@
- 确定 + + <%= submit_tag '确定',:onclick=>'popupRegex();new_student_work();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText fr' %> - <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%> + <%#= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%> + <%= l(:button_cancel)%>
<% end%> diff --git a/app/views/users/_attachment_list.html.erb b/app/views/users/_attachment_list.html.erb index 3d44fa267..939513627 100644 --- a/app/views/users/_attachment_list.html.erb +++ b/app/views/users/_attachment_list.html.erb @@ -7,7 +7,7 @@ :id => '_file', :class => ie8? ? '':'file_selector', :multiple => true, - :onchange => 'addInputFiles(this);', + :onchange => 'addInputFiles(this,"'+'upload_files_submit_btn'+'");', :style => ie8? ? '': 'display:none', :data => { :max_file_size => Setting.attachment_max_size.to_i.kilobytes, diff --git a/app/views/users/_special_user_homework_attachment.html.erb b/app/views/users/_special_user_homework_attachment.html.erb new file mode 100644 index 000000000..2f5a4e8e3 --- /dev/null +++ b/app/views/users/_special_user_homework_attachment.html.erb @@ -0,0 +1,61 @@ +
+ + <% if defined?(container) && container && container.saved_attachments %> + <% container.attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :readonly=>'readonly')%> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + <%= l(:field_is_public)%>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
+ <% end %> + <% container.saved_attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + <%= l(:field_is_public)%>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> + <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %> + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + +
+ <% end %> + <% end %> +
+ <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => ie8? ? '' : 'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this,"'+'upload_files_submit_btn'+'");', + :style => ie8? ? '' : 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js',:project =>nil), + :description_placeholder => l(:label_optional_description), + :field_is_public => l(:field_is_public), + :are_you_sure => l(:text_are_you_sure), + :file_count => l(:label_file_count), + :lebel_file_uploding => l(:lebel_file_uploding), + :delete_all_files => l(:text_are_you_sure_all) + } %> +
+
+ +
+ + 上传附件 + <%= link_to "资源库",{:controller => 'users',:action=>'user_import_resource',:id=>User.current.id,:homework_id=>container.id},:class => "FilesBtn fl mt3 mr20",:remote => true%> + <% if defined?(has_program) && has_program %> + 编程 + + <% end %> +
+ +<% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> +<% end %> \ No newline at end of file diff --git a/app/views/users/_upload_resource.html.erb b/app/views/users/_upload_resource.html.erb index d73b2986a..c973217f6 100644 --- a/app/views/users/_upload_resource.html.erb +++ b/app/views/users/_upload_resource.html.erb @@ -45,9 +45,9 @@
- <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:class=>'sendSourceText' %> + <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %>
- +
<% end %>
diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 5718983fa..20e845424 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -22,7 +22,7 @@ function reload(fileSpan) { } -function addFile_board(inputEl, file, eagerUpload, id) { +function addFile_board(inputEl, file, eagerUpload, id,btnId) { var attachments_frame = '#attachments_fields' + id; if ($(attachments_frame).children().length < 30) { @@ -80,7 +80,7 @@ function addFile_board(inputEl, file, eagerUpload, id) { ).appendTo(attachments_frame); if (eagerUpload) { - ajaxUpload(file, attachmentId, fileSpan, inputEl); + ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId); } return attachmentId; @@ -88,7 +88,7 @@ function addFile_board(inputEl, file, eagerUpload, id) { return null; } -function addFile(inputEl, file, eagerUpload) { +function addFile(inputEl, file, eagerUpload,btnId) { var attachments_frame = '#attachments_fields'; if ($(attachments_frame).children().length < 30) { @@ -145,7 +145,7 @@ function addFile(inputEl, file, eagerUpload) { ).appendTo('#attachments_fields'); if (eagerUpload) { - ajaxUpload(file, attachmentId, fileSpan, inputEl); + ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId); } return attachmentId; @@ -154,7 +154,7 @@ function addFile(inputEl, file, eagerUpload) { } addFile.nextAttachmentId = 1; -function ajaxUpload(file, attachmentId, fileSpan, inputEl) { +function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) { function onLoadstart(e) { fileSpan.removeClass('ajax-waiting'); @@ -168,7 +168,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) { } } - function actualUpload(file, attachmentId, fileSpan, inputEl) { + function actualUpload(file, attachmentId, fileSpan, inputEl,btnId) { ajaxUpload.uploading++; @@ -182,9 +182,15 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) { console.log($(inputEl)) if(containerid == undefined ){ var count = $('#attachments_fields>span').length; + $('#'+btnId).removeAttr("disabled"); + $('#'+btnId).val('确定') + $('#'+btnId).css('background-color','#269ac9') $('#upload_file_count').html("" + count + "" + $(inputEl).data('fileCount')); } else{ + $('#'+btnId).removeAttr("disabled"); + $('#'+btnId).val('确定') + $('#'+btnId).css('background-color','#269ac9') var count = $('#attachments_fields' + containerid + '>span').length; $('#upload_file_count' + containerid).html("" + count + "" + $(inputEl).data('fileCount')); } @@ -213,6 +219,9 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) { var containerid = $(inputEl).data('containerid'); if (containerid == undefined) { var count = $('#attachments_fields>span').length; + $('#'+btnId).attr("disabled",true); + $('#'+btnId).val('提交中'); + $('#'+btnId).css('background-color','#c1c1c1') $('#upload_file_count').html("" + count + "" + $(inputEl).data('lebelFileUploding')); if (count >= 1) { var add_attachs = $('.add_attachment'); @@ -227,6 +236,9 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) { } } else { var count = $('#attachments_fields' + containerid + '>span').length; + $('#'+btnId).attr("disabled",true); + $('#'+btnId).val('提交中'); + $('#'+btnId).css('background-color','#c1c1c1') $('#upload_file_count' + containerid).html("" + count + "" + $(inputEl).data('lebelFileUploding')); if (count >= 1) { var add_attachs = $('.add_attachment').filter(function(index) { @@ -258,7 +270,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) { var maxSyncUpload = $(inputEl).data('max-concurrent-uploads'); if (maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload) - actualUpload(file, attachmentId, fileSpan, inputEl); + actualUpload(file, attachmentId, fileSpan, inputEl,btnId); else $(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl)); } @@ -323,11 +335,11 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) { }); } -function addInputFiles(inputEl) { +function addInputFiles(inputEl,btnId) { // var clearedFileInput = $(inputEl).clone().val(''); if (inputEl.files) { // upload files using ajax - uploadAndAttachFiles(inputEl.files, inputEl); + uploadAndAttachFiles(inputEl.files, inputEl,btnId); // $(inputEl).remove(); } else { // browser not supporting the file API, upload on form submission @@ -349,12 +361,12 @@ function addInputFiles(inputEl) { //clearedFileInput.insertAfter('#attachments_fields'); } -function addInputFiles_board(inputEl, id) { +function addInputFiles_board(inputEl, id,btnId) { // var clearedFileInput = $(inputEl).clone().val(''); if (inputEl.files) { // upload files using ajax - uploadAndAttachFiles_board(inputEl.files, inputEl, id); + uploadAndAttachFiles_board(inputEl.files, inputEl, id,btnId); // $(inputEl).remove(); } else { // browser not supporting the file API, upload on form submission @@ -374,7 +386,7 @@ function addInputFiles_board(inputEl, id) { //clearedFileInput.insertAfter('#attachments_fields'); } -function uploadAndAttachFiles(files, inputEl) { +function uploadAndAttachFiles(files, inputEl,btnId) { var maxFileSize = $(inputEl).data('max-file-size'); var maxFileSizeExceeded = $(inputEl).data('max-file-size-message'); @@ -389,12 +401,12 @@ function uploadAndAttachFiles(files, inputEl) { window.alert(maxFileSizeExceeded); } else { $.each(files, function() { - addFile(inputEl, this, true); + addFile(inputEl, this, true,btnId); }); } } -function uploadAndAttachFiles_board(files, inputEl, id) { +function uploadAndAttachFiles_board(files, inputEl, id,btnId) { var maxFileSize = $(inputEl).data('max-file-size'); var maxFileSizeExceeded = $(inputEl).data('max-file-size-message'); @@ -409,7 +421,7 @@ function uploadAndAttachFiles_board(files, inputEl, id) { window.alert(maxFileSizeExceeded); } else { $.each(files, function() { - addFile_board(inputEl, this, true, id); + addFile_board(inputEl, this, true, id,btnId); }); } } @@ -482,10 +494,11 @@ $(function() { //课程课件 function addInputFilesCourseSource(inputEl) { checkBox = arguments[1] == 'public' ? false : true; + btnId = arguments[2]; // var clearedFileInput = $(inputEl).clone().val(''); if (inputEl.files) { // upload files using ajax - uploadAndAttachFilesCourseSource(inputEl.files, inputEl,checkBox); + uploadAndAttachFilesCourseSource(inputEl.files, inputEl,checkBox,btnId); // $(inputEl).remove(); } else { // browser not supporting the file API, upload on form submission @@ -507,7 +520,7 @@ function addInputFilesCourseSource(inputEl) { //clearedFileInput.insertAfter('#attachments_fields'); } -function uploadAndAttachFilesCourseSource(files, inputEl,checkBox) { +function uploadAndAttachFilesCourseSource(files, inputEl,checkBox,btnId) { var maxFileSize = $(inputEl).data('max-file-size'); var maxFileSizeExceeded = $(inputEl).data('max-file-size-message'); @@ -522,12 +535,12 @@ function uploadAndAttachFilesCourseSource(files, inputEl,checkBox) { window.alert(maxFileSizeExceeded); } else { $.each(files, function() { - addFileCourseSource(inputEl, this, true,checkBox); + addFileCourseSource(inputEl, this, true,checkBox,btnId); }); } } -function addFileCourseSource(inputEl, file, eagerUpload,checkBox) { +function addFileCourseSource(inputEl, file, eagerUpload,checkBox,btnId) { var attachments_frame = '#attachments_fields'; if ($(attachments_frame).children().length < 30) { @@ -606,7 +619,7 @@ function addFileCourseSource(inputEl, file, eagerUpload,checkBox) { } if (eagerUpload) { - ajaxUpload(file, attachmentId, fileSpan, inputEl); + ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId); } return attachmentId; diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 71b473abe..0cb6e203f 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1128,3 +1128,15 @@ a.postRouteLink:hover {text-decoration:underline;} .syllabusSettingIcon:hover {cursor: pointer} .pic_files{display:block; background:url(../images/public_icon.png) 0px -578px no-repeat; width:20px; height:15px;} + +/*确定按钮*/ +input.sendSourceText { + font-size: 14px; + color: #ffffff; + background-color: #269ac9; + cursor: pointer; + outline: none; + border: none; + width: 50px; + height: 25px; +} From 84348d15ea0341d25cffbafaa6249daa2d1da895 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 11 Nov 2015 16:32:13 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E7=9A=84=20=E7=A1=AE=E5=AE=9A=E6=8C=89=E9=92=AE=E7=9A=84?= =?UTF-8?q?=E8=81=94=E5=8A=A8=20=E4=BD=9C=E4=B8=9A=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/new.html.erb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index b71d36f97..fdf1e31a3 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -95,7 +95,7 @@
- <%= render :partial => 'users/special_user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %> + <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %>
@@ -111,11 +111,9 @@
- - <%= submit_tag '确定',:onclick=>'popupRegex();new_student_work();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText fr' %> + 确定 - <%#= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%> - <%= l(:button_cancel)%> + <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%>
<% end%> From 3aa73fba35712f916d3e2e1d56886648d371295e Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 11 Nov 2015 16:33:09 +0800 Subject: [PATCH 4/5] =?UTF-8?q?Gitlab=E6=9D=83=E9=99=90=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AEGitlab=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 9 +++++++++ lib/gitlab-cli/lib/gitlab/client/projects.rb | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index d26e465ba..58dea46b7 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -607,6 +607,15 @@ class ProjectsController < ApplicationController @project.organization_id = params[:organization_id] params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0 params[:project][:hidden_repo] ? @project.hidden_repo = 1 : @project.hidden_repo = 0 + # 更新公开私有时同步gitlab公开私有 + g = Gitlab.client + gproject = g.project(@project.gpid) + if params[:project][:is_public] + g.edit_project(gproject.id, 20) + else + g.edit_project(gproject.id, 0) + end + # end if validate_parent_id && @project.save @project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id') if params[:project][:is_public] == '0' diff --git a/lib/gitlab-cli/lib/gitlab/client/projects.rb b/lib/gitlab-cli/lib/gitlab/client/projects.rb index 04ea682aa..6247294f3 100644 --- a/lib/gitlab-cli/lib/gitlab/client/projects.rb +++ b/lib/gitlab-cli/lib/gitlab/client/projects.rb @@ -72,6 +72,23 @@ class Gitlab::Client post(url, :body => {:name => name}.merge(options)) end + # Updates a project team member to a specified access level. + # id (required) - The ID of a project + # name (optional) - project name + # path (optional) - repository name for project + # description (optional) - short project description + # default_branch (optional) + # issues_enabled (optional) + # merge_requests_enabled (optional) + # wiki_enabled (optional) + # snippets_enabled (optional) + # public (optional) - if true same as setting visibility_level = 20 + # visibility_level (optional) + + def edit_project(id, visibility_level) + put("/projects/#{id}", :body => {:visibility_level => visibility_level}) + end + # Deletes a project. # # @example From 2596f0a78844af5dbbaec1031be71610884a3f5f Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 11 Nov 2015 16:39:05 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9D=83=E9=99=90?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 58dea46b7..065adf596 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -608,12 +608,10 @@ class ProjectsController < ApplicationController params[:project][:is_public] ? @project.is_public = 1 : @project.is_public = 0 params[:project][:hidden_repo] ? @project.hidden_repo = 1 : @project.hidden_repo = 0 # 更新公开私有时同步gitlab公开私有 - g = Gitlab.client - gproject = g.project(@project.gpid) - if params[:project][:is_public] - g.edit_project(gproject.id, 20) - else - g.edit_project(gproject.id, 0) + unless @project.gpid.nil? + g = Gitlab.client + gproject = g.project(@project.gpid) + params[:project][:is_public] ? g.edit_project(gproject.id, 20) : g.edit_project(gproject.id, 0) end # end if validate_parent_id && @project.save