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 | 5 | before_filter :find_problem, :except => [:index, :all, :destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several] |
| 6 | 6 | before_filter :find_selected_problems, :only => [:destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several] |
| 7 | 7 | |
| 8 | - | |
| 9 | - | |
| 10 | 8 | def index |
| 11 | 9 | app_scope = current_user.admin? ? App.all : current_user.apps |
| 12 | - | |
| 10 | + | |
| 13 | 11 | @sort = params[:sort] |
| 14 | 12 | @order = params[:order] |
| 15 | 13 | @sort = "app" unless %w{message last_notice_at last_deploy_at count}.member?(@sort) |
| 16 | 14 | @order = "asc" unless (@order == "desc") |
| 17 | - | |
| 15 | + | |
| 18 | 16 | @problems = Problem.for_apps(app_scope).in_env(params[:environment]).unresolved.ordered_by(@sort, @order) |
| 19 | 17 | @selected_problems = params[:problems] || [] |
| 20 | 18 | respond_to do |format| |
| ... | ... | @@ -25,14 +23,12 @@ class ErrsController < ApplicationController |
| 25 | 23 | end |
| 26 | 24 | end |
| 27 | 25 | |
| 28 | - | |
| 29 | 26 | def all |
| 30 | 27 | app_scope = current_user.admin? ? App.all : current_user.apps |
| 31 | 28 | @problems = Problem.for_apps(app_scope).ordered.paginate(:page => params[:page], :per_page => current_user.per_page) |
| 32 | 29 | @selected_problems = params[:problems] || [] |
| 33 | 30 | end |
| 34 | 31 | |
| 35 | - | |
| 36 | 32 | def show |
| 37 | 33 | page = (params[:notice] || @problem.notices_count) |
| 38 | 34 | page = 1 if page.to_i.zero? |
| ... | ... | @@ -41,7 +37,6 @@ class ErrsController < ApplicationController |
| 41 | 37 | @comment = Comment.new |
| 42 | 38 | end |
| 43 | 39 | |
| 44 | - | |
| 45 | 40 | def create_issue |
| 46 | 41 | set_tracker_params |
| 47 | 42 | |
| ... | ... | @@ -57,13 +52,11 @@ class ErrsController < ApplicationController |
| 57 | 52 | redirect_to app_err_path(@app, @problem) |
| 58 | 53 | end |
| 59 | 54 | |
| 60 | - | |
| 61 | 55 | def unlink_issue |
| 62 | 56 | @problem.update_attribute :issue_link, nil |
| 63 | 57 | redirect_to app_err_path(@app, @problem) |
| 64 | 58 | end |
| 65 | 59 | |
| 66 | - | |
| 67 | 60 | def resolve |
| 68 | 61 | # Deal with bug in mongoid where find is returning an Enumberable obj |
| 69 | 62 | @problem = @problem.first if @problem.respond_to?(:first) |
| ... | ... | @@ -75,7 +68,6 @@ class ErrsController < ApplicationController |
| 75 | 68 | redirect_to app_path(@app) |
| 76 | 69 | end |
| 77 | 70 | |
| 78 | - | |
| 79 | 71 | def create_comment |
| 80 | 72 | @comment = Comment.new(params[:comment].merge(:user_id => current_user.id)) |
| 81 | 73 | if @comment.valid? |
| ... | ... | @@ -88,7 +80,6 @@ class ErrsController < ApplicationController |
| 88 | 80 | redirect_to app_err_path(@app, @problem) |
| 89 | 81 | end |
| 90 | 82 | |
| 91 | - | |
| 92 | 83 | def destroy_comment |
| 93 | 84 | @comment = Comment.find(params[:comment_id]) |
| 94 | 85 | if @comment.destroy |
| ... | ... | @@ -106,14 +97,12 @@ class ErrsController < ApplicationController |
| 106 | 97 | redirect_to :back |
| 107 | 98 | end |
| 108 | 99 | |
| 109 | - | |
| 110 | 100 | def unresolve_several |
| 111 | 101 | @selected_problems.each(&:unresolve!) |
| 112 | 102 | flash[:success] = "#{pluralize(@selected_problems.count, 'err has', 'errs have')} been unresolved." |
| 113 | 103 | redirect_to :back |
| 114 | 104 | end |
| 115 | 105 | |
| 116 | - | |
| 117 | 106 | def merge_several |
| 118 | 107 | if @selected_problems.length < 2 |
| 119 | 108 | flash[:notice] = "You must select at least two errors to merge" |
| ... | ... | @@ -124,58 +113,48 @@ class ErrsController < ApplicationController |
| 124 | 113 | redirect_to :back |
| 125 | 114 | end |
| 126 | 115 | |
| 127 | - | |
| 128 | 116 | def unmerge_several |
| 129 | 117 | all = @selected_problems.map(&:unmerge!).flatten |
| 130 | 118 | flash[:success] = "#{pluralize(all.length, 'err has', 'errs have')} been unmerged." |
| 131 | 119 | redirect_to :back |
| 132 | 120 | end |
| 133 | 121 | |
| 134 | - | |
| 135 | 122 | def destroy_several |
| 136 | 123 | @selected_problems.each(&:destroy) |
| 137 | 124 | flash[:notice] = "#{pluralize(@selected_problems.count, 'err has', 'errs have')} been deleted." |
| 138 | 125 | redirect_to :back |
| 139 | 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 | 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 | 159 | end |
| 181 | 160 | ... | ... |