2015-08-03 10:54:33 +00:00
|
|
|
class Ticket
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include OrbitTag::Taggable
|
|
|
|
include OrbitCategory::Categorizable
|
|
|
|
include Slug
|
|
|
|
|
|
|
|
field :site_type
|
|
|
|
field :ticket_creater_id
|
|
|
|
field :ticket_creater_name
|
|
|
|
field :subject
|
2015-08-18 18:28:47 +00:00
|
|
|
field :urgent, type: Boolean, default: false
|
2015-08-03 10:54:33 +00:00
|
|
|
field :reopened_count, type: Integer, :default => 0
|
|
|
|
field :status, :default => "open"
|
|
|
|
field :taken_by, type: BSON::ObjectId
|
|
|
|
|
|
|
|
scope :open, ->{ where(status: "open") }
|
|
|
|
scope :closed, ->{ where(status: "closed") }
|
|
|
|
scope :commenced, ->{ where(status: "commenced") }
|
2015-08-18 18:28:47 +00:00
|
|
|
scope :not_urgent, ->{ where(:urgent.in => [false,nil]) }
|
|
|
|
scope :all_urgent, ->{ where(urgent: true) }
|
2015-08-03 10:54:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
belongs_to :registered_site
|
|
|
|
|
|
|
|
has_many :ticket_queries, :dependent => :destroy
|
|
|
|
|
|
|
|
|
|
|
|
def can_be_reopened?
|
|
|
|
self.reopened_count < 2
|
|
|
|
end
|
|
|
|
|
2015-08-18 18:28:47 +00:00
|
|
|
def is_urgent?
|
|
|
|
self.urgent
|
|
|
|
end
|
|
|
|
|
|
|
|
def reopened?
|
|
|
|
self.reopened_count > 0
|
|
|
|
end
|
2015-08-03 10:54:33 +00:00
|
|
|
|
2015-08-18 18:28:47 +00:00
|
|
|
def registered_site_title
|
|
|
|
self.registered_site.title
|
|
|
|
end
|
|
|
|
|
|
|
|
def registered_site_domain
|
|
|
|
self.registered_site.site_domain
|
|
|
|
end
|
2015-08-03 10:54:33 +00:00
|
|
|
end
|