diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 8ee7f42d8..48d590c4b 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -231,12 +231,12 @@ module WelcomeHelper # modif by nwb def find_all_new_hot_course limit = 9 ,school_id = 0 #sort_project_by_hot_rails 1, 'course_ac_para DESC', limit - time_now = Time.new.strftime("%Y"); + time_now = Time.new.strftime("%Y") if school_id - courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <> + courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <> ?", school_id).order("course_ac_para DESC").limit(limit).all else - courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL + courses = Course.includes(:school, :members).visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id is not NULL ").order("course_ac_para DESC").limit(limit).all end courses diff --git a/app/views/welcome/_course_list.html.erb b/app/views/welcome/_course_list.html.erb new file mode 100644 index 000000000..f590cf868 --- /dev/null +++ b/app/views/welcome/_course_list.html.erb @@ -0,0 +1,28 @@ +<% course_list.map do |course| %> +
  • /,"") %>> +
    + <%= image_tag(get_course_avatar(course), :class => "avatar-4") %> +
    + +
    + + <% if (course.school == nil) %> +               + <% else %> + <%= link_to course.school.name.try(:gsub, /(.+)$/, '\1:'), options={:action => 'course', :school_id => course.school.id}, html_options={:method => 'get'} %> + <% end %> + + + <%= link_to(course.try(:teacher).try(:realname), user_path(course.teacher)) %> + <%#=course.try(:teacher).try(:name)%> + +
    +
    + [<%= get_course_term course %>] + <%= link_to(course.name.truncate(30, omission: '...'), course_path(course.id), :class => "d-g-blue d-p-project-name", :title => "#{course.name}") %> + (<%= course.members.count %>人) + <%# files_count = course.attachments.count.to_s %> + (<%= link_to "#{course.attachments.count.to_s}份", course_files_path(course) %>资料) +
    +
  • +<% end %> diff --git a/app/views/welcome/_no_course_title.html.erb b/app/views/welcome/_no_course_title.html.erb new file mode 100644 index 000000000..f16b91dba --- /dev/null +++ b/app/views/welcome/_no_course_title.html.erb @@ -0,0 +1,5 @@ +

    +

    + <%= course_title%> +

    +

    \ No newline at end of file diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index 7cab331b6..c979807b9 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -88,46 +88,15 @@ <%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %>
    -
    @@ -143,80 +112,12 @@ <% end %>
    -
    diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 9b6329b95..135e9afb1 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2101,4 +2101,7 @@ zh: # ajax异步验证 modal_valid_passing: 可以使用 label_bug: 漏洞 + + lable_school_no_course: 该学校未开设任何课程,您可以查看其他学校课程 + lable_school_less_course: 该学校开设课程较少,您可以查看其他学校课程 \ No newline at end of file