blob: 3815f52e1c335b45dff0f198411a65b7d1d25011 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
class CdrsController < ApplicationController
load_and_authorize_resource :tenant
before_filter :set_and_authorize_parent
before_filter :spread_breadcrumbs
helper_method :sort_column, :sort_descending
def index
@cdrs = Cdr.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate(
:page => params[:page],
:per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE')
)
end
def show
end
def destroy
@cdr.destroy
m = method( :"#{@parent.class.name.underscore}_cdrs_url" )
redirect_to m.(@parent), :notice => t('cdrs.controller.successfuly_destroyed')
end
private
def set_and_authorize_parent
@parent = @user || @tenant
authorize! :read, @parent
end
def spread_breadcrumbs
add_breadcrumb t("cdrs.index.page_title"), tenant_cdrs_path(@tenant)
end
def sort_descending
params[:desc].to_s == 'true'
end
def sort_column
Cdr.column_names.include?(params[:sort]) ? params[:sort] : 'start_stamp'
end
end
|