dev_sync_trustie
parent
a9c69f204e
commit
03117b8b5a
@ -0,0 +1,39 @@
|
||||
class Admins::CompetitionNavSettingService < ApplicationService
|
||||
attr_reader :competition, :params
|
||||
|
||||
def initialize(competition, params)
|
||||
@params = params
|
||||
@competition = competition
|
||||
end
|
||||
|
||||
def call
|
||||
ActiveRecord::Base.transaction do
|
||||
competition.name = strip params[:name]
|
||||
competition.sub_title = strip params[:sub_title]
|
||||
competition.start_time = params[:start_time]
|
||||
competition.end_time = params[:end_time]
|
||||
competition.mode = params[:mode]
|
||||
competition.identifier = strip params[:identifier]
|
||||
competition.bonus = params[:bonus]
|
||||
competition.awards_count = params[:awards_count]
|
||||
competition.description = strip params[:description]
|
||||
|
||||
competition.save!
|
||||
|
||||
if competition.mode == 1 || competition.mode == 4
|
||||
competition.competition_mode_setting.destroy
|
||||
else
|
||||
setting = competition.competition_mode_setting || CompetitionModeSetting.create!(competition_id: competition.id)
|
||||
if competition.mode == 2
|
||||
setting.course_id = params[:course_id]
|
||||
elsif competition.mode == 3
|
||||
setting.start_time = params[:teach_start_time]
|
||||
setting.end_time = params[:teach_end_time]
|
||||
end
|
||||
setting.save!
|
||||
end
|
||||
|
||||
competition
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,28 @@
|
||||
class MigrateCompetitionModuleType < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :competition_modules, :module_type, :string
|
||||
|
||||
Competition.all.each do |competition|
|
||||
competition.competition_modules.each do |com_module|
|
||||
mod_type = ""
|
||||
case com_module.name
|
||||
when '首页'
|
||||
mod_type = "home"
|
||||
when '报名'
|
||||
mod_type = "enroll"
|
||||
when '通知公告'
|
||||
mod_type = "inform"
|
||||
when '参赛手册'
|
||||
mod_type = "manual"
|
||||
when '排行榜'
|
||||
mod_type = "chart"
|
||||
when '资料下载 '
|
||||
mod_type = "resource"
|
||||
else
|
||||
mod_type = "md"
|
||||
end
|
||||
com_module.update_attributes!(module_type: mod_type)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in new issue