Merge branch 'master' of git.mindplus-dev.ir:sahama/accounts

This commit is contained in:
Sayyid Hamid Mahdavi 2026-05-25 11:57:21 +03:30
commit 30f23c8d49
5 changed files with 76 additions and 7 deletions

View file

@ -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"]

View file

@ -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}')

View file

@ -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

View file

@ -21,4 +21,5 @@ django_redis
django_minio_backend
daphne
Twisted[tls,http2]
packaging==25.0
packaging==25.0
unidecode

View file

@ -246,3 +246,4 @@ zope-interface==8.2
# via
# gevent
# twisted
unidecode==1.4.0