Skip to content

Commit

Permalink
Introduce CommonInstructionModel
Browse files Browse the repository at this point in the history
1. These models are linked to one event
2. There is a user through event
  • Loading branch information
skelz0r committed Apr 10, 2024
1 parent a811806 commit b0f7476
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
15 changes: 15 additions & 0 deletions app/models/concerns/common_instruction_model.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module CommonInstructionModel
extend ActiveSupport::Concern

included do
belongs_to :authorization_request

has_one :event,
class_name: 'AuthorizationRequestEvent',
inverse_of: :entity,
dependent: :destroy

has_one :user,
through: :event
end
end
8 changes: 2 additions & 6 deletions app/models/denial_of_authorization.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
class DenialOfAuthorization < ApplicationRecord
validates :reason, presence: true
belongs_to :authorization_request
include CommonInstructionModel

has_many :events,
class_name: 'AuthorizationRequestEvent',
inverse_of: :entity,
dependent: :destroy
validates :reason, presence: true
end
8 changes: 2 additions & 6 deletions app/models/instructor_modification_request.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
class InstructorModificationRequest < ApplicationRecord
validates :reason, presence: true
belongs_to :authorization_request
include CommonInstructionModel

has_many :events,
class_name: 'AuthorizationRequestEvent',
inverse_of: :entity,
dependent: :destroy
validates :reason, presence: true
end
2 changes: 1 addition & 1 deletion app/models/revocation_of_authorization.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class RevocationOfAuthorization < ApplicationRecord
belongs_to :authorization_request
include CommonInstructionModel
end

0 comments on commit b0f7476

Please sign in to comment.