From 762941e12ef98264060e60587d9413e509d23e92 Mon Sep 17 00:00:00 2001 From: Felix Eckhofer <felix@eckhofer.com> Date: Mon, 23 Dec 2024 21:44:40 +0100 Subject: [PATCH] Allow stages to be sorted --- app/jobs/pretalx/import_job.rb | 3 ++- app/views/conferences/show.html.erb | 5 ++++- db/migrate/20241223202350_add_weight_to_stages.rb | 5 +++++ db/schema.rb | 3 ++- 4 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20241223202350_add_weight_to_stages.rb diff --git a/app/jobs/pretalx/import_job.rb b/app/jobs/pretalx/import_job.rb index 36d817b..8355061 100644 --- a/app/jobs/pretalx/import_job.rb +++ b/app/jobs/pretalx/import_job.rb @@ -29,7 +29,8 @@ module Pretalx # This is where canceled sessions are moved to, so we can still easily access them canceled_stage = Stage.find_or_initialize_by(conference:, ref_id: 'c3lingo_canceled').tap do |stage_| stage_.name = 'Canceled talk' - stage_.description = 'A dummy stage where talks move to when the disappear from the Fahrplan' + stage_.description = 'A dummy stage where talks move to when they disappear from the Fahrplan' + stage_.weight = 1000 # Sort it all the way to the right stage_.save! end diff --git a/app/views/conferences/show.html.erb b/app/views/conferences/show.html.erb index 5daedf9..6b1d442 100644 --- a/app/views/conferences/show.html.erb +++ b/app/views/conferences/show.html.erb @@ -126,7 +126,10 @@ current_time = Time.zone.now.in_time_zone(@conference.time_zone) <div class="stages"> - <% @sessions_by_date_and_stage[date].each do |stage, sessions| %> + <% + @sessions_by_date_and_stage[date].keys.sort_by(&:weight).each do |stage| + sessions = @sessions_by_date_and_stage[date][stage] + %> <div class="stage"> <h4 class="sticky top-0 bg-white bg-opacity-70 w-full z-30"><%= stage.name %></h4> <div class="stage-sessions"> diff --git a/db/migrate/20241223202350_add_weight_to_stages.rb b/db/migrate/20241223202350_add_weight_to_stages.rb new file mode 100644 index 0000000..814d8aa --- /dev/null +++ b/db/migrate/20241223202350_add_weight_to_stages.rb @@ -0,0 +1,5 @@ +class AddWeightToStages < ActiveRecord::Migration[7.1] + def change + add_column :stages, :weight, :integer, null: false, default: 50 + end +end diff --git a/db/schema.rb b/db/schema.rb index 2347d52..42fb0d5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2024_12_23_004818) do +ActiveRecord::Schema[7.1].define(version: 2024_12_23_202350) do create_table "assignments", force: :cascade do |t| t.integer "user_id", null: false t.integer "session_id", null: false @@ -265,6 +265,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_12_23_004818) do t.datetime "created_at", null: false t.datetime "updated_at", null: false t.string "ref_id" + t.integer "weight", default: 50, null: false t.index ["conference_id"], name: "index_stages_on_conference_id" t.index ["ref_id", "conference_id"], name: "index_stages_on_ref_id_and_conference_id", unique: true end -- GitLab