summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--help/app/controllers/tickets_controller.rb17
-rw-r--r--help/app/views/tickets/index.html.haml6
-rw-r--r--help/app/views/tickets/show.html.haml1
3 files changed, 23 insertions, 1 deletions
diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb
index f3184ef..6011232 100644
--- a/help/app/controllers/tickets_controller.rb
+++ b/help/app/controllers/tickets_controller.rb
@@ -84,6 +84,10 @@ class TicketsController < ApplicationController
@tickets = Ticket.by_is_open.key(true)
elsif params[:status] == 'closed'
@tickets = Ticket.by_is_open.key(false)
+ elsif params[:status] == 'open tickets I admin' #TODO: obviously temp hack
+ @tickets = tickets_by_admin(current_user.id)
+ elsif params[:status] == 'all tickets I admin' #TODO: obviously temp hack
+ @tickets = tickets_by_admin(current_user.id, false)
else
@tickets = Ticket.all
end
@@ -120,6 +124,19 @@ class TicketsController < ApplicationController
access_denied unless ticket_access?
end
+ def tickets_by_admin(id=current_user.id, just_open=true)
+ admin_tickets = []
+ tickets = Ticket.all
+ tickets.each do |ticket|
+ ticket.comments.each do |comment|
+ if comment.posted_by == id and (!just_open or ticket.is_open)
+ admin_tickets << ticket
+ break
+ end
+ end
+ end
+ admin_tickets
+ end
def set_strings
@post_reply_str = 'Post reply' #t :post_reply
diff --git a/help/app/views/tickets/index.html.haml b/help/app/views/tickets/index.html.haml
index dff39ce..8fe4055 100644
--- a/help/app/views/tickets/index.html.haml
+++ b/help/app/views/tickets/index.html.haml
@@ -4,7 +4,11 @@ Create a
= # below shouldn't be unless logged in
%h2 Tickets
= form_tag (tickets_path, :method => :get) do # want to redo as ajax, and make sure it displays the selected option
- = select_tag :status, options_for_select(["open", "closed", "all"])
+ - options = ["open", "closed", "all"]
+ - if admin?
+ - options << "open tickets I admin" # obviously not what we will want
+ - options << "all tickets I admin" # obviously not what we will want
+ = select_tag :status, options_for_select(options) # TODO
= submit_tag "filter"
- @tickets.each do |ticket|
%p
diff --git a/help/app/views/tickets/show.html.haml b/help/app/views/tickets/show.html.haml
index acd3a61..77d168a 100644
--- a/help/app/views/tickets/show.html.haml
+++ b/help/app/views/tickets/show.html.haml
@@ -21,6 +21,7 @@
= 'closed'
= button_to 'open', {:change_status => :open}, :method => :put
= render(:partial => "comment", :collection => @ticket.comments)
+= #render @ticket.comments should work if view is in /app/views/comments/_comment
= simple_form_for(@ticket, :html => {:novalidate => true}) do |f| #turn off html5 validations to test
= f.simple_fields_for :comments, TicketComment.new do |c|