From 8859fe4d2073c701f42a6bf58e98db308564360a Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Mon, 18 May 2026 11:37:58 +0330 Subject: [PATCH 1/3] FEATURE(account): convert phone number to english numbers convert phone number to english numbers --- apps/users/serializers.py | 5 +++++ requirements.in | 3 ++- requirements.txt | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/users/serializers.py b/apps/users/serializers.py index e4bf1cc..82e13be 100644 --- a/apps/users/serializers.py +++ b/apps/users/serializers.py @@ -5,6 +5,7 @@ from rest_framework import serializers from apps.users.models import User from django.utils import timezone from django.utils.translation import gettext_lazy as _ +from unidecode import unidecode from utils.exceptions import UnprocessableEntity @@ -62,6 +63,10 @@ class RequestOTPSerializer(serializers.ModelSerializer): read_only_fields = ['otp_expire', 'ttl'] + def validate(self, attrs): + attrs['phone_number'] = unidecode(attrs['phone_number']) + return attrs + def save(self, **kwargs): # TODO: move it to query set validated_data = self.validated_data diff --git a/requirements.in b/requirements.in index ccc7cf9..9caa867 100644 --- a/requirements.in +++ b/requirements.in @@ -21,4 +21,5 @@ django_redis django_minio_backend daphne Twisted[tls,http2] -packaging==25.0 \ No newline at end of file +packaging==25.0 +unidecode \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 1eb7ad6..ebd29a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -246,3 +246,4 @@ zope-interface==8.2 # via # gevent # twisted +unidecode==1.4.0 From 706de574273abd745c89deeec0507c832be7ed0d Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Wed, 20 May 2026 13:08:56 +0330 Subject: [PATCH 2/3] Fix(accounts): Dockerfile Dockerfile --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 298a33a..9e378fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM debian:13 +FROM base:debian13 ENV PYTHONUNBUFFERED 1 WORKDIR /app -RUN apt update -RUN apt install gnupg2 netcat-traditional libssl-dev libcrypto++-dev lsb-release python3-pip -y -COPY requirements.txt /app/requirements.txt -RUN pip3 install --break-system-packages -r requirements.txt -RUN pip3 install --break-system-packages setuptools +#RUN apt update +#RUN apt install gnupg2 netcat-traditional libssl-dev libcrypto++-dev lsb-release python3-pip -y +#COPY requirements.txt /app/requirements.txt +#RUN pip3 install --break-system-packages -r requirements.txt +#RUN pip3 install --break-system-packages setuptools #ENTRYPOINT ["./run.sh"] From 43b5ba9028a3190ed85d99ea6e9142b06c06a980 Mon Sep 17 00:00:00 2001 From: Haydar Ghasemi Date: Sat, 23 May 2026 13:55:47 +0330 Subject: [PATCH 3/3] Fix(accounts): send sms send sms --- .../commands/send_sms_by_uuid_list.py | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 apps/users/management/commands/send_sms_by_uuid_list.py diff --git a/apps/users/management/commands/send_sms_by_uuid_list.py b/apps/users/management/commands/send_sms_by_uuid_list.py new file mode 100644 index 0000000..ede31b5 --- /dev/null +++ b/apps/users/management/commands/send_sms_by_uuid_list.py @@ -0,0 +1,62 @@ +from apps.users.models import * +from django.contrib.gis.geos import Point, Polygon +import random +import os + + +from django.core.management.base import BaseCommand, CommandError + +class Command(BaseCommand): + help = "send sms by uuid list" + + def add_arguments(self, parser): + parser.add_argument('message_file', type=str, help='Message as a file') + parser.add_argument('uuids_file', type=str, help='File with one UUID per line') + + def handle(self, *args, **options): + print(options['message_file']) + print(options['uuids_file']) + message_file_path = options['message_file'] + uuids_file_path = options['uuids_file'] + + if not os.path.exists(message_file_path): + raise CommandError(f'File "{message_file_path}" does not exist') + + if not os.path.exists(uuids_file_path): + raise CommandError(f'File "{uuids_file_path}" does not exist') + + uuids = [] + invalid_lines = [] + message: str = '''''' + + with open(message_file_path, 'r', encoding='utf-8') as f: + message = f.read() + + with open(uuids_file_path, 'r', encoding='utf-8') as f: + for line_num, line in enumerate(f, 1): + line = line.strip() + if not line: # Skip empty lines + continue + try: + # Validate and normalize UUID + valid_uuid = str(uuid.UUID(line)) + uuids.append(valid_uuid) + self.stdout.write(f'Line {line_num}: ✓ {valid_uuid}') + except (ValueError, AttributeError, TypeError): + invalid_lines.append((line_num, line)) + self.stdout.write( + self.style.ERROR(f'Line {line_num}: ✗ Invalid UUID "{line}"') + ) + + sms_client = SMSPolicy.get_client() + users = User.objects.filter(uuid__in=uuids) + empty_phone_numbers = list(filter(lambda u: not u.phone_number, users)) + if empty_phone_numbers: + logger.error(f'not exist phone numbers for following uuids') + print(empty_phone_numbers) + logger.error(f'end of not exist phone numbers') + return + for user in users: + logger.info(f'try to send message for: {user.uuid} and {user.phone_number}') + # sms_client.send_sms(user.phone_number.strip('+'), message) + logger.info(f'sent message for: {user.uuid} and {user.phone_number}')