summaryrefslogtreecommitdiff
path: root/help/app/controllers
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2012-11-08 15:30:04 -0800
committerjessib <jessib@riseup.net>2012-11-08 15:30:04 -0800
commit30f04a24fe0dcbdc779584ec92c1a06801195f86 (patch)
tree590b4bee0124fe72a87b8ea78fbae4da42ad82b3 /help/app/controllers
parent2f44497b6206ad7b31e7444f52609cb3e56b8ab5 (diff)
First attempt at functionality for admins viewing their own tickets.
Diffstat (limited to 'help/app/controllers')
-rw-r--r--help/app/controllers/tickets_controller.rb17
1 files changed, 17 insertions, 0 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