diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 09124f79..cf976f6d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -182,9 +182,9 @@ class ProjectsController < ApplicationController @s_type = 2 end else - @projects = sort_project_demo 1, "course_ac_para desc", @project_pages.offset, @limit - @s_type = 1 - # @projects = Project.visible.where("project_type = ?", 1).order("created_on desc").offset(@project_pages.offset).limit(@limit).all + # @projects = sort_project_demo 1, "course_ac_para desc", @project_pages.offset, @limit + @s_type = 0 + @projects = Project.visible.where("project_type = ?", 1).order("created_on desc").offset(@project_pages.offset).limit(@limit).all # @s_type = 0 end respond_to do |format| diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 6e92631a..1394180e 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -66,18 +66,18 @@ module ProjectsHelper content = ''.html_safe case state when 0 - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected") + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) when 1 - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected") # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type))) when 2 - content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) content << content_tag('li', link_to(l(:label_sort_by_time), course_path(:project_sort_type => '0', :project_type => project_type))) + content << content_tag('li', link_to(l(:label_sort_by_active), course_path(:project_sort_type => '1', :project_type => project_type))) # content << content_tag('li', link_to(l(:label_sort_by_influence), course_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") end @@ -243,7 +243,7 @@ module ProjectsHelper end end - def eventToLanguageCourse event_type, project + def eventToLanguageCourse event_type, project case event_type when "issue-note" l :label_issue @@ -286,7 +286,17 @@ module ProjectsHelper WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ") end - def method_name - + # 判断课程是否结束 + def course_timeout? project + return true if (project.nil? && project.course_extra.nil?) + courses_year = project.course_extra.time + current_year = Time.now.year + if(courses_year >= current_year) + return false + elsif( (courses_year < current_year) && (Time.now.month < 3) ) + return false + else + return true + end end end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 7d93d0cd..519803a9 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -21,6 +21,10 @@ module WelcomeHelper include CoursesHelper + def find_new_course limit=15 + Project.visible.joins(:course_extra).where("#{Project.table_name}.project_type = ? ", 1).order("courses.time DESC, #{Project.table_name}.created_on DESC").limit(limit).all + end + def find_all_hot_project limit=15 sort_project_by_hot limit end diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 53b05742..9f39d376 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -34,7 +34,7 @@
<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > - <%= link_to(@bid.courses.first.name, homework_project_path(@bid.courses.first)) %> > + <%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%> > <%=link_to(@bid.name, respond_path(@bid)) %>
- <%= content_tag "span", project.description.truncate(50, omission: '...'), :class => "d-p-project-intro" , :title => project.description %>
+ <%= content_tag "div", " ".html_safe<