allow reports to have parameters. refs #4315

Change-Id: I03e6a846f3d2dea38e662e4c784d218ed63499db
Reviewed-on: https://gerrit.instructure.com/3858
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Brian Whitmer <brian@instructure.com>
Reviewed-by: Zach Wily <zach@instructure.com>
This commit is contained in:
Cody Cutrer 2011-05-25 12:40:44 -06:00
parent bdbebfaec8
commit 326f249679
5 changed files with 18 additions and 1 deletions

View File

@ -380,7 +380,7 @@ class AccountsController < ApplicationController
def run_report
if authorized_action(@context, @current_user, :read_reports)
student_report = AccountReport.new(:user=>@current_user, :account=>@account, :report_type=>params[:report_type])
student_report = AccountReport.new(:user=>@current_user, :account=>@account, :report_type=>params[:report_type], :parameters=>params[:parameters])
student_report.workflow_state = :running
student_report.progress = 0
student_report.save

View File

@ -24,6 +24,8 @@ class AccountReport < ActiveRecord::Base
belongs_to :user
belongs_to :attachment
serialize :parameters
workflow do
state :created
state :running

View File

@ -390,6 +390,8 @@
description = details[:description]
description_partial = details[:description_partial]
description_partial = report + '_description' if description_partial == true
parameters_partial = details[:parameters_partial]
parameters_partial = report + '_parameters' if parameters_partial == true
last_run = @last_reports[report]
%>
<div id="<%= report %>" style="margin-bottom: 10px;">
@ -411,6 +413,9 @@
<form id="<%= report %>_form" class="run_report_form" action="<%= account_run_report_path %>">
<input type="hidden" name="report_type" value="<%= report %>" />
<span class="running_report_message" style="<%= hidden %>">The report is running. You'll receive an email when it is done.</span>
<div class="report_parameters">
<%= render :partial => parameters_partial if parameters_partial %>
</div>
<a href="#" id="run_<%= report %>" class="run_report_link">Run this report now</a><br/>
</form>
</div>

View File

@ -0,0 +1,9 @@
class AddParametersToAccountReports < ActiveRecord::Migration
def self.up
add_column :account_reports, :parameters, :text
end
def self.down
remove_column :account_reports, :parameters
end
end

View File

@ -120,6 +120,7 @@ $(document).ready(function() {
resetForm: true,
beforeSubmit: function(data) {
$(this).find('.run_report_link').hide();
$(this).find('.report_parameters').hide();
$(this).find('.running_report_message').show();
return true;
},