Browse Source

Improved report stuff.

master
Michael Herzberg 1 year ago
parent
commit
3eec39c5df
6 changed files with 7 additions and 9 deletions
  1. +2
    -4
      .gitignore
  2. +2
    -3
      app/controllers/reports_controller.rb
  3. +1
    -0
      config/application.rb
  4. +2
    -2
      lib/tasks/sample_data.rake
  5. +0
    -0
      public/reports/.keep
  6. +0
    -0
      public/uploads/.keep

+ 2
- 4
.gitignore View File

@@ -26,9 +26,7 @@ doc/rdocs
/vendor
*.swp

public/reports/*
!public/reports/.keep
public/uploads/*
!public/uploads/.keep
/public/reports
/reports

storage

+ 2
- 3
app/controllers/reports_controller.rb View File

@@ -1,12 +1,11 @@
class ReportsController < ApplicationController
@@report_dir = Rails.root.join("public", "reports")

def create
if logged_in_as_student
user = current_user
filename = user.id.to_s + ".pdf"
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
else


+ 1
- 0
config/application.rb View File

@@ -15,5 +15,6 @@ module DVGM
# Application configuration can go into files in config/initializers
# -- all .rb files in that directory are automatically loaded after loading
# the framework and any gems in your application.
config.report_dir = Rails.root.join("public", "reports")
end
end

+ 2
- 2
lib/tasks/sample_data.rake View File

@@ -1,10 +1,10 @@
namespace :db do
desc "Populate database with default data"
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"
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

task :populate => :environment do


+ 0
- 0
public/reports/.keep View File


+ 0
- 0
public/uploads/.keep View File


Loading…
Cancel
Save