From 7dfcbfe38fd87a66fcbfa5218760e4c3d10d11bb Mon Sep 17 00:00:00 2001 From: moanos Date: Mon, 23 Jun 2025 19:21:33 +0200 Subject: [PATCH] feat: Add catogories, FN, website and GEO --- .../templates/fellchensammlung/contacts.vcf | 12 ++++++++---- src/fellchensammlung/tools/admin.py | 5 +++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/fellchensammlung/templates/fellchensammlung/contacts.vcf b/src/fellchensammlung/templates/fellchensammlung/contacts.vcf index ca97ba6..feda788 100644 --- a/src/fellchensammlung/templates/fellchensammlung/contacts.vcf +++ b/src/fellchensammlung/templates/fellchensammlung/contacts.vcf @@ -1,9 +1,13 @@ {% for contact in contacts %} BEGIN:VCARD VERSION:4.0 -N:{{contact.name}};;;; -TEL;TYPE=work:{{ contact.phone_number }} +N:{{contact.name|safe}};;;; +FN:{{contact.name|safe}} +{% if contact.location %}GEO:geo:{{contact.location.latitude}},{{contact.location.longitude}} +{% endif %}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 +{% endif %}REV:{{ current_time|date:'Ymd' }}T{{ current_time|date:'His' }}Z +CATEGORIES:{{ categories }} +{% if contact.website %}URL:{{ contact.website }} +{% endif %}END:VCARD {% endfor %} \ No newline at end of file diff --git a/src/fellchensammlung/tools/admin.py b/src/fellchensammlung/tools/admin.py index c205755..ed05460 100644 --- a/src/fellchensammlung/tools/admin.py +++ b/src/fellchensammlung/tools/admin.py @@ -118,9 +118,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()}) + context={"contacts": rescue_orgs, + "current_time": timezone.now(), + "categories": "Tierheim"}) filename = "contacts.vcf" with open(filename, "w") as f: f.write(result) print(f"Wrote {len(rescue_orgs)} contacts to {filename}") -