summaryrefslogtreecommitdiff
path: root/app/controllers/cdrs_controller.rb
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-06-22 10:25:31 +0200
committerPeter Kozak <spag@golwen.net>2013-06-22 10:25:31 +0200
commit130e77d4c9df2cca2425b63a443ea8745133d083 (patch)
tree4637509156e35ac172937d02e9639b6cde8b29a6 /app/controllers/cdrs_controller.rb
parent08ecc91d89a2b6a83daee4a1ffda5520e38e53c6 (diff)
cdrs added
Diffstat (limited to 'app/controllers/cdrs_controller.rb')
-rw-r--r--app/controllers/cdrs_controller.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/app/controllers/cdrs_controller.rb b/app/controllers/cdrs_controller.rb
new file mode 100644
index 0000000..3815f52
--- /dev/null
+++ b/app/controllers/cdrs_controller.rb
@@ -0,0 +1,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