class RegisteredSite include Mongoid::Document include Mongoid::Timestamps include OrbitTag::Taggable include OrbitCategory::Categorizable include Slug field :site_domain field :title, as: :slug_title, localize: true field :description, localize: true field :access_granted, type: Boolean, :default => false field :admin_email field :site_confirmed, type: Boolean, :default => false field :confirmation_token index({ confirmation_token: 1}, { unique: true }) def site_token self.uid end def generate_confirmation_token self.confirmation_token = SecureRandom.hex(5) self.save end def active? return self.access_granted && self.site_confirmed end end