mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 02:16:16 +00:00
76 lines
2.3 KiB
Python
76 lines
2.3 KiB
Python
from django.db import models
|
|
import random
|
|
from django.contrib.auth.models import User
|
|
from base.constants import USER_TYPE
|
|
# Create your models here.
|
|
|
|
class UserProfile(models.Model):
|
|
"""
|
|
User details
|
|
"""
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='user_profile')
|
|
user_type = models.CharField(max_length=15, choices=USER_TYPE, null=True, blank=True, default=None)
|
|
is_verified = models.BooleanField(default=False)
|
|
|
|
# OTP validity
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
is_active = models.BooleanField(default=False)
|
|
|
|
class Meta(object):
|
|
""" Meta information """
|
|
db_table = 'user_profile'
|
|
|
|
def __str__(self):
|
|
"""return phone as an object"""
|
|
return f'{self.user}'
|
|
|
|
class UserPhoneOtp(models.Model):
|
|
"""
|
|
This class is used to verify user email and their contact no.
|
|
"""
|
|
"""user details"""
|
|
country_code = models.IntegerField()
|
|
phone = models.CharField(max_length=17)
|
|
"""otp details"""
|
|
otp = models.CharField(max_length=10)
|
|
is_verified = models.BooleanField(default=False)
|
|
|
|
# OTP validity
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
expired_at = models.DateTimeField(blank=True, null=True)
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
class Meta(object):
|
|
""" Meta information """
|
|
db_table = 'user_phone_otp'
|
|
|
|
def __str__(self):
|
|
"""return phone as an object"""
|
|
return self.phone
|
|
|
|
class UserEmailOtp(models.Model):
|
|
"""
|
|
This class is used to verify user email and their contact no.
|
|
"""
|
|
"""user details"""
|
|
email = models.EmailField()
|
|
"""otp details"""
|
|
otp = models.CharField(max_length=10)
|
|
is_verified = models.BooleanField(default=False)
|
|
|
|
# OTP validity
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
expired_at = models.DateTimeField(blank=True, null=True)
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
class Meta(object):
|
|
""" Meta information """
|
|
db_table = 'user_email_otp'
|
|
|
|
def __str__(self):
|
|
"""return phone as an object"""
|
|
return self.email
|