fix for tickets
This commit is contained in:
parent
05ff4b488c
commit
fd3f22abaa
|
@ -107,6 +107,7 @@ class Admin::TicketsApiController < ApplicationController
|
|||
response["ticket"] = get_ticket_hash(ticket)
|
||||
response["ticket"]["creator_name"] = ticket.ticket_creater_name
|
||||
response["ticket"]["creator_id"] = ticket.ticket_creater_id
|
||||
response["ticket"]["creater_cpanel_id"] = ticket.ticket_creater_cpanel_id
|
||||
response["ticket"]["queries"] = []
|
||||
ticket.ticket_queries.asc(:created_at).each do |qu|
|
||||
r = {"query" => qu.query, "responses" => []}
|
||||
|
|
|
@ -2,34 +2,39 @@ class Ticket
|
|||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include OrbitTag::Taggable
|
||||
include OrbitCategory::Categorizable
|
||||
include OrbitCategory::Categorizable
|
||||
include Slug
|
||||
|
||||
field :site_type
|
||||
field :ticket_creater_id
|
||||
field :ticket_creater_name
|
||||
field :ticket_creater_cpanel_id
|
||||
field :subject
|
||||
field :urgent, type: Boolean, default: false
|
||||
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") }
|
||||
scope :not_urgent, ->{ where(:urgent.in => [false,nil]) }
|
||||
scope :all_urgent, ->{ where(urgent: true) }
|
||||
scope :open, ->{ where(status: "open") }
|
||||
scope :closed, ->{ where(status: "closed") }
|
||||
scope :commenced, ->{ where(status: "commenced") }
|
||||
scope :not_urgent, ->{ where(:urgent.in => [false,nil]) }
|
||||
scope :all_urgent, ->{ where(urgent: true) }
|
||||
|
||||
|
||||
belongs_to :registered_site
|
||||
|
||||
has_many :ticket_queries, :dependent => :destroy
|
||||
|
||||
has_many :ticket_queries, :autosave => true, :dependent => :destroy
|
||||
accepts_nested_attributes_for :ticket_queries, :allow_destroy => true
|
||||
|
||||
def can_be_reopened?
|
||||
self.reopened_count < 2
|
||||
end
|
||||
|
||||
def author
|
||||
!self.ticket_creater_name.nil? ? self.ticket_creater_name : self.ticket_creater_cpanel_id
|
||||
end
|
||||
|
||||
def is_urgent?
|
||||
self.urgent
|
||||
end
|
||||
|
|
|
@ -11,4 +11,9 @@ class TicketQueryResponse
|
|||
scope :for_clients, ->{ where(:internal_response.in => [nil, false]) }
|
||||
|
||||
belongs_to :ticket_query
|
||||
|
||||
def author
|
||||
User.find(self.response_by)
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue