Issues tags: refactoring

This commit is contained in:
randx 2012-06-27 23:13:44 +03:00
parent 50fdb2e7df
commit 5f356d6928
3 changed files with 39 additions and 20 deletions

View file

@ -3,6 +3,8 @@ class IssuesController < ApplicationController
before_filter :project
before_filter :module_enabled
before_filter :issue, :only => [:edit, :update, :destroy, :show]
helper_method :issues_filter
layout "project"
# Authorize
@ -130,10 +132,10 @@ class IssuesController < ApplicationController
end
def issues_filtered
@issues = case params[:f].to_i
when 1 then @project.issues
when 2 then @project.issues.closed
when 3 then @project.issues.opened.assigned(current_user)
@issues = case params[:f]
when issues_filter[:all] then @project.issues
when issues_filter[:closed] then @project.issues.closed
when issues_filter[:to_me] then @project.issues.opened.assigned(current_user)
else @project.issues.opened
end
@ -143,4 +145,13 @@ class IssuesController < ApplicationController
@issues = @issues.includes(:author, :project).order("updated_at")
@issues
end
def issues_filter
{
all: "1",
closed: "2",
to_me: "3",
open: "0"
}
end
end