From fc93de9161bf283a5cb09945f95b1c58673a0d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20J=C3=A4ggi?= Date: Wed, 30 Oct 2024 23:22:29 +0100 Subject: [PATCH 1/2] Fix levels controller sorting --- app/controllers/event/levels_controller.rb | 11 ++++------- .../groups/self_inscription_controller.rb | 18 ++++++++++++++++++ app/views/event/levels/_list.html.haml | 3 +-- 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 app/controllers/sac_cas/groups/self_inscription_controller.rb diff --git a/app/controllers/event/levels_controller.rb b/app/controllers/event/levels_controller.rb index c1db2b15a..7ac303300 100644 --- a/app/controllers/event/levels_controller.rb +++ b/app/controllers/event/levels_controller.rb @@ -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 diff --git a/app/controllers/sac_cas/groups/self_inscription_controller.rb b/app/controllers/sac_cas/groups/self_inscription_controller.rb new file mode 100644 index 000000000..0367210ee --- /dev/null +++ b/app/controllers/sac_cas/groups/self_inscription_controller.rb @@ -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 diff --git a/app/views/event/levels/_list.html.haml b/app/views/event/levels/_list.html.haml index c64df3838..8a260b8cf 100644 --- a/app/views/event/levels/_list.html.haml +++ b/app/views/event/levels/_list.html.haml @@ -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) From 1a54aecbc766e6f2ab87eec2c9e01f058a2a7924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20J=C3=A4ggi?= Date: Thu, 31 Oct 2024 15:32:06 +0100 Subject: [PATCH 2/2] Fix rubocop --- app/controllers/event/levels_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/event/levels_controller.rb b/app/controllers/event/levels_controller.rb index 7ac303300..a95bea117 100644 --- a/app/controllers/event/levels_controller.rb +++ b/app/controllers/event/levels_controller.rb @@ -12,7 +12,7 @@ class Event::LevelsController < SimpleCrudController label: { joins: [:translations], order: ["event_level_translations.label"] - }, + } } def self.model_class