mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
init StatisticProfileTraining
This commit is contained in:
parent
6f87873b2c
commit
f0c5b0eb09
19
app/models/statistic_profile_training.rb
Normal file
19
app/models/statistic_profile_training.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Stores trainings validated per user (non validated trainings are only recorded in reservations)
|
||||
class StatisticProfileTraining < ActiveRecord::Base
|
||||
include NotifyWith::NotificationAttachedObject
|
||||
|
||||
belongs_to :statistic_profile
|
||||
belongs_to :training
|
||||
|
||||
after_commit :notify_user_training_valid, on: :create
|
||||
|
||||
private
|
||||
|
||||
def notify_user_training_valid
|
||||
NotificationCenter.call type: 'notify_user_training_valid',
|
||||
receiver: statistic_profile.user,
|
||||
attached_object: self
|
||||
end
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
class CreateStatisticProfileTrainings < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :statistic_profile_trainings do |t|
|
||||
t.belongs_to :statistic_profile, index: true, foreign_key: true
|
||||
t.belongs_to :training, index: true, foreign_key: true
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
9
test/fixtures/statistic_profile_trainings.yml
vendored
Normal file
9
test/fixtures/statistic_profile_trainings.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
statistic_profile_id:
|
||||
training_id:
|
||||
|
||||
two:
|
||||
statistic_profile_id:
|
||||
training_id:
|
Loading…
x
Reference in New Issue
Block a user