未配置班级列表报500,全部班级列表添加状态列表明班级是否已删除

This commit is contained in:
cxt 2016-07-11 14:43:22 +08:00
parent 8e8d6a8439
commit 834e72b0f8
4 changed files with 15 additions and 6 deletions

View File

@ -112,10 +112,10 @@ class AdminController < ApplicationController
def non_syllabus_courses
@name = params[:name].to_s.strip.downcase
if @name && @name != ""
@courses = Course.where("syllabus_id is null").select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)}
@courses = Course.where("syllabus_id is null and is_delete = 0").select{ |course| (course.teacher[:lastname].to_s.downcase + course.teacher[:firstname].to_s.downcase).include?(@name) || course.name.include?(@name)}
@courses = @courses.sort{|x, y| y.created_at <=> x.created_at}
else
@courses = Course.where("syllabus_id is null").order('created_at desc')
@courses = Course.where("syllabus_id is null and is_delete = 0").order('created_at desc')
end
@courses = paginateHelper @courses,30
@page = (params['page'] || 1).to_i - 1

View File

@ -7,7 +7,7 @@
</span>
</td>
<td align="center">
<%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
<%= link_to(course.teacher.show_name.truncate(6, omission: '...'), user_path(course.teacher)) %>
</td>
<td align="center">
<%= course.class_period %>
@ -16,6 +16,8 @@
<%= checked_image course.is_public? %>
</td>
<td class="center">
<%= course.is_delete == 0 ? '正常' : '归档' %>
</td><td class="center">
<%= format_date(course.created_at) %>
</td>
<td class="center">

View File

@ -27,10 +27,10 @@
<table class="list" style="width: 100%;table-layout: fixed">
<thead>
<tr>
<th style="width: 30px;">
<th style="width: 20px;">
序号
</th>
<th style="width: 85px;">
<th style="width: 70px;">
班级
</th>
<th style="width: 35px;">
@ -42,6 +42,9 @@
<th style="width: 15px;">
<%=l(:field_is_public)%>
</th>
<th style="width: 20px;">
状态
</th>
<th style="width: 45px;">
<%=l(:field_created_on)%>
</th>
@ -58,9 +61,11 @@
</thead>
<tbody>
<% @courses.each do |course| %>
<% unless course.teacher.nil? %>
<tr class="<%= cycle("odd", "even") %>" id="course_<%=course.id %>">
<%=render :partial => 'courselist_detail_tr', :locals => {:course => course} %>
</tr>
<% end %>
<% end %>
</tbody>
</table>

View File

@ -58,6 +58,7 @@
</thead>
<tbody>
<% @courses.each do |course| %>
<% unless course.teacher.nil? %>
<tr class="<%= cycle("odd", "even") %>" id="course_<%=course.id %>">
<td style="text-align: center;">
<%= course.id %>
@ -68,7 +69,7 @@
</span>
</td>
<td align="center">
<%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
<%= link_to(course.teacher.show_name.truncate(6, omission: '...'), user_path(course.teacher)) %>
</td>
<td align="center">
<%= course.class_period %>
@ -90,6 +91,7 @@
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>