Merge branch 'bigchange' of 10.0.47.245:/home/trustie2 into bigchange

This commit is contained in:
nieguanghui 2014-01-13 16:29:19 +08:00
commit d49e51f5a6
5 changed files with 24 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)