Files
codeocean/app/models/contributor.rb
Sebastian Serth dab8f777b3 Extract Contributor concern as abstract class
During documentation of the pair programming feature, we noticed that the Contributor should be an abstract class, which is parent for the User and the ProgrammingGroup. With this commit, we perform these changes.
2024-04-02 16:56:49 +02:00

49 lines
872 B
Ruby

# frozen_string_literal: true
class Contributor < ApplicationRecord
self.abstract_class = true
has_many :anomaly_notifications, as: :contributor, dependent: :destroy
has_many :user_exercise_interventions, as: :contributor
has_many :runners, as: :contributor, dependent: :destroy
has_many :submissions, as: :contributor
def learner?
raise NotImplementedError
end
def teacher?
raise NotImplementedError
end
def admin?
raise NotImplementedError
end
def internal_user?
is_a?(InternalUser)
end
def external_user?
is_a?(ExternalUser)
end
def programming_group?
is_a?(ProgrammingGroup)
end
def to_s
displayname
end
def to_page_context
{
id:,
type: self.class.name,
consumer: try(:consumer)&.name, # Only a user is associated with a consumer.
displayname:,
}
end
end