Class: Site

Inherits:
Object
  • Object
show all
Includes:
AuxModel, Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/site.rb

Constant Summary collapse

LANGUAGES =
[ 'en', 'ru', 'pt' ]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from AuxModel

#add_newsitem

Class Method Details

.listObject

manager uses it.


66
67
68
69
# File 'lib/site.rb', line 66

def self.list
  out = self.all.order_by( :domain => :asc, :lang => :asc )
  [['Select Site', nil]] + out.map { |item| [ "#{item.domain} #{item.lang}", item.id ] }
end

.mobiObject


71
72
73
# File 'lib/site.rb', line 71

def self.mobi
  Site.where( :domain => 'travel-guide.mobi', :lang => 'en' ).first
end

.seduxObject


90
91
92
93
94
# File 'lib/site.rb', line 90

def self.sedux
  site   = Site.where( :domain => 'sedux.local' ).first
  site ||= Site.where( :domain => 'sedux.net'   ).first
  site
end

.TgmObject


87
88
89
# File 'lib/site.rb', line 87

def self.Tgm
  Site.find_by( :domain => 'travel-guide.mobi', :lang => :en )
end

Instance Method Details

#its_localesObject


83
84
85
# File 'lib/site.rb', line 83

def its_locales
  Site.where( :domain => self.domain ).map { |s| s.lang.to_sym }
end

#n_private_reportsObject


79
80
81
# File 'lib/site.rb', line 79

def n_private_reports
  self.reports.unscoped.where( :is_public => false, :is_trash => false ).length
end

#n_reportsObject


75
76
77
# File 'lib/site.rb', line 75

def n_reports
  self.reports.unscoped.where( :is_trash => false ).length
end

#nameObject


96
97
98
# File 'lib/site.rb', line 96

def name
  "#{domain}/#{lang}"
end