Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Gemfile.lock
# reports
spec/coverage
spec/reports
coverage/
brakeman-output.tabs
rubocop-results.xml
.tool-versions
Expand Down
40 changes: 40 additions & 0 deletions app/abilities/pbs/event_readables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

# Copyright (c) 2026, Pfadibewegung Schweiz. This file is part of
# hitobito_pbs 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_pbs.

module Pbs::EventReadables
extend ActiveSupport::Concern

def accessible_conditions
super.tap do |condition|
part_of_krisenteam_condition(condition)
end
end

def part_of_krisenteam_condition(condition)
cantons = krisenteam_cantons
condition.or("events.canton IN (?)", cantons) if cantons.present?
end

def krisenteam_cantons
user.roles
.select { |role| Pbs::EventAbility::CAMP_KRISENTEAM_ROLES.any? { |type| role.is_a?(type) } }
.map(&:group)
.uniq
.flat_map(&:cantons)
.uniq
end

def participating_condition(condition)
subquery = participations
.joins(:event)
.joins("INNER JOIN events AS descendants ON " \
"descendants.lft >= events.lft AND descendants.rgt <= events.rgt")
.select("descendants.id")

condition.or("events.id IN (#{subquery.to_sql})")
end
end
13 changes: 0 additions & 13 deletions app/controllers/pbs/event/lists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ module Pbs::Event::ListsController
extend ActiveSupport::Concern

included do
# required to allow api calls
protect_from_forgery with: :null_session, only: [:bsv_export]

skip_authorization_check only: :camps
skip_authorize_resource only: [:camps, :all_camps, :kantonalverband_camps,
:camps_in_canton, :camps_abroad]
alias_method_chain :render_bsv_export, :advanced
end

# simple redirect action acting as a generic entry point from the main navigation
Expand Down Expand Up @@ -67,15 +63,6 @@ def camps_abroad

private

def render_bsv_export_with_advanced(courses_for_bsv_export)
if params[:advanced]
send_data(Export::Tabular::Events::AdvancedBsvList.csv(courses_for_bsv_export),
type: :csv, filename: "advanced_bsv_export.csv")
else
render_bsv_export_without_advanced(courses_for_bsv_export)
end
end

def render_camp_list(camps)
respond_to do |format|
format.html { @camps = grouped(camps) }
Expand Down
24 changes: 24 additions & 0 deletions app/controllers/pbs/events/courses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2012-2015, Pfadibewegung Schweiz. This file is part of
# hitobito_pbs 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_pbs.

module Pbs::Events::CoursesController
extend ActiveSupport::Concern

prepended do
# required to allow api calls
protect_from_forgery with: :null_session, only: [:bsv_export]
end

private

def render_bsv_export(courses_for_bsv_export)
if params[:advanced]
send_data(Export::Tabular::Events::AdvancedBsvList.csv(courses_for_bsv_export),
type: :csv, filename: "advanced_bsv_export.csv")
else
super
end
end
end
38 changes: 0 additions & 38 deletions app/domain/pbs/event/filter.rb

This file was deleted.

16 changes: 16 additions & 0 deletions app/domain/pbs/events/filter/course_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2012-2018, Pfadibewegung Schweiz. This file is part of
# hitobito_pbs 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_pbs.

module Pbs::Events::Filter::CourseList
private

def base_scope
if params[:list_all_courses] == true
Event::Course.all
else
Event::Course.in_hierarchy(user)
end
end
end
26 changes: 26 additions & 0 deletions app/domain/pbs/events/filter/group_list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2012-2018, Pfadibewegung Schweiz. This file is part of
# hitobito_pbs 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_pbs.

module Pbs::Events::Filter::GroupList
private

def filtered_scope_with_selection
return super unless range == "canton"

super.where(canton: cantons)
end

def relevant_group_ids
return super unless range == "canton"

Group.select(:id)
end

def cantons
if group.respond_to?(:kantonalverband)
group.kantonalverband.cantons
end.to_a
end
end
18 changes: 0 additions & 18 deletions app/domain/pbs/events/filter/groups.rb

This file was deleted.

4 changes: 2 additions & 2 deletions app/views/events/courses/_buttons_pbs.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= action_button(t('event.lists.advanced_bsv_export_button'),
= action_button(t('events/courses.advanced_bsv_export_button'),
nil,
:download,
title: t('event.lists.bsv_export_button'),
title: t('events/courses.bsv_export_button'),
data: { bs_toggle: 'popover',
bs_content: render('popover_bsv_export', advanced: true).to_str })
43 changes: 21 additions & 22 deletions config/locales/views.pbs.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ de:
index:
no_data_for_this_year: Für dieses Jahr sind keine Angaben vorhanden.
infos:
census_evaluation:
Die Bestandesmeldungen für %{year} können ab dem %{start_at} erfasst werden.
census_evaluation_active:
Die aktuellen Bestandesmeldungen für %{year} können ab dem %{start_at} erfasst werden.
census_evaluation_reference_date:
Stichtag ist der %{finish_at}
census_evaluation: Die Bestandesmeldungen für %{year} können ab dem %{start_at} erfasst werden.
census_evaluation_active: Die aktuellen Bestandesmeldungen für %{year} können ab dem %{start_at} erfasst werden.
census_evaluation_reference_date: Stichtag ist der %{finish_at}
abteilung:
actions_index:
create_population_data: Aktuellen Bestand erzeugen
Expand All @@ -38,7 +35,7 @@ de:

crises:
update:
too_old: Die Krise ist zu alt um zu quittieren
too_old: Die Krise ist zu alt um zu quittieren

devise:
sessions:
Expand Down Expand Up @@ -95,17 +92,16 @@ de:
camps_abroad: Lager im Ausland
all_camps:
title: Bevorstehende Lager in der ganzen Schweiz
explanation: 'Hier werden alle Lager der gesamten PBS angezeigt, welche aktuell oder in drei oder weniger Wochen durchgeführt werden angezeigt. Dabei werden nur Lager berücksichtigt, welche eingereicht wurden und die nicht abgesagt sind.'
explanation: "Hier werden alle Lager der gesamten PBS angezeigt, welche aktuell oder in drei oder weniger Wochen durchgeführt werden angezeigt. Dabei werden nur Lager berücksichtigt, welche eingereicht wurden und die nicht abgesagt sind."
kantonalverband_camps:
title: Alle Lager im Kantonalverband %{group}
explanation: 'Hier werden alle Lager, welche innerhalb des entsprechenden Kantonalverbandes organisiert werden angezeigt. Dabei werden nur Lager berücksichtigt, welche eingereicht wurden und deren Status bestätigt oder höher ist und die nicht abgesagt sind.'
explanation: "Hier werden alle Lager, welche innerhalb des entsprechenden Kantonalverbandes organisiert werden angezeigt. Dabei werden nur Lager berücksichtigt, welche eingereicht wurden und deren Status bestätigt oder höher ist und die nicht abgesagt sind."
camps_in_canton:
title: Alle Lager im Kanton %{canton}
explanation: 'Hier werden alle Lager, welche aktuell oder in drei oder weniger Wochen im entsprechenden Kanton stattfinden angezeigt. Dabei werden nur Lager berücksichtigt, welche eingereicht wurden und deren Status bestätigt oder höher ist und die nicht abgesagt sind.'
explanation: "Hier werden alle Lager, welche aktuell oder in drei oder weniger Wochen im entsprechenden Kanton stattfinden angezeigt. Dabei werden nur Lager berücksichtigt, welche eingereicht wurden und deren Status bestätigt oder höher ist und die nicht abgesagt sind."
camps_abroad:
title: Alle Lager im Ausland
explanation: 'Hier werden alle Lager, welche im Ausland stattfinden angezeigt. Dabei werden nur Lager berücksichtigt, welche eingereicht wurden und deren Status bestätigt oder höher ist und die nicht abgesagt sind.'
advanced_bsv_export_button: Erweiterter BSV/LKB Export
explanation: "Hier werden alle Lager, welche im Ausland stattfinden angezeigt. Dabei werden nur Lager berücksichtigt, welche eingereicht wurden und deren Status bestätigt oder höher ist und die nicht abgesagt sind."
hierarchy: Lagerhierarchie

participations:
Expand Down Expand Up @@ -159,15 +155,15 @@ de:

event/camp:
al_present_info:
'true': Im Lager anwesend
'false': Nicht im Lager anwesend
"true": Im Lager anwesend
"false": Nicht im Lager anwesend
visiting_info:
at: Besucht das Lager am %{date}
'true': Besucht das Lager
'false': Besucht das Lager nicht
"true": Besucht das Lager
"false": Besucht das Lager nicht
coach_confirmed_info:
'true': Bestätigt
'false': Nicht bestätigt
"true": Bestätigt
"false": Nicht bestätigt
checkpoint_field_caption: Kann nur von dem*der Lagerleiter*in bestätigt werden

event/course:
Expand Down Expand Up @@ -198,8 +194,8 @@ de:
create_camp_application:
flash:
success: Das Lager wurde an die PBS eingereicht. Du erhältst eine Kopie des E-Mails.
error: 'Das Lager konnte nicht eingereicht werden:'
preview: 'Das Lager kann noch nicht durch den*die Coach eingereicht werden:'
error: "Das Lager konnte nicht eingereicht werden:"
preview: "Das Lager kann noch nicht durch den*die Coach eingereicht werden:"
preview_success: Es sind alle Informationen zum Einreichen des Lagers vorhanden.
expected_participants_fields:
expected_participants_help_inline: Hier wird die Anzahl TN und die Anzahl der Leiter*innen eingetragen. Sind diese Angaben noch nicht bekannt, wird die erwartete Anzahl angegeben.
Expand Down Expand Up @@ -262,8 +258,11 @@ de:
vd_title: Beachte die Sonderregelung für Lager im Kanton Waadt («Hering» -> Kantonale Sonderregelungen)
vd_url: http://hering.scouts.ch

events/courses:
advanced_bsv_export_button: Erweiterter BSV/LKB Export

filter_navigation/events:
canton: 'durchgeführt im Kanton'
canton: "durchgeführt im Kanton"

filter_navigation/camps:
all: Alle untergeordneten Lager
Expand All @@ -276,7 +275,7 @@ de:
pending_approvals:
index:
pending_title: Offene Freigaben
pending_info: 'Folgende Personen haben sich für einen Kurs angemeldet und müssen durch dich freigegeben werden:'
pending_info: "Folgende Personen haben sich für einen Kurs angemeldet und müssen durch dich freigegeben werden:"
no_pending_info: Zurzeit sind keine offenen Freigaben vorhanden.
notified_role_setting:
title: Benachrichtigungen an
Expand Down
6 changes: 4 additions & 2 deletions lib/hitobito_pbs/wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class Wagon < Rails::Engine
Bsv::Info.leader_roles += [Event::Role::Cook]
Export::Pdf::Participation.runner = Pbs::Export::Pdf::Participation::Runner
Event::ParticipantAssigner.include Pbs::Event::ParticipantAssigner
Event::Filter.include Pbs::Event::Filter
Events::Filter::Groups.include Pbs::Events::Filter::Groups
Events::Filter::GroupList.prepend Pbs::Events::Filter::GroupList
Events::Filter::CourseList.prepend Pbs::Events::Filter::CourseList
Event::Qualifier::QualifyAction.include Pbs::Event::Qualifier::QualifyAction
Export::Tabular::Events::List.include Pbs::Export::Tabular::Events::List
Export::Tabular::Events::Row.include Pbs::Export::Tabular::Events::Row
Expand Down Expand Up @@ -98,6 +98,7 @@ class Wagon < Rails::Engine
PersonAbility.include Pbs::PersonAbility
EventAbility.include Pbs::EventAbility
EventAbility.include Pbs::Event::Constraints
EventReadables.prepend Pbs::EventReadables
Event::ApplicationAbility.include Pbs::Event::ApplicationAbility
Event::ApplicationAbility.include Pbs::Event::Constraints
Event::ParticipationAbility.include Pbs::Event::ParticipationAbility
Expand Down Expand Up @@ -143,6 +144,7 @@ class Wagon < Rails::Engine
Event::ParticipationsController.include Pbs::Event::ParticipationsController
Event::QualificationsController.include Pbs::Event::QualificationsController
Event::RolesController.prepend Pbs::Event::RolesController
Events::CoursesController.prepend Pbs::Events::CoursesController
QualificationsController.include Pbs::QualificationsController
Person::QueryController.search_columns << :pbs_number
SubscriptionsController.include Pbs::SubscriptionsController
Expand Down
Loading
Loading