|
|
|
@ -11,6 +11,9 @@ class Laboratory < ApplicationRecord
|
|
|
|
|
has_many :laboratory_shixuns, dependent: :destroy
|
|
|
|
|
has_many :laboratory_subjects, dependent: :destroy
|
|
|
|
|
|
|
|
|
|
has_many :courses, dependent: :destroy
|
|
|
|
|
has_many :competitions, dependent: :destroy
|
|
|
|
|
|
|
|
|
|
validates :identifier, uniqueness: { case_sensitive: false }, allow_nil: true
|
|
|
|
|
|
|
|
|
|
delegate :name, :navbar, :footer, :login_logo_url, :nav_logo_url, :tab_logo_url, :default_navbar, to: :laboratory_setting
|
|
|
|
@ -47,14 +50,6 @@ class Laboratory < ApplicationRecord
|
|
|
|
|
main_site? ? Subject.all : Subject.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: id })
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def courses
|
|
|
|
|
main_site? ? Course.all : Course.where(laboratory_id: self.id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def competitions
|
|
|
|
|
main_site? ? Competition.all : Competition.where(laboratory_id: self.id)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def shixun_repertoires
|
|
|
|
|
where_sql = ShixunTagRepertoire.where("shixun_tag_repertoires.tag_repertoire_id = tag_repertoires.id")
|
|
|
|
|
|
|
|
|
|