Add notification settings and forms for email notifications
This commit is contained in:
parent
93f5f05a33
commit
bb8949af76
19 changed files with 435 additions and 23 deletions
28
app/bird/migrations/0007_add_notification_settings.py
Normal file
28
app/bird/migrations/0007_add_notification_settings.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Generated manually for notification settings
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bird', '0006_alter_fallenbird_options_alter_fallenbird_age_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='bird',
|
||||
name='melden_an_naturschutzbehoerde',
|
||||
field=models.BooleanField(default=True, verbose_name='Melden an Naturschutzbehörde'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='bird',
|
||||
name='melden_an_jagdbehoerde',
|
||||
field=models.BooleanField(default=False, verbose_name='Melden an Jagdbehörde'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='bird',
|
||||
name='melden_an_wildvogelhilfe_team',
|
||||
field=models.BooleanField(default=True, verbose_name='Melden an Wildvogelhilfe-Team'),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,41 @@
|
|||
# Data migration to set defaults for existing Bird records
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def set_default_notification_settings(apps, schema_editor):
|
||||
"""Set default notification settings for all existing Bird records."""
|
||||
Bird = apps.get_model('bird', 'Bird')
|
||||
|
||||
# Update all existing birds to have the default notification settings
|
||||
Bird.objects.all().update(
|
||||
melden_an_naturschutzbehoerde=True,
|
||||
melden_an_wildvogelhilfe_team=True,
|
||||
melden_an_jagdbehoerde=False
|
||||
)
|
||||
|
||||
|
||||
def reverse_default_notification_settings(apps, schema_editor):
|
||||
"""Reverse the default settings if needed."""
|
||||
Bird = apps.get_model('bird', 'Bird')
|
||||
|
||||
# Reset all notification settings to False
|
||||
Bird.objects.all().update(
|
||||
melden_an_naturschutzbehoerde=False,
|
||||
melden_an_wildvogelhilfe_team=False,
|
||||
melden_an_jagdbehoerde=False
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bird', '0007_add_notification_settings'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
set_default_notification_settings,
|
||||
reverse_default_notification_settings
|
||||
),
|
||||
]
|
14
app/bird/migrations/0009_merge_20250609_2033.py
Normal file
14
app/bird/migrations/0009_merge_20250609_2033.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
# Generated by Django 5.2.2 on 2025-06-09 18:33
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('bird', '0007_alter_fallenbird_status'),
|
||||
('bird', '0008_set_default_notification_settings'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue