mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-06-28 09:50:05 +00:00
Initial commit
This commit is contained in:
46
api/models.py
Normal file
46
api/models.py
Normal file
@ -0,0 +1,46 @@
|
||||
"""
|
||||
This is the models module for api.
|
||||
"""
|
||||
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.db import models
|
||||
from .managers import CustomUserManager
|
||||
from django.utils import timezone
|
||||
|
||||
class User(AbstractUser):
|
||||
email = models.EmailField(unique=True, blank=True, null=True)
|
||||
address = models.CharField(max_length=255, blank=True)
|
||||
mobile = models.CharField(max_length=255, blank=True)
|
||||
designation = models.CharField(max_length=255, blank=True)
|
||||
acc_no = models.CharField(max_length=255, blank=True)
|
||||
id_card = models.CharField(max_length=255, blank=True)
|
||||
verified = models.BooleanField(default=False)
|
||||
dob = models.DateField(blank=True, null=True)
|
||||
terms_accepted = models.BooleanField(default=False)
|
||||
policy_accepted = models.BooleanField(default=False)
|
||||
wallet_balance = models.FloatField(default=0.0)
|
||||
ninja_user_id = models.CharField(max_length=255, blank=True)
|
||||
atoll = models.ForeignKey('Atoll', on_delete=models.SET_NULL, null=True, blank=True, related_name='users')
|
||||
island = models.ForeignKey('Island', on_delete=models.SET_NULL, null=True, blank=True, related_name='users')
|
||||
def get_all_fields(self, instance):
|
||||
return [field.name for field in instance.get_fields()]
|
||||
|
||||
objects = CustomUserManager()
|
||||
|
||||
|
||||
class Atoll(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
created_at = models.DateTimeField(default=timezone.now)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Island(models.Model):
|
||||
atoll = models.ForeignKey(Atoll, on_delete=models.CASCADE, related_name='islands')
|
||||
name = models.CharField(max_length=255)
|
||||
created_at = models.DateTimeField(default=timezone.now)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
Reference in New Issue
Block a user