fix for tickets

This commit is contained in:
Harry Bomrah 2017-04-12 19:43:24 +08:00
parent 05ff4b488c
commit fd3f22abaa
3 changed files with 19 additions and 8 deletions

View File

@ -107,6 +107,7 @@ class Admin::TicketsApiController < ApplicationController
response["ticket"] = get_ticket_hash(ticket) response["ticket"] = get_ticket_hash(ticket)
response["ticket"]["creator_name"] = ticket.ticket_creater_name response["ticket"]["creator_name"] = ticket.ticket_creater_name
response["ticket"]["creator_id"] = ticket.ticket_creater_id response["ticket"]["creator_id"] = ticket.ticket_creater_id
response["ticket"]["creater_cpanel_id"] = ticket.ticket_creater_cpanel_id
response["ticket"]["queries"] = [] response["ticket"]["queries"] = []
ticket.ticket_queries.asc(:created_at).each do |qu| ticket.ticket_queries.asc(:created_at).each do |qu|
r = {"query" => qu.query, "responses" => []} r = {"query" => qu.query, "responses" => []}

View File

@ -8,6 +8,7 @@ class Ticket
field :site_type field :site_type
field :ticket_creater_id field :ticket_creater_id
field :ticket_creater_name field :ticket_creater_name
field :ticket_creater_cpanel_id
field :subject field :subject
field :urgent, type: Boolean, default: false field :urgent, type: Boolean, default: false
field :reopened_count, type: Integer, :default => 0 field :reopened_count, type: Integer, :default => 0
@ -23,13 +24,17 @@ class Ticket
belongs_to :registered_site 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? def can_be_reopened?
self.reopened_count < 2 self.reopened_count < 2
end end
def author
!self.ticket_creater_name.nil? ? self.ticket_creater_name : self.ticket_creater_cpanel_id
end
def is_urgent? def is_urgent?
self.urgent self.urgent
end end

View File

@ -11,4 +11,9 @@ class TicketQueryResponse
scope :for_clients, ->{ where(:internal_response.in => [nil, false]) } scope :for_clients, ->{ where(:internal_response.in => [nil, false]) }
belongs_to :ticket_query belongs_to :ticket_query
def author
User.find(self.response_by)
end
end end