summaryrefslogtreecommitdiff
path: root/help/app/models
diff options
context:
space:
mode:
authorjessib <jessib@leap.se>2013-01-14 11:19:55 -0800
committerjessib <jessib@leap.se>2013-01-14 11:19:55 -0800
commit2485527650c4832d764d318e91c10bafde8b8ae5 (patch)
treeb624178d9d6e3279f38340e86d2097a338b434d6 /help/app/models
parentce8b283255e2be4c0f42b3223c3cf4ad33364933 (diff)
Some fixes to the how we keep track of information about users associated with a ticket.
Diffstat (limited to 'help/app/models')
-rw-r--r--help/app/models/ticket.rb13
-rw-r--r--help/app/models/ticket_comment.rb4
2 files changed, 16 insertions, 1 deletions
diff --git a/help/app/models/ticket.rb b/help/app/models/ticket.rb
index fed2b8b..262d5a4 100644
--- a/help/app/models/ticket.rb
+++ b/help/app/models/ticket.rb
@@ -30,7 +30,7 @@ class Ticket < CouchRest::Model::Base
timestamps!
#before_validation :set_created_by, :set_code, :set_email, :on => :create
- before_validation :set_email, :on => :create
+ before_validation :set_email, :set_regarding_user, :on => :create
#named_scope :open, :conditions => {:is_open => true} #??
@@ -171,6 +171,10 @@ class Ticket < CouchRest::Model::Base
# in controller set to be current users email if that exists
end
+ def set_regarding_user
+ self.regarding_user = nil if self.regarding_user == ""
+ end
+
#not saving with close and reopen, as we will save in update when they are called.
#TODO: not sure if we should bother with these:
def close
@@ -209,6 +213,13 @@ class Ticket < CouchRest::Model::Base
end
end
+ def created_by_user
+ User.find(self.created_by)
+ end
+
+ def regarding_user_actual_user
+ User.find_by_login(self.regarding_user)
+ end
=begin
def validate
if email_address and not email_address.strip =~ RFC822::EmailAddress
diff --git a/help/app/models/ticket_comment.rb b/help/app/models/ticket_comment.rb
index 18da3e1..1df7eec 100644
--- a/help/app/models/ticket_comment.rb
+++ b/help/app/models/ticket_comment.rb
@@ -22,6 +22,10 @@ class TicketComment
!!posted_by
end
+ def posted_by_user
+ User.find(self.posted_by)
+ end
+
=begin
#TODO.
#this is resetting all comments associated with the ticket: