先对课程下的班级归档,再删除该课程,此时就不能再恢复班级了

This commit is contained in:
cxt 2017-03-31 15:00:09 +08:00
parent 1dcaef2ce7
commit f3057fc9c8
2 changed files with 11 additions and 2 deletions

View File

@ -57,6 +57,13 @@ class SyllabusesController < ApplicationController
end
def delete_syllabus
if @syllabus.courses.empty?
@status = 1
elsif @syllabus.courses.not_deleted.empty?
@status = 2
else
@status = 3
end
respond_to do |format|
format.js
end

View File

@ -6,15 +6,17 @@
</div>
<div style='text-align:center;font-family: "微软雅黑","宋体"' class="mt20 f14">
<% if @syllabus.courses.not_deleted.empty? %>
<% if @status == 1 %>
确认删除该课程吗?
<% elsif @status == 2 %>
该课程下存在归档班级,不能删除。
<% else %>
该课程下已经存在班级,不能删除。
<% end %>
</div>
<div style='width:164px; margin:0 auto; margin-top: 15px; text-align:center; font-family: "微软雅黑","宋体"'>
<% if @syllabus.courses.not_deleted.empty? %>
<% if @status == 1 %>
<a href='javascript:void(0);' class='sy_btn_grey fl mr5' style="margin-left: 25px;" onclick='hideModal()'>取消</a>
<%=link_to '确认', syllabus_path(@syllabus), :class => 'sy_btn_blue fl', :method => 'delete'%>
<% else %>