Nur Vorstandsadresse als Kontakt bei Kursen und Anlässen, Version 0.4.1 🤖

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
KJV Bautzen 2026-10-09 18:03:07 +02:00
parent 26ce1112bf
commit f301d72572
9 changed files with 190 additions and 1 deletions

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
# Copyright (c) 2026, Kreisjagdverband Bautzen e.V. This file is part of
# hitobito_kjv and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory.
# Kontaktperson bei Kursen und Anlässen: nur die Vorstandsadresse anzeigen, nicht die
# private Haupt-E-Mail und keine weiteren E-Mails (siehe Kjv::VorstandEmail).
module Kjv::EventDecorator
def contact_emails(icons: true)
email = Kjv::VorstandEmail.for(contact)
return if email.blank?
icon = icons ? h.icon(:envelope, class: "me-1") : nil
h.content_tag(:p, h.safe_join([icon, h.mail_to(email)].compact, " "))
end
end

View file

@ -0,0 +1,76 @@
# frozen_string_literal: true
# Copyright (c) 2026, Kreisjagdverband Bautzen e.V. This file is part of
# hitobito_kjv and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory.
# Weitere Stellen, an denen der Core die E-Mail der Kontaktperson eines Anlasses ausgibt.
# Überall wird die Vorstandsadresse statt der privaten Haupt-E-Mail verwendet.
# Die Methoden sind Kopien der Core-Methoden mit ausgetauschter E-Mail; bei Core-Updates
# mit dem Original abgleichen.
module Kjv::EventContactEmail
# Export::Ics::Events: Beschreibung im (öffentlichen) Kalender-Feed
module IcsEvents
def event_description(event)
return event.description unless event.contact
[
event.description, "",
event.contact.person_name,
event.contact.phone_numbers.map { |pn| "#{pn.label}: #{pn.number}" if pn.public },
Kjv::VorstandEmail.for(event.contact), "",
url(event)
].flatten.compact.join("\n")
end
end
# Export::Pdf::Participation::Confirmation: Teilnahmebestätigung
module ParticipationConfirmation
def render_contact_address
text(I18n.t("event.applied_to"), style: :bold)
email = Kjv::VorstandEmail.for(contact)
pdf.bounding_box([10, cursor], width: bounds.width) do
if email
text(I18n.t("contactable.address_or_email", address: contact_address, email: email))
else
text(contact_address)
end
end
move_down_line
end
end
# Event::ParticipationMailer: Anlass-Angaben in Mails an Teilnehmende
module ParticipationMailer
def event_details # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
infos = []
infos << event.name
infos << labeled(:dates) { join_lines(event.dates.map(&:to_s)) }
infos << labeled(:motto)
infos << labeled(:cost)
infos << labeled(:description) { convert_newlines_to_breaks(event.description) }
infos << labeled(:location) { convert_newlines_to_breaks(event.location) }
infos << labeled(:contact) do
email = Kjv::VorstandEmail.for(event.contact)
email ? escape_html(event.contact) + br_tag + email : escape_html(event.contact)
end
infos << answers_details
infos << additional_information_details
infos << placeholder_participation_details
join_lines(infos.compact, br_tag * 2)
end
end
# Event::ReplyToContact: Antwortadresse (nur wenn event.use_contact_as_reply_to aktiv)
module ReplyToContact
private
def set_reply_to_from_event_contact
return unless Settings.event.use_contact_as_reply_to
email = Kjv::VorstandEmail.for(event&.contact)
message.reply_to = email if email
end
end
end

View file

@ -0,0 +1,40 @@
# frozen_string_literal: true
# Copyright (c) 2026, Kreisjagdverband Bautzen e.V. This file is part of
# hitobito_kjv and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory.
# Öffentliche Vorstandsadresse einer Person: weitere E-Mail mit der Kategorie "Vorstand".
#
# Bei Kursen und Anlässen wird für die Kontaktperson ausschließlich diese Adresse
# angezeigt bzw. weitergegeben (Kursseite, externe Anmeldung, Kalender-Feed,
# Teilnahmebestätigung, Mails). Die private Haupt-E-Mail bleibt verborgen. Hat die
# Kontaktperson keine Vorstandsadresse, erscheint keine E-Mail.
module Kjv::VorstandEmail
CATEGORY_KEY = "vorstand"
module_function
def for(person)
return if person.nil?
person = person.object if person.respond_to?(:object) # Decorator
person.additional_emails.includes(:category)
.find { |email| email.category&.key == CATEGORY_KEY }&.email.presence
end
# Für Migration und Seed
def ensure_category!
ContactAccountCategory.find_or_create_by!(
key: CATEGORY_KEY,
contact_account_type: AdditionalEmail.sti_name,
contactable_type: Person.sti_name
) do |category|
category.name = "Vorstand"
category.unique_per_contactable = true
category.position = ContactAccountCategory
.where(contact_account_type: AdditionalEmail.sti_name, contactable_type: Person.sti_name)
.maximum(:position).to_i + 1
end
end
end