diff options
Diffstat (limited to 'help')
-rw-r--r-- | help/app/models/ticket.rb | 16 | ||||
-rw-r--r-- | help/app/models/ticket_comment.rb | 2 | ||||
-rw-r--r-- | help/app/views/tickets/index.html.haml | 5 | ||||
-rw-r--r-- | help/app/views/tickets/new.html.haml | 15 | ||||
-rw-r--r-- | help/app/views/tickets/show.html.haml | 5 |
5 files changed, 34 insertions, 9 deletions
diff --git a/help/app/models/ticket.rb b/help/app/models/ticket.rb index 355ae02..8cec0df 100644 --- a/help/app/models/ticket.rb +++ b/help/app/models/ticket.rb @@ -15,8 +15,8 @@ class Ticket < CouchRest::Model::Base =end #belongs_to :user #from leap_web_users. doesn't necessarily belong to a user though - property :created_by, Integer #nil unless user was authenticated for ticket creation, #THIS should not be changed after being set - property :regarding_user, 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 :created_by, String#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? #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 @@ -29,6 +29,8 @@ class Ticket < CouchRest::Model::Base timestamps! + #accepts_nested_attributes_for :ticketcomments #?? + #before_validation :set_created_by, :set_code, :set_email, :on => :create before_validation :set_code, :set_email, :on => :create @@ -36,7 +38,11 @@ class Ticket < CouchRest::Model::Base view :by_title end + validates :title, :presence => true + validates :comments, :presence => true #do we want it like this? + + # html5 has built-in validation which isn't ideal, as it says 'please enter an email address' for invalid email addresses, which implies an email address is required, and it is not. validates :email, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :if => :email #email address is optional #TODO: @@ -55,6 +61,7 @@ class Ticket < CouchRest::Model::Base def set_email + self.email = nil if self.email == "" #self.email = current users email if is_creator_validated? end @@ -68,6 +75,11 @@ class Ticket < CouchRest::Model::Base save end + #probably not useful, but trying it: + def ticket_comment_attributes=(attributes) + @ticket_comment = TicketComment.new(attributes) + 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 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 diff --git a/help/app/views/tickets/index.html.haml b/help/app/views/tickets/index.html.haml index 55bfa79..d2e0ea0 100644 --- a/help/app/views/tickets/index.html.haml +++ b/help/app/views/tickets/index.html.haml @@ -2,4 +2,7 @@ - @tickets.each do |ticket| %p = link_to ticket.title, ticket -= #render(:partial => "ticket", :collection => @tickets)
\ No newline at end of file +%p +Create a += link_to "new ticket", new_ticket_path += #render(:partial => "ticket", :collection => @tickets) diff --git a/help/app/views/tickets/new.html.haml b/help/app/views/tickets/new.html.haml index fd1bcd4..d0e6939 100644 --- a/help/app/views/tickets/new.html.haml +++ b/help/app/views/tickets/new.html.haml @@ -1,12 +1,19 @@ %h2=t :new_ticket -= simple_form_for @ticket do |f| += simple_form_for (@ticket, :html => {:novalidate => true}) do |f| #turn off html5 validations to test + = @ticket.errors.messages = f.input :title = #f.input :email #if there is no current_user - = f.input :email if !User.current_test - = #simple_fields_for :comment do |c| + = f.input :email if !User.current_test #hmm--might authenticated users want to submit an alternate email? + = #f.simple_fields_for :comment do |c| = #c.input :body, :label => 'Comment', :as => :text + = #f.input :comments, :label => 'Comment', :as => :text + + = f.fields_for :comment do |c| + = c.input :body, :label => 'Comment', :as => :text + + = #f.input :comment - = render :partial => 'new_comment' + = #render :partial => 'new_comment' #what we were using = # regarding_user if not logged in = # email if not logged in = #f.button :submit, :value => t(:submit), :class => 'btn-primary' diff --git a/help/app/views/tickets/show.html.haml b/help/app/views/tickets/show.html.haml index a37f5c8..1e1fab3 100644 --- a/help/app/views/tickets/show.html.haml +++ b/help/app/views/tickets/show.html.haml @@ -5,6 +5,7 @@ code: = @ticket.code = render(:partial => "comment", :collection => @ticket.comments) -= simple_form_for @ticket do |f| += simple_form_for (@ticket, :html => {:novalidate => true}) do |f| #turn off html5 validations to test = render :partial => 'new_comment' - = f.button :submit
\ No newline at end of file + = f.button :submit + = link_to t(:cancel), root_url, :class => :btn
\ No newline at end of file |