mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-02-22 17:12:00 +00:00
- Added `wallet_balance` field to the User model. - Updated UserAdmin to include `wallet_balance` in the admin interface. - Created serializers and views for Atoll and Island management. - Implemented endpoints for listing, creating, and updating Atolls and Islands. - Enhanced payment processing with UUIDs for Payment and Topup models. - Added migration files for new fields and constraints. - Improved error handling and validation in various views. - Updated email templates for better responsiveness and SEO.
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
"""
|
|
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, unique=True)
|
|
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, unique=True)
|
|
created_at = models.DateTimeField(default=timezone.now)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
def __str__(self):
|
|
return self.name
|