Class: Helpdesk::Admin::TicketsController
Instance Method Summary
collapse
#default_url_options, #ensure_user
Instance Method Details
#assign ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/helpdesk/admin/tickets_controller.rb', line 20
def assign
@ticket = Helpdesk::Ticket.find(params[:id])
if @ticket.update_column(:assignee_id, helpdesk_user)
redirect_to admin_ticket_path,
notice: t('helpdesk.tickets.is_now_assigned',subject: @ticket.subject)
else
redirect_to admin_ticket_path
end
end
|
#create ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'app/controllers/helpdesk/admin/tickets_controller.rb', line 45
def create
@ticket = Helpdesk::Ticket.new(params[:ticket])
if @ticket.save
redirect_to admin_ticket_path(@ticket)
else
render action: "new"
end
end
|
#edit ⇒ Object
35
36
37
38
|
# File 'app/controllers/helpdesk/admin/tickets_controller.rb', line 35
def edit
@ticket = Helpdesk::Ticket.find(params[:id])
end
|
#index ⇒ Object
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/controllers/helpdesk/admin/tickets_controller.rb', line 3
def index
if params[:tickets] == 'unassigned'
@tickets = Helpdesk::Ticket.unassigned.scoped
elsif params[:tickets] == 'closed'
@tickets = Helpdesk::Ticket.closed.scoped
elsif params[:tickets] == 'active'
@tickets = Helpdesk::Ticket.active.scoped
elsif params[:tickets] == 'all'
@tickets = Helpdesk::Ticket.all.scoped
else
@tickets = my_tickets.active.scoped
end
@tickets = @tickets.page(params[:page])
render 'list'
end
|
#show ⇒ Object
40
41
42
43
|
# File 'app/controllers/helpdesk/admin/tickets_controller.rb', line 40
def show
@ticket = Helpdesk::Ticket.find(params[:id])
end
|
#update ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/controllers/helpdesk/admin/tickets_controller.rb', line 54
def update
@ticket = Helpdesk::Ticket.find(params[:id])
if @ticket.update_attributes(params[:ticket])
unless @ticket.assignee
@ticket.update_column(:assignee_id, helpdesk_user)
end
redirect_to admin_ticket_path
else
render action: "new"
end
end
|