add dic models

This commit is contained in:
thomaschen 2013-08-22 15:04:46 +08:00 committed by chris
parent 5d8b65d625
commit 2fdfdeafa2
2 changed files with 126 additions and 0 deletions

View File

@ -0,0 +1,84 @@
# encoding: utf-8
class DictionaryVocab
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
include Mongoid::Sortable
# BelongsToCategory = :archive_file_category
# include OrbitCoreLib::BelongsToCategoryMayDisable
# PAYMENT_TYPES = @site_valid_locales
# include OrbitTag::Taggable
# taggable
field :word, :type => String
field :definition, :type => String
field :create_user_id
field :update_user_id
# field :is_top, :type => Boolean, :default => false
# field :is_hot, :type => Boolean, :default => false
# field :is_hidden, :type => Boolean, :default => false
# scope :can_display,where(is_hidden: false)
# belongs_to :archive_file_category
# has_many :archive_file_multiples, :autosave => true, :dependent => :destroy
# accepts_nested_attributes_for :archive_file_multiples, :allow_destroy => true
# after_save :save_archive_file_multiples
# searchable do
# text :titles do
# title_translations.to_a.collect{|t| t[1]}
# end
# boolean :frontend_search do
# !is_hidden
# end
# end
# def self.search( category_id = nil )
# if category_id.to_s.size > 0
# find(:all, :conditions => {archive_file_category_id: category_id}).desc( :is_top, :title )
# else
# find(:all).desc( :is_top, :title)
# end
# end
# def self.widget_datas
# where( :is_hidden => false ).desc(:is_top, :title)
# end
# def is_top?
# self.is_top
# end
# def get_file_icon( file_data )
# file_icon = "<span class=\"o-archives-file-type\">#{file_data.split('.')[-1]}</span>".html_safe
# end
# def save_archive_file_multiples
# self.archive_file_multiples.each do |t|
# if t.should_destroy
# t.destroy
# end
# end
# end
end

View File

@ -0,0 +1,42 @@
# encoding: utf-8
class DictionaryVocabCategory
include Mongoid::Document
include Mongoid::Timestamps
include OrbitCoreLib::ObjectAuthable
include OrbitCoreLib::ObjectDisable
include Sunspot::Mongo
# include Mongoid::MultiParameterAttributes
# APP_NAME = 'Archive'
# ObjectAuthTitlesOptions = %W{submit_new fact_check}
# AfterObjectAuthUrl = '/panel/archive/back_end/archive_file_categorys'
field :disable, type: Boolean, :default => false
field :display
field :key
field :title, localize: true
has_many :dictionary_vocabs
# searchable do
# text :titles do
# title_translations.to_a.collect{|t| t[1]}
# end
# boolean :frontend_search do
# !disable
# end
# text :files do
# archive_files.can_display.collect{|t| t.title_translations.to_a.collect{|t| t[1]}}
# end
# end
def pp_object
title
end
def self.from_id(id)
ArchiveFileCategory.find(id) rescue nil
end
end