Add Anrede field to Destinatär model (STI-86)
Adds optional salutation (Herr/Frau/Divers) to the Destinatär model with migration, form support, admin integration and template display. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,7 +24,7 @@ class DestinataerAdmin(admin.ModelAdmin):
|
||||
fieldsets = (
|
||||
(
|
||||
"Persönliche Daten",
|
||||
{"fields": ("vorname", "nachname", "geburtsdatum", "email", "telefon")},
|
||||
{"fields": ("anrede", "vorname", "nachname", "geburtsdatum", "email", "telefon")},
|
||||
),
|
||||
(
|
||||
"Berufliche Informationen",
|
||||
|
||||
@@ -54,18 +54,14 @@ class DestinataerForm(forms.ModelForm):
|
||||
for field_name, field in self.fields.items():
|
||||
if field_name not in ["vorname", "nachname"]:
|
||||
field.required = False
|
||||
# Set choices for familienzweig and berufsgruppe to match model
|
||||
# Set choices for familienzweig, berufsgruppe and anrede to match model
|
||||
self.fields["familienzweig"].choices = [("", "Bitte wählen...")] + list(Destinataer.FAMILIENZWIG_CHOICES)
|
||||
self.fields["berufsgruppe"].choices = [("", "Bitte wählen...")] + list(Destinataer.BERUFSGRUPPE_CHOICES)
|
||||
if "anrede" in self.fields:
|
||||
self.fields["anrede"].choices = [("", "Bitte wählen...")] + list(Destinataer.ANREDE_CHOICES)
|
||||
# Set choices for standard_konto to allow blank
|
||||
self.fields["standard_konto"].empty_label = "---"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
for field_name, field in self.fields.items():
|
||||
if field_name not in ["vorname", "nachname"]:
|
||||
field.required = False
|
||||
|
||||
|
||||
class DestinataerUnterstuetzungForm(forms.ModelForm):
|
||||
"""Form für geplante/ausgeführte Destinatärunterstützungen"""
|
||||
|
||||
18
app/stiftung/migrations/0063_add_anrede_to_destinataer.py
Normal file
18
app/stiftung/migrations/0063_add_anrede_to_destinataer.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.0.6 on 2026-03-21 21:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('stiftung', '0062_veranstaltungseinladung_vorlage'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='destinataer',
|
||||
name='anrede',
|
||||
field=models.CharField(blank=True, choices=[('Herr', 'Herr'), ('Frau', 'Frau'), ('Divers', 'Divers')], max_length=20, null=True, verbose_name='Anrede'),
|
||||
),
|
||||
]
|
||||
@@ -26,7 +26,20 @@ class Destinataer(models.Model):
|
||||
("andere", "Andere"),
|
||||
]
|
||||
|
||||
ANREDE_CHOICES = [
|
||||
("Herr", "Herr"),
|
||||
("Frau", "Frau"),
|
||||
("Divers", "Divers"),
|
||||
]
|
||||
|
||||
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
anrede = models.CharField(
|
||||
max_length=20,
|
||||
choices=ANREDE_CHOICES,
|
||||
blank=True,
|
||||
null=True,
|
||||
verbose_name="Anrede",
|
||||
)
|
||||
familienzweig = models.CharField(
|
||||
max_length=100, choices=FAMILIENZWIG_CHOICES, blank=True, null=True
|
||||
)
|
||||
|
||||
@@ -157,6 +157,18 @@
|
||||
<div class="card-body py-2">
|
||||
<table class="table table-sm table-borderless mb-0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="text-muted" style="width:140px;">Anrede</td>
|
||||
<td>
|
||||
<span class="view-mode">{{ destinataer.anrede|default:"-" }}</span>
|
||||
<select name="anrede" class="form-select form-select-sm edit-mode" style="display:none;">
|
||||
<option value="">---</option>
|
||||
<option value="Herr" {% if destinataer.anrede == 'Herr' %}selected{% endif %}>Herr</option>
|
||||
<option value="Frau" {% if destinataer.anrede == 'Frau' %}selected{% endif %}>Frau</option>
|
||||
<option value="Divers" {% if destinataer.anrede == 'Divers' %}selected{% endif %}>Divers</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-muted" style="width:140px;">Vorname</td>
|
||||
<td>
|
||||
|
||||
@@ -48,6 +48,13 @@
|
||||
<div class="card-body py-2">
|
||||
<table class="table table-sm table-borderless mb-0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="text-muted" style="width:140px;">Anrede</td>
|
||||
<td>
|
||||
{{ form.anrede }}
|
||||
{% if form.anrede.errors %}<div class="invalid-feedback d-block">{{ form.anrede.errors.0 }}</div>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="text-muted" style="width:140px;">Vorname *</td>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user