diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ef3363..74e45b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # hitobito_kjv Changelog +## 0.4.1 + +- E-Mail-Kategorie „Vorstand“; bei Kursen und Anlässen ist von der Kontaktperson nur noch + die Vorstandsadresse sichtbar (Kursseite, Kalender-Feed, Teilnahmebestätigung, Mails) + ## 0.4.0 - Gruppen- und Rollenstruktur nach Satzung 2024: Vorstand mit Vorsitzendem, Stellvertreter, diff --git a/README.md b/README.md index aef9418..8505c56 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,18 @@ Rollentypen definiert dieser Wagon (`app/models/group/`, `app/models/role/`); (Präsident → Vorsitzender, Kassier → Schatzmeister, Aktivmitglied → Verbandsmitglied, Vorstandsmitglied/Sekretär → Vorstandsmitglied) und die Sortiertabellen neu befüllt. +## Vorstandsadresse bei Kursen und Anlässen + +Bei Kursen und Anlässen ist von der Kontaktperson öffentlich nur ihre **Vorstandsadresse** +sichtbar: eine weitere E-Mail mit der Kategorie „Vorstand“ (Profil bearbeiten → Weitere +E-Mails → Kategorie „Vorstand“, je Person höchstens eine). Die private Haupt-E-Mail und +andere weitere E-Mails erscheinen dort nicht. Hat die Kontaktperson keine Vorstandsadresse, +wird keine E-Mail angezeigt. + +Das gilt für Kursseite und externe Anmeldung, den öffentlichen Kalender-Feed (ICS), die +Teilnahmebestätigung (PDF), die Bestätigungs-Mails an Teilnehmende und die Antwortadresse +(falls `event.use_contact_as_reply_to` aktiv ist). Zentrale Stelle: `Kjv::VorstandEmail`. + ## Beitragsstatus und Mitgliedsausweis ### Gültigkeit und Beitrag @@ -245,6 +257,9 @@ Diese Stellen hängen an Interna des Cores und sollten bei Updates geprüft werd - `Kjv::PeopleHelper#sortable_grouped_person_attr`, `Kjv::CsvImportHelper`, `Kjv::CsvImportsController#field_mappings` und `Kjv::PersonFilterList` überschreiben Core-Methoden. +- Vorstandsadresse: `Kjv::EventDecorator#contact_emails` sowie die Kopien in + `Kjv::EventContactEmail` (ICS-Beschreibung, Teilnahmebestätigung, Mail-Anlassangaben, + Antwortadresse) überschreiben Core-Methoden; bei Updates mit dem Original abgleichen. - Mitgliedsausweis: kommt aus `hitobito_verifiable_pass`, das am Pass-System des Cores hängt. Bei Updates von Core oder diesem Wagon Prüfseite, „Mein Ausweis“ und Sammel-PDF kurz testen. Neue Commits von `hitobito_verifiable_pass` in `VERSIONS` eintragen. diff --git a/app/decorators/kjv/event_decorator.rb b/app/decorators/kjv/event_decorator.rb new file mode 100644 index 0000000..30cdeb7 --- /dev/null +++ b/app/decorators/kjv/event_decorator.rb @@ -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 diff --git a/app/domain/kjv/event_contact_email.rb b/app/domain/kjv/event_contact_email.rb new file mode 100644 index 0000000..d7acbf2 --- /dev/null +++ b/app/domain/kjv/event_contact_email.rb @@ -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 diff --git a/app/domain/kjv/vorstand_email.rb b/app/domain/kjv/vorstand_email.rb new file mode 100644 index 0000000..022af0f --- /dev/null +++ b/app/domain/kjv/vorstand_email.rb @@ -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 diff --git a/db/migrate/20261009170000_add_vorstand_email_category.rb b/db/migrate/20261009170000_add_vorstand_email_category.rb new file mode 100644 index 0000000..858e524 --- /dev/null +++ b/db/migrate/20261009170000_add_vorstand_email_category.rb @@ -0,0 +1,21 @@ +# 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. + +# Kategorie "Vorstand" für weitere E-Mails (öffentliche Vorstandsadresse, siehe +# Kjv::VorstandEmail). Nur in bestehenden Installationen; bei einer neuen Installation +# legt sie der Seed nach den Core-Kategorien an (der Core-Seeder läuft nur, solange noch +# keine Kategorie existiert). +class AddVorstandEmailCategory < ActiveRecord::Migration[8.0] + def up + return unless ContactAccountCategory.exists? + + Kjv::VorstandEmail.ensure_category! + end + + def down + # Kategorie bleibt bestehen, damit zugeordnete Adressen nicht ihre Kategorie verlieren + end +end diff --git a/db/seeds/vorstand_email_category.rb b/db/seeds/vorstand_email_category.rb new file mode 100644 index 0000000..f7dea04 --- /dev/null +++ b/db/seeds/vorstand_email_category.rb @@ -0,0 +1,8 @@ +# 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. + +# Kategorie "Vorstand" für weitere E-Mails (siehe Kjv::VorstandEmail) +Kjv::VorstandEmail.ensure_category! if ContactAccountCategory.exists? diff --git a/lib/hitobito_kjv/version.rb b/lib/hitobito_kjv/version.rb index f7d6fa0..238ffdb 100644 --- a/lib/hitobito_kjv/version.rb +++ b/lib/hitobito_kjv/version.rb @@ -5,5 +5,5 @@ # or later. See the COPYING file at the top-level directory. module HitobitoKjv - VERSION = "0.4.0" + VERSION = "0.4.1" end diff --git a/lib/hitobito_kjv/wagon.rb b/lib/hitobito_kjv/wagon.rb index 5fbe832..1388da9 100644 --- a/lib/hitobito_kjv/wagon.rb +++ b/lib/hitobito_kjv/wagon.rb @@ -45,6 +45,13 @@ module HitobitoKjv StandardFormBuilder.prepend Kjv::StandardFormBuilder CsvImportHelper.prepend Kjv::CsvImportHelper PeopleHelper.prepend Kjv::PeopleHelper + EventDecorator.prepend Kjv::EventDecorator + + ### Kontaktperson bei Anlässen: nur Vorstandsadresse (Kjv::VorstandEmail) + Export::Ics::Events.prepend Kjv::EventContactEmail::IcsEvents + Export::Pdf::Participation::Confirmation.prepend Kjv::EventContactEmail::ParticipationConfirmation + Event::ParticipationMailer.prepend Kjv::EventContactEmail::ParticipationMailer + Event::ReplyToContact.prepend Kjv::EventContactEmail::ReplyToContact ### domain Export::Tabular::People::PeopleAddress.prepend Kjv::Export::Tabular::People::PeopleAddress