From 313000fec18d56fba8f720ac32ae3ca8a92e4e36 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 24 Dec 2012 16:22:39 -0800 Subject: Rough functionality for unauthenticated tickets. --- help/app/models/ticket.rb | 2 +- help/app/views/tickets/_ticket_data.html.haml | 7 +++++++ help/app/views/tickets/new.html.haml | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'help') diff --git a/help/app/models/ticket.rb b/help/app/models/ticket.rb index fa056b4..fed2b8b 100644 --- a/help/app/models/ticket.rb +++ b/help/app/models/ticket.rb @@ -16,7 +16,7 @@ class Ticket < CouchRest::Model::Base #belongs_to :user #from leap_web_users. doesn't necessarily belong to a user though property :created_by, String, :protected => true #Integer #nil unless user was authenticated for ticket creation, #THIS should not be changed after being set - #property :regarding_user, String#Integer # form cannot be submitted if they type in a username w/out corresponding ID. this field can be nil. for authenticated ticket creation by non-admins, should this just automatically be set to be same as created_by? or maybe we don't use this field unless created_by is nil? + property :regarding_user, String#Integer # form cannot be submitted if they type in a username w/out corresponding ID. this field can be nil. for authenticated ticket creation by non-admins, should this just automatically be set to be same as created_by? or maybe we don't use this field unless created_by is nil? #also, both created_by and regarding_user could be nil---say user forgets username, or has general question property :title, String property :email, String #verify diff --git a/help/app/views/tickets/_ticket_data.html.haml b/help/app/views/tickets/_ticket_data.html.haml index 3d301be..80c0d74 100644 --- a/help/app/views/tickets/_ticket_data.html.haml +++ b/help/app/views/tickets/_ticket_data.html.haml @@ -5,6 +5,13 @@ = User.find(@ticket.created_by).login - else Unauthenticated ticket creator + - if @ticket.regarding_user + %b + Regarding user: + - if regarding_user = User.find_by_login(@ticket.regarding_user) + = link_to @ticket.regarding_user, edit_user_path(regarding_user) + - else + = @ticket.regarding_user + '(no such user)' - if @ticket.email %b email: diff --git a/help/app/views/tickets/new.html.haml b/help/app/views/tickets/new.html.haml index 750b990..255be65 100644 --- a/help/app/views/tickets/new.html.haml +++ b/help/app/views/tickets/new.html.haml @@ -3,6 +3,7 @@ = simple_form_for(@ticket, :html => {:novalidate => true}) do |f| #turn off html5 validations to test = f.input :title = f.input :email if !current_user #hmm--might authenticated users want to submit an alternate email? + = f.input :regarding_user if !current_user = render :partial => 'new_comment', :locals => {:f => f} = # regarding_user if not logged in = # email if not logged in -- cgit v1.2.3 From 4f35e7555feae15fb86eb81a38d4ff39b97ab576 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 24 Dec 2012 16:34:49 -0800 Subject: Link to edit page (as show doesn't now exist, and not clear if we will want it) of user who created ticket. --- help/app/views/tickets/_ticket_data.html.haml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'help') diff --git a/help/app/views/tickets/_ticket_data.html.haml b/help/app/views/tickets/_ticket_data.html.haml index 80c0d74..fd5d3bf 100644 --- a/help/app/views/tickets/_ticket_data.html.haml +++ b/help/app/views/tickets/_ticket_data.html.haml @@ -1,8 +1,11 @@ .spam12 %b Created by: - - if User.find(@ticket.created_by) - = User.find(@ticket.created_by).login + - if creator = User.find(@ticket.created_by) + - if !creator.is_admin? + = link_to creator.login, edit_user_path(creator) + - else + = creator.login - else Unauthenticated ticket creator - if @ticket.regarding_user -- cgit v1.2.3 From 6b0fba93fc6137e83fb66cc38098f5479d1ce485 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 31 Dec 2012 15:20:31 -0800 Subject: remove commented-out lines. --- help/app/views/tickets/new.html.haml | 2 -- 1 file changed, 2 deletions(-) (limited to 'help') diff --git a/help/app/views/tickets/new.html.haml b/help/app/views/tickets/new.html.haml index 255be65..79a9af7 100644 --- a/help/app/views/tickets/new.html.haml +++ b/help/app/views/tickets/new.html.haml @@ -5,8 +5,6 @@ = f.input :email if !current_user #hmm--might authenticated users want to submit an alternate email? = f.input :regarding_user if !current_user = render :partial => 'new_comment', :locals => {:f => f} - = # regarding_user if not logged in - = # email if not logged in .form-actions = f.button :submit, :class => 'btn-primary' = link_to t(:cancel), tickets_path, :class => :btn -- cgit v1.2.3 From ce8b283255e2be4c0f42b3223c3cf4ad33364933 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 7 Jan 2013 12:25:12 -0800 Subject: Ticket comments can be private --- help/app/models/ticket_comment.rb | 1 + help/app/views/tickets/_comment.html.haml | 31 +++++++++++++++------------ help/app/views/tickets/_new_comment.html.haml | 2 ++ 3 files changed, 20 insertions(+), 14 deletions(-) (limited to 'help') diff --git a/help/app/models/ticket_comment.rb b/help/app/models/ticket_comment.rb index 49e5c6c..18da3e1 100644 --- a/help/app/models/ticket_comment.rb +++ b/help/app/models/ticket_comment.rb @@ -7,6 +7,7 @@ class TicketComment 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 + property :private, TrueClass # private comments are only viewable by admins # ? timestamps! validates :body, :presence => true diff --git a/help/app/views/tickets/_comment.html.haml b/help/app/views/tickets/_comment.html.haml index 26794dc..ae7f1d4 100644 --- a/help/app/views/tickets/_comment.html.haml +++ b/help/app/views/tickets/_comment.html.haml @@ -1,15 +1,18 @@ - # style is super ugly but just for now -%tr - %td - - if commenter = User.find(comment.posted_by) - %b - = 'Posted by' + (commenter.is_admin? ? ' admin' : '') + ':' - = commenter.login - - else - Unauthenticated post - .pull-right - %b - Posted at: - = comment.posted_at.to_s(:short) - %br - = comment.body +- if admin? or !comment.private # only show comment if user is admin or comment is not private + %tr + %td + - if commenter = User.find(comment.posted_by) + %b + = 'Posted by' + (commenter.is_admin? ? ' admin' : '') + ':' + = commenter.login + - else + Unauthenticated post + - if comment.private + (Private comment) + .pull-right + %b + Posted at: + = comment.posted_at.to_s(:short) + %br + = comment.body \ No newline at end of file diff --git a/help/app/views/tickets/_new_comment.html.haml b/help/app/views/tickets/_new_comment.html.haml index 7307dad..8d40bb6 100644 --- a/help/app/views/tickets/_new_comment.html.haml +++ b/help/app/views/tickets/_new_comment.html.haml @@ -1,2 +1,4 @@ = f.simple_fields_for :comments, @comment do |c| = c.input :body, :label => 'Comment', :as => :text, :input_html => {:class => "span12", :rows=>4} + - if admin? + = c.input :private, :as => :boolean, :label => false, :inline_label => true -- cgit v1.2.3 From 2485527650c4832d764d318e91c10bafde8b8ae5 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 14 Jan 2013 11:19:55 -0800 Subject: Some fixes to the how we keep track of information about users associated with a ticket. --- help/app/models/ticket.rb | 13 ++++++++++++- help/app/models/ticket_comment.rb | 4 ++++ help/app/views/tickets/_comment.html.haml | 6 +++--- help/app/views/tickets/_ticket_data.html.haml | 18 +++++++++--------- help/app/views/tickets/new.html.haml | 2 +- 5 files changed, 29 insertions(+), 14 deletions(-) (limited to 'help') 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: diff --git a/help/app/views/tickets/_comment.html.haml b/help/app/views/tickets/_comment.html.haml index ae7f1d4..01cf01a 100644 --- a/help/app/views/tickets/_comment.html.haml +++ b/help/app/views/tickets/_comment.html.haml @@ -2,10 +2,10 @@ - if admin? or !comment.private # only show comment if user is admin or comment is not private %tr %td - - if commenter = User.find(comment.posted_by) + - if comment.posted_by_user %b - = 'Posted by' + (commenter.is_admin? ? ' admin' : '') + ':' - = commenter.login + = 'Posted by' + (comment.posted_by_user.is_admin? ? ' admin' : '') + ':' + = comment.posted_by_user.login - else Unauthenticated post - if comment.private diff --git a/help/app/views/tickets/_ticket_data.html.haml b/help/app/views/tickets/_ticket_data.html.haml index fd5d3bf..2261d8f 100644 --- a/help/app/views/tickets/_ticket_data.html.haml +++ b/help/app/views/tickets/_ticket_data.html.haml @@ -1,20 +1,20 @@ .spam12 %b Created by: - - if creator = User.find(@ticket.created_by) - - if !creator.is_admin? - = link_to creator.login, edit_user_path(creator) - - else - = creator.login + - if @ticket.created_by_user + = link_to @ticket.created_by_user.login, edit_user_path(@ticket.created_by_user) #todo: won't want edit path - else Unauthenticated ticket creator - if @ticket.regarding_user %b Regarding user: - - if regarding_user = User.find_by_login(@ticket.regarding_user) - = link_to @ticket.regarding_user, edit_user_path(regarding_user) - - else - = @ticket.regarding_user + '(no such user)' + - if admin? + - if @ticket.regarding_user_actual_user + = link_to @ticket.regarding_user_actual_user.login, edit_user_path(@ticket.regarding_user_actual_user) #todo: won't want edit path + - else + = @ticket.regarding_user + ' (no such user)' + - else # a non-admin is viewing the ticket, so they shouldn't see confirmation of whether the regarding_user exists or not. + = @ticket.regarding_user - if @ticket.email %b email: diff --git a/help/app/views/tickets/new.html.haml b/help/app/views/tickets/new.html.haml index 79a9af7..af8baad 100644 --- a/help/app/views/tickets/new.html.haml +++ b/help/app/views/tickets/new.html.haml @@ -3,7 +3,7 @@ = simple_form_for(@ticket, :html => {:novalidate => true}) do |f| #turn off html5 validations to test = f.input :title = f.input :email if !current_user #hmm--might authenticated users want to submit an alternate email? - = f.input :regarding_user if !current_user + = f.input :regarding_user = render :partial => 'new_comment', :locals => {:f => f} .form-actions = f.button :submit, :class => 'btn-primary' -- cgit v1.2.3 From 8141876126aa25d713cf4b2c76c3ecff837c4ba7 Mon Sep 17 00:00:00 2001 From: jessib Date: Mon, 14 Jan 2013 12:39:59 -0800 Subject: Use partials for displaying details shown when viewing a user. Some of these partials have specific CSS for another use, so we will likely want to tweak this. --- help/app/views/tickets/_ticket.html.haml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'help') diff --git a/help/app/views/tickets/_ticket.html.haml b/help/app/views/tickets/_ticket.html.haml index 3edfa8b..e02aaeb 100644 --- a/help/app/views/tickets/_ticket.html.haml +++ b/help/app/views/tickets/_ticket.html.haml @@ -1,3 +1,4 @@ += # TODO---this is now used in 2 places, and not sure we want the same CSS in both places %tr %td %b @@ -5,9 +6,9 @@ %br %small created: - = ticket.created_at.to_s(:short) + = ticket.created_at.to_s(:short) #todo doesn't show year updated: - = ticket.updated_at.to_s(:short) + = ticket.updated_at.to_s(:short) # doesn't show year %small.pull-right comments by: = ticket.commenters -- cgit v1.2.3 From 9d53f7b2d1b34da6b6103e97bd6c931cedb23e9b Mon Sep 17 00:00:00 2001 From: jessib Date: Tue, 15 Jan 2013 11:03:02 -0800 Subject: Show different ticket characteristics when viewing the users versus when listing the tickets. Give a message if a user has no tickets. --- help/app/views/tickets/_ticket.html.haml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'help') diff --git a/help/app/views/tickets/_ticket.html.haml b/help/app/views/tickets/_ticket.html.haml index e02aaeb..7b37652 100644 --- a/help/app/views/tickets/_ticket.html.haml +++ b/help/app/views/tickets/_ticket.html.haml @@ -1,14 +1,17 @@ -= # TODO---this is now used in 2 places, and not sure we want the same CSS in both places +- updated_at_text = 'updated: ' + ticket.updated_at.to_s(:long) %tr %td %b = link_to ticket.title, ticket - %br - %small - created: - = ticket.created_at.to_s(:short) #todo doesn't show year - updated: - = ticket.updated_at.to_s(:short) # doesn't show year - %small.pull-right - comments by: - = ticket.commenters + - if params[:controller] == 'tickets' + %br + %small + created: + = ticket.created_at.to_s(:long) + = updated_at_text + %small.pull-right + comments by: + = ticket.commenters + - else + %small + = updated_at_text \ No newline at end of file -- cgit v1.2.3