add test number
This commit is contained in:
parent
ba858baa85
commit
b8a57a0ce4
3 changed files with 26 additions and 14 deletions
|
|
@ -11,7 +11,7 @@ https://docs.djangoproject.com/en/5.0/ref/settings/
|
|||
"""
|
||||
|
||||
from pathlib import Path
|
||||
from decouple import config
|
||||
from decouple import config, Csv
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
|
|
@ -274,7 +274,12 @@ PAYAM_SMS_USERNAME = config('PAYAM_SMS_USERNAME')
|
|||
PAYAM_SMS_PASSWORD = config('PAYAM_SMS_PASSWORD')
|
||||
PAYAM_SMS_CLIENT_ID = config('PAYAM_SMS_CLIENT_ID')
|
||||
PAYAM_SMS_CLIENT_SECRET = config('PAYAM_SMS_CLIENT_SECRET')
|
||||
|
||||
|
||||
SMS_OTP_SIGNITURE = config('SMS_OTP_SIGNITURE', '')
|
||||
SMS_SEND=config('SMS_SEND', True, cast=bool)
|
||||
TEST_PHONENUMBERS=config('TEST_PHONENUMBERS', [], cast=Csv(post_process=list))
|
||||
|
||||
|
||||
CACHES = {
|
||||
"default": {
|
||||
|
|
@ -352,7 +357,6 @@ STORAGES = {
|
|||
],
|
||||
"MINIO_POLICY_HOOKS": [],
|
||||
"MINIO_BUCKET_CHECK_ON_SAVE": True # Default: True // Creates bucket if missing, then save
|
||||
|
||||
},
|
||||
},
|
||||
"staticfiles": {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import logging
|
||||
import random
|
||||
import string
|
||||
from datetime import timedelta
|
||||
|
|
@ -22,6 +23,8 @@ from .provinces_and_cities import state
|
|||
from apps.users.constans import MAX_OTP_TRY, DEVELOPMENT_PHONE_NUMBERS, GenderChoices, EducationDegreeChoices, \
|
||||
MAX_OTP_VALID_DURATION
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class UserManager(BaseUserManager):
|
||||
use_in_migrations = True
|
||||
|
|
@ -161,7 +164,9 @@ class User(AbstractUser):
|
|||
if self.otp_expire and (self.otp_expire + timedelta(seconds=MAX_OTP_VALID_DURATION)) > timezone.now():
|
||||
raise Exception(_('otp expire time not reached.'))
|
||||
|
||||
if self.phone_number == '+989965419352':
|
||||
if not settings.SMS_SEND:
|
||||
self._otp = '77501'
|
||||
elif self.phone_number in settings.TEST_PHONENUMBERS:
|
||||
self._otp = '88555'
|
||||
else:
|
||||
self._otp = ''.join(random.choice('0123456789') for _ in range(5))
|
||||
|
|
@ -245,7 +250,10 @@ class User(AbstractUser):
|
|||
# # f"code is: {body}\n"
|
||||
# f"{settings.SMS_OTP_SIGNITURE}"
|
||||
)
|
||||
if settings.SMS_SEND:
|
||||
send_sms(self.phone_number.strip('+'), message)
|
||||
else:
|
||||
logger.info(f'otp for: {self.phone_number} is {message}')
|
||||
return
|
||||
# TODO: enable celery
|
||||
send_notification(
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# This file is autogenerated by pip-compile with Python 3.13
|
||||
# by the following command:
|
||||
#
|
||||
# pip-compile --cert=None --client-cert=None --index-url=None --pip-args=None
|
||||
# pip-compile
|
||||
#
|
||||
amqp==5.3.1
|
||||
# via kombu
|
||||
|
|
@ -58,7 +58,7 @@ constantly==23.10.4
|
|||
# via twisted
|
||||
crispy-bootstrap5==2025.6
|
||||
# via -r requirements.in
|
||||
cryptography==46.0.4
|
||||
cryptography==46.0.5
|
||||
# via
|
||||
# autobahn
|
||||
# jwcrypto
|
||||
|
|
@ -80,7 +80,7 @@ django==6.0.2
|
|||
# django-redis
|
||||
# djangorestframework
|
||||
# drf-spectacular
|
||||
django-betterforms==2.0.0
|
||||
django-betterforms==3.0.0
|
||||
# via -r requirements.in
|
||||
django-cors-headers==4.9.0
|
||||
# via -r requirements.in
|
||||
|
|
@ -106,9 +106,9 @@ drf-spectacular==0.29.0
|
|||
# via -r requirements.in
|
||||
gevent==25.9.1
|
||||
# via -r requirements.in
|
||||
greenlet==3.3.1
|
||||
greenlet==3.3.2
|
||||
# via gevent
|
||||
gunicorn==25.0.2
|
||||
gunicorn==25.1.0
|
||||
# via -r requirements.in
|
||||
h2==4.3.0
|
||||
# via twisted
|
||||
|
|
@ -141,7 +141,7 @@ jwcrypto==1.5.6
|
|||
# via django-oauth-toolkit
|
||||
kombu==5.6.2
|
||||
# via celery
|
||||
markdown==3.10.1
|
||||
markdown==3.10.2
|
||||
# via -r requirements.in
|
||||
minio==7.2.20
|
||||
# via django-minio-backend
|
||||
|
|
@ -155,7 +155,7 @@ packaging==25.0
|
|||
# gunicorn
|
||||
# incremental
|
||||
# kombu
|
||||
pillow==12.1.0
|
||||
pillow==12.1.1
|
||||
# via
|
||||
# -r requirements.in
|
||||
# django-minio-backend
|
||||
|
|
@ -163,9 +163,9 @@ priority==1.3.0
|
|||
# via twisted
|
||||
prompt-toolkit==3.0.52
|
||||
# via click-repl
|
||||
psycopg[binary,pool]==3.3.2
|
||||
psycopg[binary,pool]==3.3.3
|
||||
# via -r requirements.in
|
||||
psycopg-binary==3.3.2
|
||||
psycopg-binary==3.3.3
|
||||
# via psycopg
|
||||
psycopg-pool==3.3.0
|
||||
# via psycopg
|
||||
|
|
@ -189,7 +189,7 @@ python-decouple==3.8
|
|||
# via -r requirements.in
|
||||
pyyaml==6.0.3
|
||||
# via drf-spectacular
|
||||
redis==7.1.0
|
||||
redis==7.2.0
|
||||
# via
|
||||
# -r requirements.in
|
||||
# django-redis
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue