access control:关闭课程in view

This commit is contained in:
yanxd 2014-05-06 09:26:48 +08:00
parent d257f4e853
commit f8746d6812
1 changed files with 7 additions and 4 deletions

View File

@ -1,10 +1,13 @@
<% <%
id = "finish_course_#{project.id}" id = "finish_course_#{project.id}"
display = (project.course_extra.teacher.id == User.current.id ) display = (project.course_extra.teacher.id == User.current.id || User.current.admin?)
%> %>
<% if display && course_endTime_timeout?(project) #如果课程已结束%> <% if display #如果课程已结束%>
<%= link_to '重启课程', restartcourse_project_path(project, format: :js), :remote => true, :method => :post, :id => id, :confirm => ('确定要重启课程?') %> <% linkPath = course_endTime_timeout?(project) ? restartcourse_project_path(project) : finishcourse_project_path(project, format: :js) %>
<% desc = course_endTime_timeout?(project) ? '重启' : '关闭' %>
<%= link_to "#{desc}课程", linkPath, :remote => true, :method => :post, :id => id, :confirm => ("确定要#{desc}课程?") %>
<% else %> <% else %>
<%= link_to '关闭课程', finishcourse_project_path(project, format: :js), :remote => true, :method => :post, :id => id, :confirm => ('确定要关闭课程?') %> <!-- 关闭课程block -->
<% end %> <% end %>