课程删除

This commit is contained in:
huang 2015-12-10 17:26:03 +08:00
parent fbba933a46
commit 4f7f4acb1f
4 changed files with 13 additions and 1 deletions

View File

@ -634,6 +634,11 @@ class CoursesController < ApplicationController
end
def show
# 被删除的课程只有超级管理员才能看到is_delete为1的时候标记课程被删除
if @course.is_delete == 1 && User.current.admin?
render_403
return
end
#更新创建课程消息状态
create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0)
create_course_messages.update_all(:viewed => true)

View File

@ -88,6 +88,12 @@
</li>
<% end %>
</ul>
<% if @course.is_delete == 1 %>
<div class="mt30 fr"><img src="/images/pic_del.gif" class="mr5"><%=link_to "恢复该课程", course_path(@course), :method => :delete %></div>
<% else %>
<div class="mt30 fr"><img src="/images/pic_del.gif" class="mr5"><%=link_to "删除该课程", course_path(@course), :method => :delete %></div>
<% end %>
</div>
<div class="hwork_undis" id="tbc_02">

View File

@ -147,7 +147,7 @@
<% end%>
<% end%>
</div>
<% courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5)%>
<% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5)%>
<div class="homepageLeftMenuCourses <%= courses.empty? ? 'none' : ''%>" id="homepageLeftMenuCourses">
<ul>
<%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user, :page => 0} %>

View File

@ -890,6 +890,7 @@ RedmineApp::Application.routes.draw do
get 'member_score', :to => 'courses#member_score'
post 'finishcourse'
post 'restartcourse'
match "recover", :to => 'courses#recovery'
match "searchmembers", :controller => 'courses', :action => 'searchmembers', :via => [:post,:get]
match "searchgroupmembers", :via => [:post, :get]
match 'member_score_sort', :via => [:get]