From 042ac399960acbffc7cbd29c41178cea0e30dbcc Mon Sep 17 00:00:00 2001 From: Luca Vari Date: Mon, 9 Dec 2024 15:18:27 +1100 Subject: [PATCH 1/3] Keep staging AWS S3 buckets in sync with production Specifically we sync the AWS S3 audio bucket when restoring staging from production. The audio bucket contains recording used by the call centre. --- app/scripts/tasks/staging-restore.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/app/scripts/tasks/staging-restore.sh b/app/scripts/tasks/staging-restore.sh index e4e7d829..70f79fbc 100755 --- a/app/scripts/tasks/staging-restore.sh +++ b/app/scripts/tasks/staging-restore.sh @@ -29,6 +29,7 @@ aws s3 sync --acl public-read s3://anika-clerk/action-documents s3://anika-clerk aws s3 sync --acl public-read s3://anika-clerk/documents s3://anika-clerk-test/documents aws s3 sync --acl public-read s3://anika-clerk/images s3://anika-clerk-test/images aws s3 sync --acl public-read s3://anika-clerk/original_images s3://anika-clerk-test/original_images +aws s3 sync --acl public-read s3://anika-twilio-audio s3://anika-twilio-audio-test echo -e "\nRunning migrations" ./manage.py migrate From d04437ea2db5e098c4954b22915d4630f1a275ce Mon Sep 17 00:00:00 2001 From: Luca Vari Date: Fri, 13 Dec 2024 13:11:37 +1100 Subject: [PATCH 2/3] Removed unused import --- app/core/management/commands/obfuscate_data.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/core/management/commands/obfuscate_data.py b/app/core/management/commands/obfuscate_data.py index 0d728413..57a51929 100644 --- a/app/core/management/commands/obfuscate_data.py +++ b/app/core/management/commands/obfuscate_data.py @@ -1,7 +1,6 @@ import logging import os from io import BytesIO -from random import randint from accounts.models import CaseGroups, User from core.models import Client, FileUpload, Issue, IssueNote, Person, Service, Tenancy @@ -12,8 +11,8 @@ from django.db import transaction from django.db.models import Q from emails.models import Email, EmailAttachment -from utils.signals import disable_signals, restore_signals from faker import Faker +from utils.signals import disable_signals, restore_signals logger = logging.getLogger(__name__) From 43124ddcd2c105628414f2f08375c969462363d4 Mon Sep 17 00:00:00 2001 From: Luca Vari Date: Fri, 13 Dec 2024 13:13:00 +1100 Subject: [PATCH 3/3] Add django management command to export client info for backup Provide client-related info in an easily accessible format to be included with backups and used for disaster recovery. See https://linear.app/anika-legal/issue/TEC-1423/ --- .../management/commands/export_client_info.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 app/core/management/commands/export_client_info.py diff --git a/app/core/management/commands/export_client_info.py b/app/core/management/commands/export_client_info.py new file mode 100644 index 00000000..a4a984fa --- /dev/null +++ b/app/core/management/commands/export_client_info.py @@ -0,0 +1,37 @@ +import csv +import sys +import re + +from core.models import Issue +from django.core.management.base import BaseCommand + +fields = [ + "fileref", + "client__first_name", + "client__last_name", + "topic", + "created_at", + "is_open", + "stage", + "provided_legal_services", + "client__email", + "client__phone_number", + "tenancy__address", + "tenancy__suburb", + "tenancy__postcode", +] + + +class Command(BaseCommand): + help = "Output client information as CSV" + + def handle(self, *args, **kwargs): + values = ( + Issue.objects.select_related("client", "tenancy") + .values(*fields) + .order_by("-created_at") + ) + writer = csv.DictWriter(sys.stdout, fieldnames=fields) + header = dict(zip(fields, [ re.sub('^\w+__', '', x) for x in fields ])) + writer.writerow(header) + writer.writerows(values.iterator())