summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-04-11 10:51:28 +0200
committerPeter Kozak <spag@golwen.net>2013-04-11 10:51:28 +0200
commit78ea4bcd397a4d8f39ad3c08066fe918a8fc89ad (patch)
treea22d63d7fcaa2c2c32d2905424777a1ff1a8a21d /app/controllers
parent145d774adece71282020603b699ab684537cc1b3 (diff)
file uploader
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/generic_files_controller.rb64
1 files changed, 64 insertions, 0 deletions
diff --git a/app/controllers/generic_files_controller.rb b/app/controllers/generic_files_controller.rb
new file mode 100644
index 0000000..b7dc453
--- /dev/null
+++ b/app/controllers/generic_files_controller.rb
@@ -0,0 +1,64 @@
+class GenericFilesController < ApplicationController
+
+ load_resource :sip_account
+ load_resource :conference
+ load_resource :hunt_group
+ load_resource :automatic_call_distributor
+ load_resource :user
+ load_resource :tenant
+ load_resource :generic_file
+
+ load_and_authorize_resource :generic_file, :through => [:sip_account, :conference, :hunt_group, :automatic_call_distributor, :user, :tenant]
+
+ before_filter :set_and_authorize_parent
+
+ def index
+ @generic_files = @parent.generic_files
+ end
+
+ def show
+
+ end
+
+ def new
+ @generic_file = @parent.generic_files.build()
+ end
+
+ def create
+ @generic_file = @parent.generic_files.new(params[:generic_file])
+ if @generic_file.save
+ m = method( :"#{@parent.class.name.underscore}_generic_files_url" )
+ redirect_to m.( @parent ), :notice => t('generic_files.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @generic_file = GenericFile.find(params[:id])
+ end
+
+ def update
+ @generic_file = GenericFile.find(params[:id])
+ if @generic_file.update_attributes(params[:generic_file])
+ m = method( :"#{@parent.class.name.underscore}_generic_files_url" )
+ redirect_to m.( @parent ), :notice => t('generic_files.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @generic_file = GenericFile.find(params[:id])
+ @generic_file.destroy
+ m = method( :"#{@parent.class.name.underscore}_generic_files_url" )
+ redirect_to m.( @parent ), :notice => t('generic_files.controller.successfuly_destroyed')
+ end
+
+ private
+ def set_and_authorize_parent
+ @parent = @sip_account || @conference || @hunt_group || @automatic_call_distributor || @user || @tenant
+
+ authorize! :read, @parent
+ end
+end