mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 18:07:02 +00:00
133 lines
5.1 KiB
Python
133 lines
5.1 KiB
Python
"""Guardian model file"""
|
|
"""Third party Django app"""
|
|
from django.db import models
|
|
from django.contrib.auth import get_user_model
|
|
"""Import Django app"""
|
|
from base.constants import GENDERS, TASK_STATUS, PENDING, TASK_POINTS, SIGNUP_METHODS
|
|
"""import Junior model"""
|
|
from junior.models import Junior
|
|
"""Add user model"""
|
|
User = get_user_model()
|
|
|
|
# Create your models here.
|
|
# Define junior model with
|
|
# various fields like
|
|
# phone, country code,
|
|
# country name,
|
|
# gender,
|
|
# date of birth,
|
|
# profile image,
|
|
# signup method,
|
|
# guardian code,
|
|
# referral code,
|
|
# referral code that used by the guardian
|
|
# is invited guardian
|
|
# profile is active or not
|
|
# profile is complete or not
|
|
# passcode
|
|
# guardian is verified or not
|
|
"""Define junior task model"""
|
|
# define name of the Task
|
|
# task description
|
|
# points of the task
|
|
# default image of the task
|
|
# image uploaded by junior
|
|
# task status
|
|
# task approved or not
|
|
|
|
# Create your models here.
|
|
|
|
class Guardian(models.Model):
|
|
"""Guardian model"""
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='guardian_profile', verbose_name='Email')
|
|
"""Contact details"""
|
|
country_code = models.IntegerField(blank=True, null=True)
|
|
phone = models.CharField(max_length=31, null=True, blank=True, default=None)
|
|
"""country name of the guardian"""
|
|
country_name = models.CharField(max_length=100, null=True, blank=True, default=None)
|
|
"""Image info"""
|
|
image = models.URLField(null=True, blank=True, default=None)
|
|
"""Personal info"""
|
|
family_name = models.CharField(max_length=50, null=True, blank=True, default=None)
|
|
"""gender of the guardian"""
|
|
gender = models.CharField(choices=GENDERS, max_length=15, null=True, blank=True, default=None)
|
|
"""date of birth of the guardian"""
|
|
dob = models.DateField(max_length=15, null=True, blank=True, default=None)
|
|
"""Profile activity"""
|
|
is_active = models.BooleanField(default=True)
|
|
"""guardian is verified or not"""
|
|
is_verified = models.BooleanField(default=False)
|
|
"""guardian profile is complete or not"""
|
|
is_complete_profile = models.BooleanField(default=False)
|
|
"""passcode of the guardian profile"""
|
|
passcode = models.IntegerField(null=True, blank=True, default=None)
|
|
"""Sign up method"""
|
|
signup_method = models.CharField(max_length=31, choices=SIGNUP_METHODS, default='1')
|
|
"""Guardian Codes"""
|
|
guardian_code = models.CharField(max_length=10, null=True, blank=True, default=None)
|
|
"""Referral code"""
|
|
referral_code = models.CharField(max_length=10, null=True, blank=True, default=None)
|
|
"""Referral code that is used by guardian while signup"""
|
|
referral_code_used = models.CharField(max_length=10, null=True, blank=True, default=None)
|
|
"""Profile created and updated time"""
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta(object):
|
|
""" Meta class """
|
|
db_table = 'guardians'
|
|
"""verbose name of the model"""
|
|
verbose_name = 'Guardian'
|
|
"""change another name"""
|
|
verbose_name_plural = 'Guardian'
|
|
|
|
def __str__(self):
|
|
"""Return email id"""
|
|
return f'{self.user}'
|
|
|
|
class JuniorTask(models.Model):
|
|
"""Junior Task details model"""
|
|
guardian = models.ForeignKey(Guardian, on_delete=models.CASCADE, related_name='guardian', verbose_name='Guardian')
|
|
"""task details"""
|
|
task_name = models.CharField(max_length=100)
|
|
"""task description"""
|
|
task_description = models.CharField(max_length=500)
|
|
"""points of the task"""
|
|
points = models.IntegerField(default=TASK_POINTS)
|
|
"""last date of the task"""
|
|
due_date = models.DateField(auto_now_add=False, null=True, blank=True)
|
|
"""Images of task that is upload by guardian"""
|
|
default_image = models.URLField(null=True, blank=True, default=None)
|
|
"""image that is uploaded by junior"""
|
|
image = models.URLField(null=True, blank=True, default=None)
|
|
"""associated junior with the task"""
|
|
junior = models.ForeignKey(Junior, on_delete=models.CASCADE, related_name='junior', verbose_name='Junior')
|
|
"""task status"""
|
|
task_status = models.CharField(choices=TASK_STATUS, max_length=15, default=PENDING)
|
|
"""task is active or not"""
|
|
is_active = models.BooleanField(default=True)
|
|
"""Task is approved or not"""
|
|
is_approved = models.BooleanField(default=False)
|
|
"""request task on particular date"""
|
|
requested_on = models.DateTimeField(auto_now_add=False, null=True, blank=True)
|
|
"""reject task on particular date"""
|
|
rejected_on = models.DateTimeField(auto_now_add=False, null=True, blank=True)
|
|
"""complete task on particular date"""
|
|
completed_on = models.DateTimeField(auto_now_add=False, null=True, blank=True)
|
|
"""Profile created and updated time"""
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
updated_at = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta(object):
|
|
""" Meta class """
|
|
db_table = 'junior_task'
|
|
"""verbose name of the model"""
|
|
verbose_name = 'Junior Task'
|
|
verbose_name_plural = 'Junior Task'
|
|
|
|
def __str__(self):
|
|
"""Return email id"""
|
|
return f'{self.task_name}'
|
|
|
|
|