This commit is contained in:
yanxd 2014-07-05 09:40:11 +08:00
commit db28ecd883
2 changed files with 7 additions and 6 deletions

View File

@ -141,27 +141,26 @@ module WelcomeHelper
Course.active.visible. Course.active.visible.
joins(:memberships). joins(:memberships).
group('members.course_id'). group('members.course_id').
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
else else
if school_id.nil? if school_id.nil?
Course.active.visible. Course.active.visible.
joins(:memberships). joins(:memberships).
where("#{Course.table_name}.school_id = ?", User.current.user_extensions.school.id). where("#{Course.table_name}.school_id = ?", User.current.user_extensions.school.id).
group('members.course_id'). group('members.course_id').
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
else else
if school_id == "0" if school_id == "0"
Course.active.visible. Course.active.visible.
joins(:memberships). joins(:memberships).
group('members.course_id'). group('members.course_id').
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
else else
Course.active.visible. Course.active.visible.
joins(:memberships). joins(:memberships).
where("#{Course.table_name}.school_id = ?", school_id). where("#{Course.table_name}.school_id = ?", school_id).
group('members.course_id'). group('members.course_id').
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
end end
end end
end end

View File

@ -138,6 +138,7 @@
</ul> </ul>
<ul class="d-p-projectlist"> <ul class="d-p-projectlist">
<% school_course.map do |course| %> <% school_course.map do |course| %>
<% if course.school%>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s %>> <li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s %>>
<div class='avatar'> <div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %> <%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
@ -167,6 +168,7 @@
<% end %> <% end %>
</div> </div>
</li> </li>
<%end%>
<% end; reset_cycle %> <% end; reset_cycle %>
<% if school_course.count < 9 %> <% if school_course.count < 9 %>
<li> <li>