diff --git a/app/views/admins/competition_settings/index.html.erb b/app/views/admins/competition_settings/index.html.erb index 8f483b219..c8a90a9bc 100644 --- a/app/views/admins/competition_settings/index.html.erb +++ b/app/views/admins/competition_settings/index.html.erb @@ -221,11 +221,12 @@
  
-
- 报名要求 +
+ 报名模式和要求:
-
- <%= javascript_void_link '+', class: 'btn btn-primary waves-effect waves-light btn-xs setBtn_s addRequireBtn' %> +
+ <%= radio_button_tag(:team_mode, 0, !@competition.team_mode, class: 'form-radio-input') %> +
@@ -242,10 +243,8 @@
- + <% identity_options = [['全部', 'all'], ['教师', 'teacher'], ['学生', 'student'], ['专业人士', 'professional']] %> + <%= select_tag("competition_staffs[][category]", options_for_select(identity_options, staff.category), multiple: true, class: 'form-control') %>
+ <%= javascript_void_link '+', class: 'btn btn-primary waves-effect waves-light btn-xs setBtn_s addRequireBtn' %> diff --git a/db/migrate/20191106093140_add_team_mode_to_competitions.rb b/db/migrate/20191106093140_add_team_mode_to_competitions.rb new file mode 100644 index 000000000..c38fe4e05 --- /dev/null +++ b/db/migrate/20191106093140_add_team_mode_to_competitions.rb @@ -0,0 +1,6 @@ +class AddTeamModeToCompetitions < ActiveRecord::Migration[5.2] + def change + add_column :competitions, :team_mode, :boolean, default: 0 + add_column :competition_staffs, :category_name, :string + end +end diff --git a/db/migrate/20191106093832_migrate_competition_team_mode.rb b/db/migrate/20191106093832_migrate_competition_team_mode.rb new file mode 100644 index 000000000..860f13c35 --- /dev/null +++ b/db/migrate/20191106093832_migrate_competition_team_mode.rb @@ -0,0 +1,7 @@ +class MigrateCompetitionTeamMode < ActiveRecord::Migration[5.2] + def change + Competition.all.each do |competition| + competition.update_attributes!(team_mode: 1) unless (competition.competition_staffs.sum(:maximum).to_i == 1 || (competition.competition_staffs.nil? && competition.max_num == 1)) + end + end +end