From 28a4c227f1ce72c3fac5d74dbda591b9ce47740d Mon Sep 17 00:00:00 2001 From: Nathan Broadbent Date: Mon, 26 Sep 2011 18:43:06 +0800 Subject: [PATCH] indentation --- app/controllers/errs_controller.rb | 75 +++++++++++++++++++++++++++------------------------------------------------ 1 file changed, 27 insertions(+), 48 deletions(-) diff --git a/app/controllers/errs_controller.rb b/app/controllers/errs_controller.rb index bbe5d3e..68f8016 100644 --- a/app/controllers/errs_controller.rb +++ b/app/controllers/errs_controller.rb @@ -5,16 +5,14 @@ class ErrsController < ApplicationController before_filter :find_problem, :except => [:index, :all, :destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several] before_filter :find_selected_problems, :only => [:destroy_several, :resolve_several, :unresolve_several, :merge_several, :unmerge_several] - - def index app_scope = current_user.admin? ? App.all : current_user.apps - + @sort = params[:sort] @order = params[:order] @sort = "app" unless %w{message last_notice_at last_deploy_at count}.member?(@sort) @order = "asc" unless (@order == "desc") - + @problems = Problem.for_apps(app_scope).in_env(params[:environment]).unresolved.ordered_by(@sort, @order) @selected_problems = params[:problems] || [] respond_to do |format| @@ -25,14 +23,12 @@ class ErrsController < ApplicationController end end - def all app_scope = current_user.admin? ? App.all : current_user.apps @problems = Problem.for_apps(app_scope).ordered.paginate(:page => params[:page], :per_page => current_user.per_page) @selected_problems = params[:problems] || [] end - def show page = (params[:notice] || @problem.notices_count) page = 1 if page.to_i.zero? @@ -41,7 +37,6 @@ class ErrsController < ApplicationController @comment = Comment.new end - def create_issue set_tracker_params @@ -57,13 +52,11 @@ class ErrsController < ApplicationController redirect_to app_err_path(@app, @problem) end - def unlink_issue @problem.update_attribute :issue_link, nil redirect_to app_err_path(@app, @problem) end - def resolve # Deal with bug in mongoid where find is returning an Enumberable obj @problem = @problem.first if @problem.respond_to?(:first) @@ -75,7 +68,6 @@ class ErrsController < ApplicationController redirect_to app_path(@app) end - def create_comment @comment = Comment.new(params[:comment].merge(:user_id => current_user.id)) if @comment.valid? @@ -88,7 +80,6 @@ class ErrsController < ApplicationController redirect_to app_err_path(@app, @problem) end - def destroy_comment @comment = Comment.find(params[:comment_id]) if @comment.destroy @@ -106,14 +97,12 @@ class ErrsController < ApplicationController redirect_to :back end - def unresolve_several @selected_problems.each(&:unresolve!) flash[:success] = "#{pluralize(@selected_problems.count, 'err has', 'errs have')} been unresolved." redirect_to :back end - def merge_several if @selected_problems.length < 2 flash[:notice] = "You must select at least two errors to merge" @@ -124,58 +113,48 @@ class ErrsController < ApplicationController redirect_to :back end - def unmerge_several all = @selected_problems.map(&:unmerge!).flatten flash[:success] = "#{pluralize(all.length, 'err has', 'errs have')} been unmerged." redirect_to :back end - def destroy_several @selected_problems.each(&:destroy) flash[:notice] = "#{pluralize(@selected_problems.count, 'err has', 'errs have')} been deleted." redirect_to :back end + protected + def find_app + @app = App.find(params[:app_id]) -protected - - - def find_app - @app = App.find(params[:app_id]) - - # Mongoid Bug: could not chain: current_user.apps.find_by_id! - # apparently finding by 'watchers.email' and 'id' is broken - raise(Mongoid::Errors::DocumentNotFound.new(App,@app.id)) unless current_user.admin? || current_user.watching?(@app) - end - - - def find_problem - @problem = @app.problems.find(params[:id]) - - # Deal with bug in mogoid where find is returning an Enumberable obj - @problem = @problem.first if @problem.respond_to?(:first) - end - - - def set_tracker_params - IssueTracker.default_url_options[:host] = request.host - IssueTracker.default_url_options[:port] = request.port - IssueTracker.default_url_options[:protocol] = request.scheme - end + # Mongoid Bug: could not chain: current_user.apps.find_by_id! + # apparently finding by 'watchers.email' and 'id' is broken + raise(Mongoid::Errors::DocumentNotFound.new(App,@app.id)) unless current_user.admin? || current_user.watching?(@app) + end + def find_problem + @problem = @app.problems.find(params[:id]) - def find_selected_problems - err_ids = (params[:problems] || []).compact - if err_ids.empty? - flash[:notice] = "You have not selected any errors" - redirect_to :back - else - @selected_problems = Array(Problem.find(err_ids)) + # Deal with bug in mogoid where find is returning an Enumberable obj + @problem = @problem.first if @problem.respond_to?(:first) end - end + def set_tracker_params + IssueTracker.default_url_options[:host] = request.host + IssueTracker.default_url_options[:port] = request.port + IssueTracker.default_url_options[:protocol] = request.scheme + end + def find_selected_problems + err_ids = (params[:problems] || []).compact + if err_ids.empty? + flash[:notice] = "You have not selected any errors" + redirect_to :back + else + @selected_problems = Array(Problem.find(err_ids)) + end + end end -- libgit2 0.21.2