[Fix #196] Dossier: add Attestation

This commit is contained in:
Simon Lehericey 2017-06-02 14:30:26 +02:00
parent c0facbf679
commit b443b5cefd
5 changed files with 48 additions and 1 deletions

View file

@ -0,0 +1,5 @@
class Attestation < ApplicationRecord
belongs_to :dossier
mount_uploader :pdf, AttestationUploader
end

View file

@ -23,6 +23,7 @@ class Dossier < ActiveRecord::Base
has_one :etablissement, dependent: :destroy
has_one :entreprise, dependent: :destroy
has_one :individual, dependent: :destroy
has_one :attestation
has_many :cerfa, dependent: :destroy
has_many :pieces_justificatives, dependent: :destroy

View file

@ -0,0 +1,20 @@
class AttestationUploader < BaseUploader
def root
File.join(Rails.root, 'public')
end
# Choose what kind of storage to use for this uploader:
if Features.remote_storage
storage :fog
else
storage :file
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
unless Features.remote_storage
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
end

View file

@ -0,0 +1,11 @@
class CreateAttestations < ActiveRecord::Migration[5.0]
def change
create_table :attestations do |t|
t.string :pdf
t.string :title
t.references :dossier, foreign_key: true, null: false
t.timestamps
end
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170524140630) do
ActiveRecord::Schema.define(version: 20170601123221) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -84,6 +84,15 @@ ActiveRecord::Schema.define(version: 20170524140630) do
t.index ["procedure_id"], name: "index_attestation_templates_on_procedure_id", unique: true, using: :btree
end
create_table "attestations", force: :cascade do |t|
t.string "pdf"
t.string "title"
t.integer "dossier_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["dossier_id"], name: "index_attestations_on_dossier_id", using: :btree
end
create_table "avis", force: :cascade do |t|
t.string "email"
t.text "introduction"
@ -463,6 +472,7 @@ ActiveRecord::Schema.define(version: 20170524140630) do
end
add_foreign_key "attestation_templates", "procedures"
add_foreign_key "attestations", "dossiers"
add_foreign_key "avis", "gestionnaires", column: "claimant_id"
add_foreign_key "cerfas", "dossiers"
add_foreign_key "closed_mails", "procedures"