diff --git a/app/controllers/stores_controller.rb b/app/controllers/stores_controller.rb index 2790308b..6237ef89 100644 --- a/app/controllers/stores_controller.rb +++ b/app/controllers/stores_controller.rb @@ -7,8 +7,22 @@ class StoresController < ApplicationController # menu_item :settings, :only => :settings # include ActsAsTaggableOn::TagsHelper - + LIMIT = 20 unless const_defined?(:LIMIT) def index + #Document HomeworkAttach Issue Message News Version WikiPage + projects_attach + @projects_attach = Attachment.includes(:attach_project).where("projects.project_type=?", 0). + reorder("#{Attachment.table_name}.created_on DESC"). + limit(LIMIT) + @courses_attach = Attachment.includes(:attach_project).where("projects.project_type=?", 1). + reorder("#{Attachment.table_name}.created_on DESC"). + limit(LIMIT) + @homeworks_attach = Attachment.where("container_type = 'HomeworkAttach'"). + reorder("created_on DESC"). + limit(LIMIT) + @memos_attach = Attachment.where("container_type = 'Memo'"). + reorder("created_on DESC"). + limit(LIMIT) end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 63d5fea2..12e1dee6 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -268,7 +268,8 @@ module ProjectsHelper @projects << Project.visible.find_by_id("#{obj.project_id}")#where('id=:id', id: obj.project_id) end @projects - rescue NoMethodError + rescue NoMethodError => e + logger.error "Logger.Error [ProjectsHelper] ===> #sort_project_by_hot, NoMethodError: #{e}" [] end @@ -285,4 +286,7 @@ module ProjectsHelper WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ") end + def method_name + + end end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 69b06aa1..154c2a98 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -66,7 +66,7 @@ module WelcomeHelper begin grade = project.project_status.grade if project && project.project_status rescue Exception => e - logger.error "[WelcomeHelper] ===> #{e}" + logger.error "Logger.Error [WelcomeHelper] ===> #{e}" end "项目评分:".html_safe << grade.to_s end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index eeab5624..63f2ad5f 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -20,6 +20,7 @@ require "fileutils" class Attachment < ActiveRecord::Base belongs_to :container, :polymorphic => true + belongs_to :attach_project, foreign_key: 'container_id', conditions: "#{Attachment.table_name}.container_type = 'Project'" belongs_to :author, :class_name => "User", :foreign_key => "author_id" validates_presence_of :filename, :author diff --git a/app/models/project.rb b/app/models/project.rb index e106ac0c..7968859e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -151,6 +151,8 @@ class Project < ActiveRecord::Base where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern) end } + scope :project_entities, -> { where(project_type: 0) } + scope :course_entities, -> { where(project_type: 1) } def new_course self.where('project_type = ?', 1)