Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix levels controller sorting #1193

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions app/controllers/event/levels_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ class Event::LevelsController < SimpleCrudController
self.permitted_attrs = [:label, :code, :difficulty, :description]

self.sort_mappings = {
label: "event_level_translations.label"
label: {
joins: [:translations],
order: ["event_level_translations.label"]
}
}

def self.model_class
Event::Level
end

private

def list_entries
super.list
end
end
18 changes: 18 additions & 0 deletions app/controllers/sac_cas/groups/self_inscription_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# Copyright (c) 2023, Schweizer Alpen-Club. This file is part of
# hitobito_sac_cas and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_sac_cas.

module SacCas::Groups::SelfInscriptionController
extend ActiveSupport::Concern

def create
if person.years < 6
redirect_to group_self_inscription_path(group), alert: I18n.t("groups.self_inscription.must_be_six_years_old")
else
super
end
end
end
3 changes: 1 addition & 2 deletions app/views/event/levels/_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
- # https://github.com/hitobito/hitobito_sac_cas.

= table(entries, class: 'table table-striped table-hover') do |t|
- t.attr(:label)
- t.sortable_attrs(:code, :difficulty, :updated_at)
- t.sortable_attrs(:label, :code, :difficulty, :updated_at)
- add_table_actions(t)
Loading