client_management/app/models/site_request.rb

59 lines
1.5 KiB
Ruby
Raw Normal View History

2017-03-07 09:37:28 +00:00
class SiteRequest
include Mongoid::Document
include Mongoid::Timestamps
include Slug
field :site_id
field :host_with_rulingdigital, type: Boolean, default: false
field :server_details
2017-03-27 07:15:25 +00:00
field :maintenance, type: Boolean, default: false
field :maintenance_years, type: Integer
2017-03-07 09:37:28 +00:00
field :optional_modules, type: Array, default: []
field :custom_module, type: Boolean, default: false
field :custom_module_details
field :template_number
field :custom_template, type: Boolean, default: false
field :custom_template_details
field :rwd, type: Boolean, default: false
field :sites_to_add, type: Array, default: []
field :sites_added, type: Array, default: []
2017-03-07 09:37:28 +00:00
field :completed, type: Boolean, :default => false
field :type
field :site_title
field :upgrade_r2_site
field :new_site_url
2017-03-07 09:37:28 +00:00
belongs_to :site_purchase
belongs_to :request_contract
belongs_to :c_panel_user
has_one :site_timeline
has_many :project_posts
2017-03-07 09:37:28 +00:00
def get_site
self.site_id == "newsite" || self.site_id == "upgrade" ? nil : (RegisteredSite.find(self.site_id) rescue nil)
end
def get_r2_site_link
if self.upgrade_r2_site.starts_with?("http://") || self.upgrade_r2_site.starts_with?("https://")
self.upgrade_r2_site
else
"http://#{self.upgrade_r2_site}"
end
2017-03-07 09:37:28 +00:00
end
def get_request_type
2017-03-07 09:37:28 +00:00
case self.type
when "upgrade"
t = "Upgrade"
2017-03-07 09:37:28 +00:00
when "newsite"
t = "New Site"
when "existing"
t = "New Feature"
when "addsites"
t = "Sites Addition"
end
t
end
end