课程删除功能

admin中课程列表取消删除按钮
This commit is contained in:
huang 2015-12-10 18:59:54 +08:00
parent 4f7f4acb1f
commit c7b2c9e3af
5 changed files with 22 additions and 13 deletions

View File

@ -25,6 +25,7 @@ class CoursesController < ApplicationController
before_filter :authorize_course, :only => [:show, :settings, :update, :course]
before_filter :authorize_course_global, :only => [:new,:create]
before_filter :toggleCourse, :only => [:finishcourse, :restartcourse]
before_filter :is_deleted, :only => [:show, :settings]
before_filter :require_login, :only => [:join, :unjoin]
#before_filter :allow_join, :only => [:join]
@ -581,6 +582,13 @@ class CoursesController < ApplicationController
end
end
def is_deleted
if @course.is_delete == 1 and !User.current.admin?
render_404
return
end
end
def get_courses
@user = User.current
membership = @user.coursememberships.all
@ -635,10 +643,10 @@ class CoursesController < ApplicationController
def show
# 被删除的课程只有超级管理员才能看到is_delete为1的时候标记课程被删除
if @course.is_delete == 1 && User.current.admin?
render_403
return
end
# 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)
@ -786,11 +794,12 @@ class CoursesController < ApplicationController
end
# 恢复已删除的课程
def recovery
def renew
if User.current.admin?
@course.update_attributes(:is_delete => false)
redirect_to course_path(@course)
else
return 403
return 404
end
end

View File

@ -67,9 +67,6 @@
<td class="center">
<%= format_date(course.created_at) %>
</td>
<td class="buttons">
<%= link_to(l(:button_delete), course_path(course), :method => :delete, :class => 'icon icon-del', :onClick=>"delcfm()" ) %>
</td>
</tr>
<% end %>
</tbody>

View File

@ -89,9 +89,12 @@
<% 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>
<div class="mt30 fr"><img src="/images/pic_del.gif" class="mr5"><%=link_to "恢复该课程", renew_course_path(@course) %></div>
<% else %>
<div class="mt30 fr"><img src="/images/pic_del.gif" class="mr5"><%=link_to "删除该课程", course_path(@course), :method => :delete %></div>
<div class="mt30">
<img src="/images/pic_del.gif" class="mr5"><%=link_to "删除该课程", course_path(@course), :method => :delete, :confirm=>"确认要删除该课程吗?" %>
<span>(友情提示:删除该课程后如果您想恢复该课程,请联系系统管理员!)</span>
</div>
<% end %>
</div>

View File

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

View File

@ -1362,4 +1362,4 @@ $(function(){
});
personalized_init();
});
});