Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
edf3cc9cc8
|
@ -50,6 +50,8 @@ class Course < ActiveRecord::Base
|
||||||
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
|
validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/
|
||||||
validates_length_of :description, :maximum => 10000
|
validates_length_of :description, :maximum => 10000
|
||||||
before_save :self_validate
|
before_save :self_validate
|
||||||
|
# 公开课程变成私有课程,所有资源都变成私有
|
||||||
|
after_update :update_files_public
|
||||||
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message
|
after_create :create_board_sync, :act_as_course_activity, :act_as_course_message
|
||||||
before_destroy :delete_all_members
|
before_destroy :delete_all_members
|
||||||
|
|
||||||
|
@ -212,6 +214,14 @@ class Course < ActiveRecord::Base
|
||||||
def self_validate
|
def self_validate
|
||||||
|
|
||||||
end
|
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
|
def create_board_sync
|
||||||
|
|
|
@ -23,23 +23,44 @@
|
||||||
</div>
|
</div>
|
||||||
<% checkBox = (@course.present? && @course.is_public?) ? 'public' : 'private'%>
|
<% checkBox = (@course.present? && @course.is_public?) ? 'public' : 'private'%>
|
||||||
<button name="button" class="sub_btn" onclick="_file.click()" onmouseover="this.focus()" style="<%= ie8? ? 'display:none' : ''%>" type="button" ><%= l(:label_browse) %></button>
|
<button name="button" class="sub_btn" onclick="_file.click()" onmouseover="this.focus()" style="<%= ie8? ? 'display:none' : ''%>" type="button" ><%= l(:label_browse) %></button>
|
||||||
<%= file_field_tag 'attachments[dummy][file]',
|
<% if @course %>
|
||||||
:id => '_file',
|
<%= file_field_tag 'attachments[dummy][file]',
|
||||||
:class => ie8? ? '':'file_selector',
|
:id => '_file',
|
||||||
:multiple => true,
|
:class => ie8? ? '':'file_selector',
|
||||||
:onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'");',
|
:multiple => true,
|
||||||
:style => ie8? ? '': 'display:none',
|
:onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'");',
|
||||||
:data => {
|
:style => ie8? ? '': 'display:none',
|
||||||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
:data => {
|
||||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||||
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||||
:upload_path => uploads_path(:format => 'js'),
|
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||||
:description_placeholder => l(:label_optional_description),
|
:upload_path => uploads_path(:format => 'js'),
|
||||||
:field_is_public => l(:field_is_public),
|
:description_placeholder => l(:label_optional_description),
|
||||||
:are_you_sure => l(:text_are_you_sure),
|
:field_is_public => l(:field_is_public),
|
||||||
:file_count => l(:label_file_count),
|
:are_you_sure => l(:text_are_you_sure),
|
||||||
:delete_all_files => l(:text_are_you_sure_all)
|
: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 %>
|
||||||
|
|
||||||
<!--<input type="submit" name="" value="上传文件" class="f_l ml10" style="width:80px; height:26px;">-->
|
<!--<input type="submit" name="" value="上传文件" class="f_l ml10" style="width:80px; height:26px;">-->
|
||||||
|
|
||||||
<span id="upload_file_count">
|
<span id="upload_file_count">
|
||||||
|
|
|
@ -603,7 +603,7 @@
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
schoolsResult = data.schools;
|
schoolsResult = data.schools;
|
||||||
count = data.count;
|
count = data.count;
|
||||||
maxPage = count % 100 + 1; //最大页码值
|
maxPage = Math.ceil(count/100) //最大页码值
|
||||||
if(schoolsResult.length != undefined && schoolsResult.length != 0) {
|
if(schoolsResult.length != undefined && schoolsResult.length != 0) {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
$("#search_school_result_list").html('');
|
$("#search_school_result_list").html('');
|
||||||
|
|
Loading…
Reference in New Issue