FEATURE(account): convert phone number to english numbers
convert phone number to english numbers
This commit is contained in:
parent
3dd62a0173
commit
8859fe4d20
3 changed files with 8 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ from rest_framework import serializers
|
||||||
from apps.users.models import User
|
from apps.users.models import User
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
from unidecode import unidecode
|
||||||
|
|
||||||
from utils.exceptions import UnprocessableEntity
|
from utils.exceptions import UnprocessableEntity
|
||||||
|
|
||||||
|
|
@ -62,6 +63,10 @@ class RequestOTPSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
read_only_fields = ['otp_expire', 'ttl']
|
read_only_fields = ['otp_expire', 'ttl']
|
||||||
|
|
||||||
|
def validate(self, attrs):
|
||||||
|
attrs['phone_number'] = unidecode(attrs['phone_number'])
|
||||||
|
return attrs
|
||||||
|
|
||||||
def save(self, **kwargs):
|
def save(self, **kwargs):
|
||||||
# TODO: move it to query set
|
# TODO: move it to query set
|
||||||
validated_data = self.validated_data
|
validated_data = self.validated_data
|
||||||
|
|
|
||||||
|
|
@ -22,3 +22,4 @@ django_minio_backend
|
||||||
daphne
|
daphne
|
||||||
Twisted[tls,http2]
|
Twisted[tls,http2]
|
||||||
packaging==25.0
|
packaging==25.0
|
||||||
|
unidecode
|
||||||
|
|
@ -246,3 +246,4 @@ zope-interface==8.2
|
||||||
# via
|
# via
|
||||||
# gevent
|
# gevent
|
||||||
# twisted
|
# twisted
|
||||||
|
unidecode==1.4.0
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue