Commit 28a4c227f1ce72c3fac5d74dbda591b9ce47740d
1 parent
b4356b78
Exists in
master
and in
1 other branch
indentation
Showing
1 changed file
with
27 additions
and
48 deletions
Show diff stats
app/controllers/errs_controller.rb
@@ -5,16 +5,14 @@ class ErrsController < ApplicationController | @@ -5,16 +5,14 @@ class ErrsController < ApplicationController | ||
5 | before_filter :find_problem, :except => [:index, :all, :destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several] | 5 | before_filter :find_problem, :except => [:index, :all, :destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several] |
6 | before_filter :find_selected_problems, :only => [:destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several] | 6 | before_filter :find_selected_problems, :only => [:destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several] |
7 | 7 | ||
8 | - | ||
9 | - | ||
10 | def index | 8 | def index |
11 | app_scope = current_user.admin? ? App.all : current_user.apps | 9 | app_scope = current_user.admin? ? App.all : current_user.apps |
12 | - | 10 | + |
13 | @sort = params[:sort] | 11 | @sort = params[:sort] |
14 | @order = params[:order] | 12 | @order = params[:order] |
15 | @sort = "app" unless %w{message last_notice_at last_deploy_at count}.member?(@sort) | 13 | @sort = "app" unless %w{message last_notice_at last_deploy_at count}.member?(@sort) |
16 | @order = "asc" unless (@order == "desc") | 14 | @order = "asc" unless (@order == "desc") |
17 | - | 15 | + |
18 | @problems = Problem.for_apps(app_scope).in_env(params[:environment]).unresolved.ordered_by(@sort, @order) | 16 | @problems = Problem.for_apps(app_scope).in_env(params[:environment]).unresolved.ordered_by(@sort, @order) |
19 | @selected_problems = params[:problems] || [] | 17 | @selected_problems = params[:problems] || [] |
20 | respond_to do |format| | 18 | respond_to do |format| |
@@ -25,14 +23,12 @@ class ErrsController < ApplicationController | @@ -25,14 +23,12 @@ class ErrsController < ApplicationController | ||
25 | end | 23 | end |
26 | end | 24 | end |
27 | 25 | ||
28 | - | ||
29 | def all | 26 | def all |
30 | app_scope = current_user.admin? ? App.all : current_user.apps | 27 | app_scope = current_user.admin? ? App.all : current_user.apps |
31 | @problems = Problem.for_apps(app_scope).ordered.paginate(:page => params[:page], :per_page => current_user.per_page) | 28 | @problems = Problem.for_apps(app_scope).ordered.paginate(:page => params[:page], :per_page => current_user.per_page) |
32 | @selected_problems = params[:problems] || [] | 29 | @selected_problems = params[:problems] || [] |
33 | end | 30 | end |
34 | 31 | ||
35 | - | ||
36 | def show | 32 | def show |
37 | page = (params[:notice] || @problem.notices_count) | 33 | page = (params[:notice] || @problem.notices_count) |
38 | page = 1 if page.to_i.zero? | 34 | page = 1 if page.to_i.zero? |
@@ -41,7 +37,6 @@ class ErrsController < ApplicationController | @@ -41,7 +37,6 @@ class ErrsController < ApplicationController | ||
41 | @comment = Comment.new | 37 | @comment = Comment.new |
42 | end | 38 | end |
43 | 39 | ||
44 | - | ||
45 | def create_issue | 40 | def create_issue |
46 | set_tracker_params | 41 | set_tracker_params |
47 | 42 | ||
@@ -57,13 +52,11 @@ class ErrsController < ApplicationController | @@ -57,13 +52,11 @@ class ErrsController < ApplicationController | ||
57 | redirect_to app_err_path(@app, @problem) | 52 | redirect_to app_err_path(@app, @problem) |
58 | end | 53 | end |
59 | 54 | ||
60 | - | ||
61 | def unlink_issue | 55 | def unlink_issue |
62 | @problem.update_attribute :issue_link, nil | 56 | @problem.update_attribute :issue_link, nil |
63 | redirect_to app_err_path(@app, @problem) | 57 | redirect_to app_err_path(@app, @problem) |
64 | end | 58 | end |
65 | 59 | ||
66 | - | ||
67 | def resolve | 60 | def resolve |
68 | # Deal with bug in mongoid where find is returning an Enumberable obj | 61 | # Deal with bug in mongoid where find is returning an Enumberable obj |
69 | @problem = @problem.first if @problem.respond_to?(:first) | 62 | @problem = @problem.first if @problem.respond_to?(:first) |
@@ -75,7 +68,6 @@ class ErrsController < ApplicationController | @@ -75,7 +68,6 @@ class ErrsController < ApplicationController | ||
75 | redirect_to app_path(@app) | 68 | redirect_to app_path(@app) |
76 | end | 69 | end |
77 | 70 | ||
78 | - | ||
79 | def create_comment | 71 | def create_comment |
80 | @comment = Comment.new(params[:comment].merge(:user_id => current_user.id)) | 72 | @comment = Comment.new(params[:comment].merge(:user_id => current_user.id)) |
81 | if @comment.valid? | 73 | if @comment.valid? |
@@ -88,7 +80,6 @@ class ErrsController < ApplicationController | @@ -88,7 +80,6 @@ class ErrsController < ApplicationController | ||
88 | redirect_to app_err_path(@app, @problem) | 80 | redirect_to app_err_path(@app, @problem) |
89 | end | 81 | end |
90 | 82 | ||
91 | - | ||
92 | def destroy_comment | 83 | def destroy_comment |
93 | @comment = Comment.find(params[:comment_id]) | 84 | @comment = Comment.find(params[:comment_id]) |
94 | if @comment.destroy | 85 | if @comment.destroy |
@@ -106,14 +97,12 @@ class ErrsController < ApplicationController | @@ -106,14 +97,12 @@ class ErrsController < ApplicationController | ||
106 | redirect_to :back | 97 | redirect_to :back |
107 | end | 98 | end |
108 | 99 | ||
109 | - | ||
110 | def unresolve_several | 100 | def unresolve_several |
111 | @selected_problems.each(&:unresolve!) | 101 | @selected_problems.each(&:unresolve!) |
112 | flash[:success] = "#{pluralize(@selected_problems.count, 'err has', 'errs have')} been unresolved." | 102 | flash[:success] = "#{pluralize(@selected_problems.count, 'err has', 'errs have')} been unresolved." |
113 | redirect_to :back | 103 | redirect_to :back |
114 | end | 104 | end |
115 | 105 | ||
116 | - | ||
117 | def merge_several | 106 | def merge_several |
118 | if @selected_problems.length < 2 | 107 | if @selected_problems.length < 2 |
119 | flash[:notice] = "You must select at least two errors to merge" | 108 | flash[:notice] = "You must select at least two errors to merge" |
@@ -124,58 +113,48 @@ class ErrsController < ApplicationController | @@ -124,58 +113,48 @@ class ErrsController < ApplicationController | ||
124 | redirect_to :back | 113 | redirect_to :back |
125 | end | 114 | end |
126 | 115 | ||
127 | - | ||
128 | def unmerge_several | 116 | def unmerge_several |
129 | all = @selected_problems.map(&:unmerge!).flatten | 117 | all = @selected_problems.map(&:unmerge!).flatten |
130 | flash[:success] = "#{pluralize(all.length, 'err has', 'errs have')} been unmerged." | 118 | flash[:success] = "#{pluralize(all.length, 'err has', 'errs have')} been unmerged." |
131 | redirect_to :back | 119 | redirect_to :back |
132 | end | 120 | end |
133 | 121 | ||
134 | - | ||
135 | def destroy_several | 122 | def destroy_several |
136 | @selected_problems.each(&:destroy) | 123 | @selected_problems.each(&:destroy) |
137 | flash[:notice] = "#{pluralize(@selected_problems.count, 'err has', 'errs have')} been deleted." | 124 | flash[:notice] = "#{pluralize(@selected_problems.count, 'err has', 'errs have')} been deleted." |
138 | redirect_to :back | 125 | redirect_to :back |
139 | end | 126 | end |
140 | 127 | ||
128 | + protected | ||
129 | + def find_app | ||
130 | + @app = App.find(params[:app_id]) | ||
141 | 131 | ||
142 | -protected | ||
143 | - | ||
144 | - | ||
145 | - def find_app | ||
146 | - @app = App.find(params[:app_id]) | ||
147 | - | ||
148 | - # Mongoid Bug: could not chain: current_user.apps.find_by_id! | ||
149 | - # apparently finding by 'watchers.email' and 'id' is broken | ||
150 | - raise(Mongoid::Errors::DocumentNotFound.new(App,@app.id)) unless current_user.admin? || current_user.watching?(@app) | ||
151 | - end | ||
152 | - | ||
153 | - | ||
154 | - def find_problem | ||
155 | - @problem = @app.problems.find(params[:id]) | ||
156 | - | ||
157 | - # Deal with bug in mogoid where find is returning an Enumberable obj | ||
158 | - @problem = @problem.first if @problem.respond_to?(:first) | ||
159 | - end | ||
160 | - | ||
161 | - | ||
162 | - def set_tracker_params | ||
163 | - IssueTracker.default_url_options[:host] = request.host | ||
164 | - IssueTracker.default_url_options[:port] = request.port | ||
165 | - IssueTracker.default_url_options[:protocol] = request.scheme | ||
166 | - end | 132 | + # Mongoid Bug: could not chain: current_user.apps.find_by_id! |
133 | + # apparently finding by 'watchers.email' and 'id' is broken | ||
134 | + raise(Mongoid::Errors::DocumentNotFound.new(App,@app.id)) unless current_user.admin? || current_user.watching?(@app) | ||
135 | + end | ||
167 | 136 | ||
137 | + def find_problem | ||
138 | + @problem = @app.problems.find(params[:id]) | ||
168 | 139 | ||
169 | - def find_selected_problems | ||
170 | - err_ids = (params[:problems] || []).compact | ||
171 | - if err_ids.empty? | ||
172 | - flash[:notice] = "You have not selected any errors" | ||
173 | - redirect_to :back | ||
174 | - else | ||
175 | - @selected_problems = Array(Problem.find(err_ids)) | 140 | + # Deal with bug in mogoid where find is returning an Enumberable obj |
141 | + @problem = @problem.first if @problem.respond_to?(:first) | ||
176 | end | 142 | end |
177 | - end | ||
178 | 143 | ||
144 | + def set_tracker_params | ||
145 | + IssueTracker.default_url_options[:host] = request.host | ||
146 | + IssueTracker.default_url_options[:port] = request.port | ||
147 | + IssueTracker.default_url_options[:protocol] = request.scheme | ||
148 | + end | ||
179 | 149 | ||
150 | + def find_selected_problems | ||
151 | + err_ids = (params[:problems] || []).compact | ||
152 | + if err_ids.empty? | ||
153 | + flash[:notice] = "You have not selected any errors" | ||
154 | + redirect_to :back | ||
155 | + else | ||
156 | + @selected_problems = Array(Problem.find(err_ids)) | ||
157 | + end | ||
158 | + end | ||
180 | end | 159 | end |
181 | 160 |