From dc0586045f9c3d520fdea57fb60da2cb3a329554 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Sun, 16 Sep 2012 03:24:54 -0700 Subject: [PATCH] Created auto-download ability --- app/controllers/door_logs_controller.rb | 18 ++++++++++++++---- app/views/door_logs/auto_download.html.erb | 6 ++++++ config/routes.rb | 3 ++- 3 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 app/views/door_logs/auto_download.html.erb diff --git a/app/controllers/door_logs_controller.rb b/app/controllers/door_logs_controller.rb index 5d1e90d..2eb1e46 100644 --- a/app/controllers/door_logs_controller.rb +++ b/app/controllers/door_logs_controller.rb @@ -1,6 +1,6 @@ class DoorLogsController < ApplicationController - authorize_resource - before_filter :authenticate_user! + authorize_resource :except => :auto_download + before_filter :authenticate_user!, :except => :auto_download # GET /door_logs # GET /door_logs.json @@ -13,8 +13,7 @@ class DoorLogsController < ApplicationController end end - # GET /door_logs/1 - # GET /door_logs/1.json + # GET /door_logs/download def download @results = DoorLog.download_from_door @@ -24,4 +23,15 @@ class DoorLogsController < ApplicationController end end + # GET /door_logs/auto_download + def auto_download + @results = DoorLog.download_from_door + + respond_to do |format| + format.html # show.html.erb + format.json { render :json => @results } + end + end + + end diff --git a/app/views/door_logs/auto_download.html.erb b/app/views/door_logs/auto_download.html.erb new file mode 100644 index 0000000..e1af088 --- /dev/null +++ b/app/views/door_logs/auto_download.html.erb @@ -0,0 +1,6 @@ + +

+ Download results: + <%= !@results.nil? %> +

+ diff --git a/config/routes.rb b/config/routes.rb index 75af558..aaa503d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,8 +6,9 @@ Dooraccess::Application.routes.draw do resources :users match 'users/:id/upload' => 'users#upload', :as => :upload + match 'door_logs' => 'door_logs#index', :as => :door_logs match 'door_logs/download' => 'door_logs#download', :as => :download - resources :door_logs + match 'door_logs/auto_download' => 'door_logs#auto_download', :as => :auto_download root :to => "home#index"