Class: Locomotive::Site

Inherits:
Object
  • Object
show all
Extended by:
Extensions::Site::FirstInstallation, Extensions::Site::SubdomainDomains
Includes:
Extensions::Shared::Seo, Extensions::Site::Locales, Extensions::Site::Timezone, Mongoid::Document
Defined in:
app/models/locomotive/site.rb

Instance Method Summary collapse

Methods included from Extensions::Site::SubdomainDomains

enable_subdomain_n_domains_if_multi_sites

Methods included from Extensions::Site::FirstInstallation

create_first_one

Methods included from Extensions::Site::Timezone

#timezone

Methods included from Extensions::Site::Locales

#default_locale, #default_locale_was, #each_locale, #is_default_locale?, #locale_fallbacks, #locales=, #localized?, #localized_page_fullpath, #prefix_default_locale?, #with_default_locale

Instance Method Details

#accountsObject



58
59
60
# File 'app/models/locomotive/site.rb', line 58

def accounts
  Account.criteria.in(_id: self.memberships.map(&:account_id))
end

#admin_membershipsObject



62
63
64
# File 'app/models/locomotive/site.rb', line 62

def admin_memberships
  self.memberships.find_all { |m| m.admin? }
end

#all_pages_in_onceObject

methods ##



40
41
42
# File 'app/models/locomotive/site.rb', line 40

def all_pages_in_once
  Page.quick_tree(self)
end

#fetch_page(path, logged_in) ⇒ Object



54
55
56
# File 'app/models/locomotive/site.rb', line 54

def fetch_page(path, logged_in)
  Locomotive::Page.fetch_page_from_path self, path, logged_in
end

#is_admin?(account) ⇒ Boolean

Returns:



66
67
68
# File 'app/models/locomotive/site.rb', line 66

def is_admin?()
  self.memberships.detect { |m| m.admin? && m. == ._id }
end

#nameObject

validations ##



14
# File 'app/models/locomotive/site.rb', line 14

field :name

#ordered_pages(conditions = {}) ⇒ Criteria

Get all the pages in the right order: depth and position, both ASC.

Parameters:

  • conditions (Hash) (defaults to: {})

    Extra conditions passed to the Mongoid criteria

Returns:

  • (Criteria)

    a Mongoid criteria



50
51
52
# File 'app/models/locomotive/site.rb', line 50

def ordered_pages(conditions = {})
  self.pages.unscoped.where(conditions || {}).order_by_depth_and_position
end

#pagesObject

associations ##



18
# File 'app/models/locomotive/site.rb', line 18

has_many    :pages,           class_name: 'Locomotive::Page',           validate: false, autosave: false