parent
d6fb35544e
commit
f168e43b0f
|
@ -191,9 +191,15 @@ class AttachmentsController < ApplicationController
|
||||||
if !@attachment.container.nil? &&
|
if !@attachment.container.nil? &&
|
||||||
(@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) &&
|
(@attachment.container.is_a?(Course) || ((@attachment.container.has_attribute?(:course) || @attachment.container.has_attribute?(:course_id) ) &&
|
||||||
@attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) &&
|
@attachment.container.course ) || ((@attachment.container.has_attribute?(:board) || @attachment.container.has_attribute?(:board_id)) &&
|
||||||
@attachment.container.board && @attachment.container.board.course ) )
|
@attachment.container.board && @attachment.container.board.course ) || @attachment.container.is_a?(StudentWorksScore) || @attachment.container.is_a?(HomeworkCommon))
|
||||||
if @attachment.container.is_a?(News)
|
if @attachment.container.is_a?(News)
|
||||||
format.html { redirect_to_referer_or news_path(@attachment.container) }
|
format.html { redirect_to_referer_or news_path(@attachment.container) }
|
||||||
|
elsif @attachment.container.is_a?(StudentWorksScore)
|
||||||
|
@is_destroy = true #根据ID删除页面对应的数据,js刷新页面
|
||||||
|
format.js
|
||||||
|
elsif @attachment.container.is_a?(HomeworkCommon)
|
||||||
|
@is_destroy = true #根据ID删除页面对应的数据,js刷新页面
|
||||||
|
format.js
|
||||||
elsif @attachment.container.is_a?(Message)
|
elsif @attachment.container.is_a?(Message)
|
||||||
format.html { redirect_to_referer_or new_board_message_path(@attachment.container) }
|
format.html { redirect_to_referer_or new_board_message_path(@attachment.container) }
|
||||||
elsif @course.nil?
|
elsif @course.nil?
|
||||||
|
@ -431,7 +437,7 @@ private
|
||||||
@attachment.container.board.course)
|
@attachment.container.board.course)
|
||||||
@course = @attachment.container.board.course
|
@course = @attachment.container.board.course
|
||||||
else
|
else
|
||||||
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWorks'
|
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication' || @attachment.container_type == 'PhoneAppVersion' || @attachment.container_type == 'StudentWorksScore'|| @attachment.container_type == 'StudentWork'
|
||||||
@project = @attachment.project
|
@project = @attachment.project
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -334,9 +334,8 @@ class HomeworkAttachController < ApplicationController
|
||||||
@homework.name = name
|
@homework.name = name
|
||||||
@homework.description = description
|
@homework.description = description
|
||||||
@homework.project_id = params[:project_id] || 0
|
@homework.project_id = params[:project_id] || 0
|
||||||
if params[:attachments]
|
@homework.save_attachments(params[:attachments])
|
||||||
@homework.save_attachments(params[:attachments])
|
render_attachment_warning_if_needed(@homework)
|
||||||
end
|
|
||||||
if @homework.save
|
if @homework.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to course_for_bid_url @homework.bid }
|
format.html { redirect_to course_for_bid_url @homework.bid }
|
||||||
|
|
|
@ -101,6 +101,9 @@ class HomeworkCommonController < ApplicationController
|
||||||
@homework_detail_manual.evaluation_num = params[:evaluation_num]
|
@homework_detail_manual.evaluation_num = params[:evaluation_num]
|
||||||
@homework_detail_manual.absence_penalty = params[:absence_penalty]
|
@homework_detail_manual.absence_penalty = params[:absence_penalty]
|
||||||
|
|
||||||
|
@homework.save_attachments(params[:attachments])
|
||||||
|
render_attachment_warning_if_needed(@homework)
|
||||||
|
|
||||||
if @homework.save && @homework_detail_manual.save
|
if @homework.save && @homework_detail_manual.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
|
|
|
@ -1,26 +1,30 @@
|
||||||
var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');
|
<% if @is_destroy%>
|
||||||
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
|
$("#attachment_<%= @attachment.id%>").remove();
|
||||||
var containerid=$('.remove-upload',attachment_html_obj).data('containerid');
|
<%else%>
|
||||||
if(containerid==undefined){
|
var attachment_html_obj = $('#attachments_<%= j params[:attachment_id] %>');
|
||||||
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
|
||||||
var count=$('#attachments_fields>span').length;
|
var containerid=$('.remove-upload',attachment_html_obj).data('containerid');
|
||||||
if(count<=0){
|
if(containerid==undefined){
|
||||||
$("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>');
|
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
||||||
$(".remove_all").remove();
|
var count=$('#attachments_fields>span').length;
|
||||||
|
if(count<=0){
|
||||||
|
$("#upload_file_count").text('<%= l(:label_no_file_uploaded)%>');
|
||||||
|
$(".remove_all").remove();
|
||||||
|
}else{
|
||||||
|
$("#upload_file_count").html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
$("#upload_file_count").html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
||||||
|
var count=$('#attachments_fields'+containerid+'>span').length;
|
||||||
|
if(count<=0){
|
||||||
|
$('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>');
|
||||||
|
var remove_all_html_obj = $(".remove_all").filter(function(index){
|
||||||
|
return $(this).data('containerid')==containerid;
|
||||||
|
});
|
||||||
|
remove_all_html_obj.remove();
|
||||||
|
}else{
|
||||||
|
$('#upload_file_count'+containerid).html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else{
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
|
||||||
$('#attachments_<%= j params[:attachment_id] %>').remove();
|
<% end%>
|
||||||
var count=$('#attachments_fields'+containerid+'>span').length;
|
|
||||||
if(count<=0){
|
|
||||||
$('#upload_file_count'+containerid).text('<%= l(:label_no_file_uploaded)%>');
|
|
||||||
var remove_all_html_obj = $(".remove_all").filter(function(index){
|
|
||||||
return $(this).data('containerid')==containerid;
|
|
||||||
});
|
|
||||||
remove_all_html_obj.remove();
|
|
||||||
}else{
|
|
||||||
$('#upload_file_count'+containerid).html("<span id=\"count\">"+count+"</span>"+"个文件"+"已上传");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
|
|
|
@ -1,5 +1,8 @@
|
||||||
<% for attachment in attachments %>
|
<% attachments.each_with_index do |attachment,i| %>
|
||||||
<%= link_to_short_attachment attachment, :class => 'link_file', :download => true -%>
|
<div id="attachment_<%= attachment.id%>">
|
||||||
<span class="ml5">(<%= number_to_human_size attachment.filesize %>)</span>
|
<%= link_to_short_attachment attachment, :class => 'link_file', :download => true -%>
|
||||||
<div class="cl"></div>
|
<%= link_to(' '.html_safe, attachment_path(attachment, :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') if attachment.id && User.current == attachment.author %>
|
||||||
|
<span class="ml5">(<%= number_to_human_size attachment.filesize %>)</span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
Loading…
Reference in New Issue