|
|
|
class CompetitionModule < ApplicationRecord
|
|
|
|
default_scope { order('position ASC') }
|
|
|
|
|
|
|
|
belongs_to :competition
|
|
|
|
|
|
|
|
has_many :competition_module_md_contents, dependent: :destroy
|
|
|
|
|
|
|
|
def module_url
|
|
|
|
result_url = url.present? ? url : case module_type
|
|
|
|
when "chart"
|
|
|
|
"/competitions/#{competition.identifier}/charts.json"
|
|
|
|
when "enroll"
|
|
|
|
"/competitions/#{competition.identifier}/competition_teams.json"
|
|
|
|
else
|
|
|
|
"/competitions/#{competition.identifier}/competition_modules/#{id}.json"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|