Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 321
- Log:
Sort Parts by name whenever Parts are listed in views.
- Author:
- rool
- Date:
- Fri Mar 18 14:39:24 +0000 2011
- Size:
- 3694 Bytes
1 | class TicketsController < ApplicationController |
2 | helper :sort |
3 | include SortHelper |
4 | before_filter :login_required |
5 | |
6 | # Beyond Collboa's built in login stuff, account management for guests |
7 | # done via Hub. Normally if you can read a ticket you can comment on it; |
8 | # we want to limit that to prevent spam. |
9 | |
10 | @@hubssolib_permissions = HubSsoLib::Permissions.new({ |
11 | :comment => [ :admin, :webmaster, :privileged, :normal ], |
12 | :new => [ :admin, :webmaster, :privileged, :normal ], |
13 | }) |
14 | |
15 | def TicketsController.hubssolib_permissions |
16 | @@hubssolib_permissions |
17 | end |
18 | |
19 | def index |
20 | # Redirect to a "default" filter once we've added so we can save filters |
21 | redirect_to :action => 'filter', :status => 1 |
22 | end |
23 | |
24 | def filter |
25 | sort_init('created_at', 'desc') |
26 | sort_update |
27 | |
28 | @milestones = Milestone.find(:all) |
29 | @parts = Part.find(:all, :order => 'name ASC') |
30 | @severities = Severity.find(:all, :order => 'position DESC') |
31 | @status = Status.find(:all) |
32 | logger.info "sort_clause: #{sort_clause}" |
33 | @tickets = Ticket.find_by_filter(params, sort_clause) |
34 | render :action => 'index' |
35 | end |
36 | |
37 | def show |
38 | @milestones = Milestone.find(:all) |
39 | @parts = Part.find(:all, :order => 'name ASC') |
40 | @severities = Severity.find(:all, :order => 'position DESC') |
41 | @releases = Release.find(:all) |
42 | @status = Status.find(:all) |
43 | |
44 | begin |
45 | @ticket = Ticket.find(params[:id], :include => [ :severity, :part, :status, :milestone ]) |
46 | rescue ActiveRecord::RecordNotFound |
47 | render :text => "Unknown ticket number" and return |
48 | end |
49 | end |
50 | |
51 | def comment |
52 | @milestones = Milestone.find(:all) |
53 | @parts = Part.find(:all, :order => 'name ASC') |
54 | @severities = Severity.find(:all, :order => 'position DESC') |
55 | @releases = Release.find(:all) |
56 | @status = Status.find(:all) |
57 | |
58 | begin |
59 | @ticket = Ticket.find(params[:id], :include => [ :severity, :part, :status, :milestone ]) |
60 | rescue ActiveRecord::RecordNotFound |
61 | render :text => "Unknown ticket number" and return |
62 | end |
63 | |
64 | @change = TicketChange.new |
65 | @change.author = hubssolib_unique_name |
66 | |
67 | @change.attributes = params[:change] |
68 | @ticket.attributes = params[:ticket] |
69 | |
70 | if request.post? && (@change.valid? && @ticket.valid?) |
71 | @change.author = params[:change][:author] |
72 | if @ticket.save(params) |
73 | redirect_to :action => 'show', :id => @ticket.id |
74 | end |
75 | end |
76 | end |
77 | |
78 | def attachment |
79 | @change = TicketChange.find(params[:id]) |
80 | unless @change.has_attachment? |
81 | redirect_to :action => 'show', :id => @change.ticket_id |
82 | else |
83 | begin |
84 | fullpath = @change.attachment_fsname |
85 | send_file(fullpath, :filename => @change.attachment,:type => @change.content_type, :disposition => 'inline') |
86 | rescue |
87 | render :text => "Could not find an attachment for this id" |
88 | end |
89 | end |
90 | end |
91 | |
92 | def new |
93 | @milestones = Milestone.find(:all, :conditions => "completed = 0") |
94 | @parts = Part.find(:all, :order => 'name ASC') |
95 | @severities = Severity.find(:all, :order => 'position DESC') |
96 | @releases = Release.find(:all) |
97 | |
98 | @ticket = Ticket.new |
99 | @ticket.author ||= hubssolib_unique_name |
100 | |
101 | if request.post? |
102 | @ticket = Ticket.new(params[:ticket]) |
103 | @ticket.author = params[:ticket][:author] |
104 | @ticket.author_host = request.remote_ip |
105 | @ticket.status = Status.find_by_name('Open') |
106 | |
107 | if @ticket.save |
108 | redirect_to :action => 'show', :id => @ticket.id |
109 | end |
110 | end |
111 | end |
112 | |
113 | private |
114 | def authorize?(user) |
115 | if action_name == 'new' |
116 | user.create_tickets? |
117 | else |
118 | user.view_tickets? |
119 | end |
120 | end |
121 | |
122 | end |