Improved report stuff.
This commit is contained in:
parent
46f68c5823
commit
3eec39c5df
|
@ -26,9 +26,7 @@ doc/rdocs
|
||||||
/vendor
|
/vendor
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
public/reports/*
|
/public/reports
|
||||||
!public/reports/.keep
|
/reports
|
||||||
public/uploads/*
|
|
||||||
!public/uploads/.keep
|
|
||||||
|
|
||||||
storage
|
storage
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
class ReportsController < ApplicationController
|
class ReportsController < ApplicationController
|
||||||
@@report_dir = Rails.root.join("public", "reports")
|
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if logged_in_as_student
|
if logged_in_as_student
|
||||||
user = current_user
|
user = current_user
|
||||||
filename = user.id.to_s + ".pdf"
|
filename = user.id.to_s + ".pdf"
|
||||||
report = GradeReport.new(user, Grade.where(:student => user))
|
report = GradeReport.new(user, Grade.where(:student => user))
|
||||||
report.render_file @@report_dir.join(filename)
|
FileUtils.mkdir_p(Rails.configuration.report_dir) unless File.directory?(Rails.configuration.report_dir)
|
||||||
|
report.render_file Rails.configuration.report_dir.join(filename)
|
||||||
|
|
||||||
redirect_to action: 'show', filename: filename
|
redirect_to action: 'show', filename: filename
|
||||||
else
|
else
|
||||||
|
|
|
@ -15,5 +15,6 @@ module DVGM
|
||||||
# Application configuration can go into files in config/initializers
|
# Application configuration can go into files in config/initializers
|
||||||
# -- all .rb files in that directory are automatically loaded after loading
|
# -- all .rb files in that directory are automatically loaded after loading
|
||||||
# the framework and any gems in your application.
|
# the framework and any gems in your application.
|
||||||
|
config.report_dir = Rails.root.join("public", "reports")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
namespace :db do
|
namespace :db do
|
||||||
desc "Populate database with default data"
|
desc "Populate database with default data"
|
||||||
def generate_report(user)
|
def generate_report(user)
|
||||||
report_dir = Rails.root.join("public", "reports")
|
FileUtils.mkdir_p(Rails.configuration.report_dir) unless File.directory?(Rails.configuration.report_dir)
|
||||||
filename = user.id.to_s + ".pdf"
|
filename = user.id.to_s + ".pdf"
|
||||||
report = GradeReport.new(user, Grade.where(:student => user))
|
report = GradeReport.new(user, Grade.where(:student => user))
|
||||||
report.render_file report_dir.join(filename)
|
report.render_file Rails.configuration.report_dir.join(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
task :populate => :environment do
|
task :populate => :environment do
|
||||||
|
|
Loading…
Reference in New Issue