From a6de1561461cc719fddd8175c93588a47513a4b8 Mon Sep 17 00:00:00 2001 From: jessib Date: Fri, 5 Oct 2012 15:41:03 -0700 Subject: Rough code to add & comment on tickets. --- help/app/models/ticket_comment.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'help/app/models/ticket_comment.rb') diff --git a/help/app/models/ticket_comment.rb b/help/app/models/ticket_comment.rb index 652133a..6b6b4db 100644 --- a/help/app/models/ticket_comment.rb +++ b/help/app/models/ticket_comment.rb @@ -2,13 +2,13 @@ class TicketComment include CouchRest::Model::Embeddable #belongs_to :ticket #is this best way to do it? will want to access all of a tickets comments, so maybe this isn't the way? - property :posted_by, Integer, :protected => true# maybe this should be current_user if that is set, meaning the user is logged in #String # user?? + property :posted_by, Integer#, :protected => true# maybe this should be current_user if that is set, meaning the user is logged in #String # user?? # if the current user is not set, then we could just say the comment comes from an 'unauthenticated user', which would be somebody with the secret URL - property :posted_at, Time, :protected => true + property :posted_at, Time#, :protected => true #property :posted_verified, TrueClass, :protected => true #should be true if current_user is set when the comment is created property :body, String - before_validation :set_time#, :set_posted_by + #before_validation :set_time#, :set_posted_by #design do # view :by_posted_at @@ -18,10 +18,14 @@ class TicketComment def is_comment_validated? !!posted_by end - + +=begin + #TODO. + #this is resetting all comments associated with the ticket: def set_time self.posted_at = Time.now end +=end =begin def set_posted_by -- cgit v1.2.3 From c27f2a0686db0705553eda88c799d4c486c20bac Mon Sep 17 00:00:00 2001 From: jessib Date: Wed, 10 Oct 2012 10:55:25 -0700 Subject: Pushing some tweaks as I try to get server-side validation working. --- help/app/models/ticket_comment.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'help/app/models/ticket_comment.rb') diff --git a/help/app/models/ticket_comment.rb b/help/app/models/ticket_comment.rb index 6b6b4db..9026bc1 100644 --- a/help/app/models/ticket_comment.rb +++ b/help/app/models/ticket_comment.rb @@ -8,6 +8,8 @@ class TicketComment #property :posted_verified, TrueClass, :protected => true #should be true if current_user is set when the comment is created property :body, String + + validates :body, :presence => true #before_validation :set_time#, :set_posted_by #design do -- cgit v1.2.3 From 48d6c2aac9ae2bf1c140e734a576e45289c99150 Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 16 Oct 2012 15:51:35 -0700 Subject: Some functional tests and other tweaks. --- help/app/models/ticket_comment.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'help/app/models/ticket_comment.rb') diff --git a/help/app/models/ticket_comment.rb b/help/app/models/ticket_comment.rb index 9026bc1..a8639a1 100644 --- a/help/app/models/ticket_comment.rb +++ b/help/app/models/ticket_comment.rb @@ -2,13 +2,13 @@ class TicketComment include CouchRest::Model::Embeddable #belongs_to :ticket #is this best way to do it? will want to access all of a tickets comments, so maybe this isn't the way? - property :posted_by, Integer#, :protected => true# maybe this should be current_user if that is set, meaning the user is logged in #String # user?? + property :posted_by, String#, :protected => true #Integer#this should be current_user if that is set, meaning the user is logged in #cannot have it be protected and set via comments_attributes= # if the current user is not set, then we could just say the comment comes from an 'unauthenticated user', which would be somebody with the secret URL property :posted_at, Time#, :protected => true #property :posted_verified, TrueClass, :protected => true #should be true if current_user is set when the comment is created property :body, String - + # ? timestamps! validates :body, :presence => true #before_validation :set_time#, :set_posted_by -- cgit v1.2.3 From 8b9d5235faed6c15e8ef2e2dc76aec7f24d0bb50 Mon Sep 17 00:00:00 2001 From: jessib Date: Thu, 18 Oct 2012 13:42:37 -0700 Subject: Uses the working authentication code. --- help/app/models/ticket_comment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'help/app/models/ticket_comment.rb') diff --git a/help/app/models/ticket_comment.rb b/help/app/models/ticket_comment.rb index a8639a1..49e5c6c 100644 --- a/help/app/models/ticket_comment.rb +++ b/help/app/models/ticket_comment.rb @@ -2,7 +2,7 @@ class TicketComment include CouchRest::Model::Embeddable #belongs_to :ticket #is this best way to do it? will want to access all of a tickets comments, so maybe this isn't the way? - property :posted_by, String#, :protected => true #Integer#this should be current_user if that is set, meaning the user is logged in #cannot have it be protected and set via comments_attributes= + property :posted_by, String#, :protected => true #Integer#this should be current_user if that is set, meaning the user is logged in #cannot have it be protected and set via comments_attributes=. also, if it is protected and we set in the tickets_controller, it gets unset. TODO---is this okay to have it not protected and manually check it? We do not users to be able to set this. # if the current user is not set, then we could just say the comment comes from an 'unauthenticated user', which would be somebody with the secret URL property :posted_at, Time#, :protected => true #property :posted_verified, TrueClass, :protected => true #should be true if current_user is set when the comment is created -- cgit v1.2.3