feat: Add initial support for contacts

This commit is contained in:
2025-06-23 18:38:15 +02:00
parent c3ec477a6e
commit cd8471036c
4 changed files with 17 additions and 1 deletions

View File

@@ -116,7 +116,6 @@ class RescueOrgeGeoJSONSerializer(serializers.ModelSerializer):
return None
class AnimalCreateSerializer(serializers.ModelSerializer):
class Meta:
model = Animal

View File

@@ -1,4 +1,5 @@
from django.core.management import BaseCommand
from fellchensammlung.tools.admin import export_orgs_as_vcf

View File

@@ -0,0 +1,9 @@
{% for contact in contacts %}
BEGIN:VCARD
VERSION:4.0
N:{{contact.name}};;;;
TEL;TYPE=work:{{ contact.phone_number }}
{% if contact.email %}EMAIL:{{ contact.email }}
{% endif %}REV:{{ current_time|date:'Ymd' }}T{{ current_time|date:'His' }}T
END:VCARD
{% endfor %}

View File

@@ -4,6 +4,7 @@ from django.utils import timezone
from datetime import timedelta
from django_super_deduper.merge import MergedModelInstance
from django.template.loader import render_to_string
from fellchensammlung.models import AdoptionNotice, Location, RescueOrganization, AdoptionNoticeStatus, Log, \
AdoptionNoticeNotification
@@ -116,4 +117,10 @@ def dedup_locations():
def export_orgs_as_vcf():
rescue_orgs = RescueOrganization.objects.filter(phone_number__isnull=False)
result = render_to_string(template_name="fellchensammlung/contacts.vcf",
context={"contacts": rescue_orgs, "current_time": timezone.now()})
filename = "contacts.vcf"
with open(filename, "w") as f:
f.write(result)
print(f"Wrote {len(rescue_orgs)} contacts to {filename}")