FIX es bug
This commit is contained in:
parent
2eaa6e2732
commit
abd11179d5
|
@ -45,12 +45,10 @@ class Attachment < ActiveRecord::Base
|
||||||
# validates :description, length: {maximum: 254}
|
# validates :description, length: {maximum: 254}
|
||||||
validate :validate_max_file_size
|
validate :validate_max_file_size
|
||||||
|
|
||||||
#elasticsearch
|
|
||||||
include Elasticsearch::Model
|
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
#elasticsearch kaminari init
|
#elasticsearch
|
||||||
Kaminari::Hooks.init
|
include Searchable
|
||||||
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
|
|
||||||
settings index: { number_of_shards: 5 } do
|
settings index: { number_of_shards: 5 } do
|
||||||
mappings dynamic: 'false' do
|
mappings dynamic: 'false' do
|
||||||
indexes :filename, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :filename, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
|
@ -145,7 +143,7 @@ class Attachment < ActiveRecord::Base
|
||||||
|
|
||||||
def get_apply_resource_status attachment_id, author_id
|
def get_apply_resource_status attachment_id, author_id
|
||||||
status = ApplyResource.where("attachment_id =? and user_id =?", attachment_id, author_id).first.try(:status)
|
status = ApplyResource.where("attachment_id =? and user_id =?", attachment_id, author_id).first.try(:status)
|
||||||
status == 2
|
status == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
# add by nwb
|
# add by nwb
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
module Searchable
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
include Elasticsearch::Model
|
||||||
|
document_type 'doc' # 解决因Elasticsearch版本导致es语法错误的问题
|
||||||
|
|
||||||
|
#elasticsearch kaminari init
|
||||||
|
Kaminari::Hooks.init
|
||||||
|
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -11,11 +11,7 @@ class Course < ActiveRecord::Base
|
||||||
STATUS_ARCHIVED = 9
|
STATUS_ARCHIVED = 9
|
||||||
|
|
||||||
#elasticsearch
|
#elasticsearch
|
||||||
include Elasticsearch::Model
|
include Searchable
|
||||||
|
|
||||||
#elasticsearch kaminari init
|
|
||||||
Kaminari::Hooks.init
|
|
||||||
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
|
|
||||||
settings index: { number_of_shards: 5 } do
|
settings index: { number_of_shards: 5 } do
|
||||||
mappings dynamic: 'false' do
|
mappings dynamic: 'false' do
|
||||||
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
|
@ -23,7 +19,7 @@ class Course < ActiveRecord::Base
|
||||||
indexes :updated_at, index:"not_analyzed",type:"date"
|
indexes :updated_at, index:"not_analyzed",type:"date"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period,
|
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period,
|
||||||
:open_student, :enterprise_name, :is_delete, :syllabus_id, :end_time, :end_term, :publish_resource, :is_copy, :endup_time,
|
:open_student, :enterprise_name, :is_delete, :syllabus_id, :end_time, :end_term, :publish_resource, :is_copy, :endup_time,
|
||||||
:setup_time, :school_id
|
:setup_time, :school_id
|
||||||
|
@ -72,7 +68,7 @@ class Course < ActiveRecord::Base
|
||||||
acts_as_nested_set :order => 'name', :dependent => :destroy
|
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||||
acts_as_attachable :view_permission => :view_course_files,
|
acts_as_attachable :view_permission => :view_course_files,
|
||||||
:delete_permission => :manage_files
|
:delete_permission => :manage_files
|
||||||
|
|
||||||
validates_presence_of :term,:name
|
validates_presence_of :term,:name
|
||||||
validates_format_of :class_period, :with =>/^[1-9]\d*$/
|
validates_format_of :class_period, :with =>/^[1-9]\d*$/
|
||||||
validates_format_of :time, :with => /^\d{4}$/
|
validates_format_of :time, :with => /^\d{4}$/
|
||||||
|
@ -309,7 +305,7 @@ class Course < ActiveRecord::Base
|
||||||
def self_validate
|
def self_validate
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_files_public
|
def update_files_public
|
||||||
unless self.is_public?
|
unless self.is_public?
|
||||||
self.attachments.each do |a|
|
self.attachments.each do |a|
|
||||||
|
@ -367,7 +363,7 @@ class Course < ActiveRecord::Base
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
end_time = Time.parse("3000-01-01")
|
end_time = Time.parse("3000-01-01")
|
||||||
Rails.logger.error "[Error] course endup_time error. ===> #{e}"
|
Rails.logger.error "[Error] course endup_time error. ===> #{e}"
|
||||||
ensure
|
ensure
|
||||||
return end_time
|
return end_time
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -537,5 +533,3 @@ end
|
||||||
|
|
||||||
# Index all article records from the DB to Elasticsearch
|
# Index all article records from the DB to Elasticsearch
|
||||||
#Course.where('is_public = 1').import :force=>true
|
#Course.where('is_public = 1').import :force=>true
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ class Memo < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
include UserScoreHelper
|
include UserScoreHelper
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
include Elasticsearch::Model
|
|
||||||
belongs_to :forum
|
belongs_to :forum
|
||||||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||||
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
|
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
|
||||||
|
@ -15,9 +14,8 @@ class Memo < ActiveRecord::Base
|
||||||
validate :cannot_reply_to_locked_topic, :on => :create
|
validate :cannot_reply_to_locked_topic, :on => :create
|
||||||
|
|
||||||
|
|
||||||
#elasticsearch kaminari init
|
#elasticsearch
|
||||||
Kaminari::Hooks.init
|
include Searchable
|
||||||
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
|
|
||||||
settings index: {
|
settings index: {
|
||||||
number_of_shards: 5 ,
|
number_of_shards: 5 ,
|
||||||
analysis: {
|
analysis: {
|
||||||
|
@ -196,7 +194,7 @@ class Memo < ActiveRecord::Base
|
||||||
def locked?
|
def locked?
|
||||||
self.lock
|
self.lock
|
||||||
end
|
end
|
||||||
|
|
||||||
def editable_by? user
|
def editable_by? user
|
||||||
# user && user.logged? || (self.author == usr && usr.allowed_to?(:edit_own_messages, project))
|
# user && user.logged? || (self.author == usr && usr.allowed_to?(:edit_own_messages, project))
|
||||||
user.admin? || self.author == user
|
user.admin? || self.author == user
|
||||||
|
|
|
@ -31,10 +31,7 @@ class Project < ActiveRecord::Base
|
||||||
# Specific overidden Activities
|
# Specific overidden Activities
|
||||||
|
|
||||||
#elasticsearch
|
#elasticsearch
|
||||||
include Elasticsearch::Model
|
include Searchable
|
||||||
#elasticsearch kaminari init
|
|
||||||
Kaminari::Hooks.init
|
|
||||||
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
|
|
||||||
settings index: { number_of_shards: 5 } do
|
settings index: { number_of_shards: 5 } do
|
||||||
mappings dynamic: 'false' do
|
mappings dynamic: 'false' do
|
||||||
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :name, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
|
|
|
@ -3,10 +3,7 @@ class Syllabus < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
#elasticsearch
|
#elasticsearch
|
||||||
include Elasticsearch::Model
|
include Searchable
|
||||||
#elasticsearch kaminari init
|
|
||||||
Kaminari::Hooks.init
|
|
||||||
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
|
|
||||||
settings index: { number_of_shards: 5 } do
|
settings index: { number_of_shards: 5 } do
|
||||||
mappings dynamic: 'false' do
|
mappings dynamic: 'false' do
|
||||||
indexes :title, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :title, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
|
|
|
@ -26,10 +26,7 @@ class User < Principal
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
seems_rateable_rater
|
seems_rateable_rater
|
||||||
#elasticsearch
|
#elasticsearch
|
||||||
include Elasticsearch::Model
|
include Searchable
|
||||||
#elasticsearch kaminari init
|
|
||||||
Kaminari::Hooks.init
|
|
||||||
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
|
|
||||||
settings index: { number_of_shards: 5 } do
|
settings index: { number_of_shards: 5 } do
|
||||||
mappings dynamic: 'false' do
|
mappings dynamic: 'false' do
|
||||||
indexes :login, analyzer: 'smartcn',index_options: 'offsets'
|
indexes :login, analyzer: 'smartcn',index_options: 'offsets'
|
||||||
|
|
Loading…
Reference in New Issue