adds filters to admin/organizations
This commit is contained in:
@@ -1,19 +1,32 @@
|
||||
class Admin::OrganizationsController < Admin::BaseController
|
||||
before_filter :set_valid_filters
|
||||
before_filter :parse_filter
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@organizations = @organizations.send(@filter)
|
||||
@organizations = @organizations.includes(:user).order(:name, 'users.email')
|
||||
end
|
||||
|
||||
def verify
|
||||
@organization.verify
|
||||
redirect_to action: :index
|
||||
redirect_to action: :index, filter: @filter
|
||||
end
|
||||
|
||||
def reject
|
||||
@organization.reject
|
||||
redirect_to action: :index
|
||||
redirect_to action: :index, filter: @filter
|
||||
end
|
||||
|
||||
private
|
||||
def set_valid_filters
|
||||
@valid_filters = %w{all pending verified rejected}
|
||||
end
|
||||
|
||||
def parse_filter
|
||||
@filter = params[:filter]
|
||||
@filter = 'all' unless @valid_filters.include?(@filter)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user