From 290e61599fdb8f526e6ebd45e98cbb492f86ba8d Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 10:47:51 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AF=B9=E8=AF=BE=E7=A8=8B=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=85=AC=E5=BC=80=E7=A7=81=E6=9C=89=E5=8D=95=E7=8B=AC?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_attachement_list.html.erb | 55 +++++++++++++++------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb index eb730640c..4c631d22f 100644 --- a/app/views/files/_attachement_list.html.erb +++ b/app/views/files/_attachement_list.html.erb @@ -23,23 +23,44 @@ <% checkBox = (@course.present? && @course.is_public?) ? 'public' : 'private'%> -<%= file_field_tag 'attachments[dummy][file]', - :id => '_file', - :class => ie8? ? '':'file_selector', - :multiple => true, - :onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'");', - :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'), - :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), - :delete_all_files => l(:text_are_you_sure_all) - } %> +<% if @course %> + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => ie8? ? '':'file_selector', + :multiple => true, + :onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'");', + :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'), + :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), + :delete_all_files => l(:text_are_you_sure_all) + } %> +<% else %> + <%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => ie8? ? '':'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :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'), + :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), + :delete_all_files => l(:text_are_you_sure_all) + } %> +<% end %> + From af4523815c6d53a95f8ff3ed0838698532c5bb4a Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 11:03:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BB=8E=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E6=94=B9=E6=88=90=E7=A7=81=E6=9C=89=20=E5=88=99?= =?UTF-8?q?=E8=AF=A5=E8=AF=BE=E7=A8=8B=E4=B8=AD=E6=89=80=E6=9C=89=E7=9A=84?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E9=83=BD=E5=8F=98=E6=88=90=E7=A7=81=E6=9C=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/course.rb b/app/models/course.rb index 46599dbfc..a583990c1 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -50,6 +50,8 @@ class Course < ActiveRecord::Base validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/ validates_length_of :description, :maximum => 10000 before_save :self_validate + # 公开课程变成私有课程,所有资源都变成私有 + after_update :update_files_public after_create :create_board_sync, :act_as_course_activity, :act_as_course_message before_destroy :delete_all_members @@ -213,6 +215,14 @@ class Course < ActiveRecord::Base end + def update_files_public + unless self.is_public? + self.attachments.each do |a| + a.update_attributes(:is_public => false) + end + end + end + # 创建课程讨论区 def create_board_sync @board = self.boards.build From 5a5cf430d3d331958ac84835c00c58b00bd372b8 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 20 Oct 2015 14:24:18 +0800 Subject: [PATCH 3/4] 0 --- app/models/course.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/course.rb b/app/models/course.rb index a583990c1..7288c3b3b 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -214,7 +214,7 @@ class Course < ActiveRecord::Base def self_validate end - + def update_files_public unless self.is_public? self.attachments.each do |a| From a8b4bde77c9cad26906169c7a9ab495554983dcc Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 20 Oct 2015 14:38:24 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=88=97=E8=A1=A8div=20?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E5=88=86=E9=A1=B5=20=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E9=A1=B5=20=E8=AE=A1=E7=AE=97=E6=96=B9=E6=B3=95=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/my/account.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 0531ea9e7..7bc674ea6 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -603,7 +603,7 @@ success: function (data) { schoolsResult = data.schools; count = data.count; - maxPage = count % 100 + 1; //最大页码值 + maxPage = Math.ceil(count/100) //最大页码值 if(schoolsResult.length != undefined && schoolsResult.length != 0) { var i = 0; $("#search_school_result_list").html('');