client_management/app/models/site_construct.rb

40 lines
1.1 KiB
Ruby
Raw Normal View History

class SiteConstruct
include Mongoid::Document
include Mongoid::Timestamps
SERVER_TYPES = SiteServer.all.map{|s| s.server_name}
SITE_TYPES = ["School","Gravity"]
field :server_type
field :site_name
field :domain_name
2021-01-19 04:48:03 +00:00
field :nginx_file
field :db_name
field :port, type: String, :default => "80"
field :path
field :site_type
field :school_name
field :user_id
field :constructed, type: Boolean, :default => false
field :status, type: String, :default => ""
field :infos, type: Array, :default => []
2021-01-19 04:48:03 +00:00
field :hidden, type: Boolean, :default => false
after_initialize do |record|
if record.status.nil?
record.status = ""
record.save
end
if record.infos.nil?
record.infos = []
record.save
end
2021-01-19 04:48:03 +00:00
if record.nginx_file.nil?
record.nginx_file = "/etc/nginx/orbit_sites/"+record.site_name.to_s
record.save
end
if record.path.nil?
dir_path = ((record.site_type == "School" && !record.school_name.blank?) ? "school_sites/#{record.school_name}" : "orbit_sites")
record.path = "/home/rulingcom/#{dir_path}"
end
end
end