Untitled
unknown
plain_text
a year ago
3.0 kB
10
Indexable
from django.db import models
# Create your models here.
class User(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
password = models.TextField()
class BloodDonor(models.Model):
BLOOD_GROUP_CHOICES = [
('A+', 'A+'),
('A-', 'A-'),
('B+', 'B+'),
('B-', 'B-'),
('AB+', 'AB+'),
('AB-', 'AB-'),
('O+', 'O+'),
('O-', 'O-'),
]
name = models.CharField(max_length=100)
age = models.IntegerField()
gender = models.CharField(max_length=10)
blood_group = models.CharField(max_length=3, choices=BLOOD_GROUP_CHOICES)
contact_number = models.CharField(max_length=15)
email = models.EmailField(unique=True)
address = models.TextField()
last_donation_date = models.DateField()
class BloodRecipient(models.Model):
BLOOD_GROUP_CHOICES = [
('A+', 'A+'),
('A-', 'A-'),
('B+', 'B+'),
('B-', 'B-'),
('AB+', 'AB+'),
('AB-', 'AB-'),
('O+', 'O+'),
('O-', 'O-'),
]
name = models.CharField(max_length=100)
age = models.IntegerField()
gender = models.CharField(max_length=10)
blood_group = models.CharField(max_length=3, choices=BLOOD_GROUP_CHOICES)
contact_number = models.CharField(max_length=15)
email = models.EmailField(unique=True)
address = models.TextField()
required_blood_group = models.CharField(max_length=3, choices=BLOOD_GROUP_CHOICES)
request_date = models.DateField()
class BloodInventory(models.Model):
BLOOD_GROUP_CHOICES = [
('A+', 'A+'),
('A-', 'A-'),
('B+', 'B+'),
('B-', 'B-'),
('AB+', 'AB+'),
('AB-', 'AB-'),
('O+', 'O+'),
('O-', 'O-'),
]
blood_group = models.CharField(max_length=3, choices=BLOOD_GROUP_CHOICES)
units_available = models.PositiveIntegerField()
last_updated = models.DateTimeField(auto_now=True)
class Donation(models.Model):
donor = models.ForeignKey(BloodDonor, on_delete=models.CASCADE)
blood_group = models.CharField(max_length=3, choices=BloodDonor.BLOOD_GROUP_CHOICES)
units_donated = models.PositiveIntegerField()
donation_date = models.DateField(auto_now_add=True)
def __str__(self):
return f"Donor: {self.donor.name}, Blood Group: {self.blood_group}, Units: {self.units_donated}"
class BloodRequest(models.Model):
recipient = models.ForeignKey(BloodRecipient, on_delete=models.CASCADE)
blood_group = models.CharField(max_length=3, choices=BloodRecipient.BLOOD_GROUP_CHOICES)
units_requested = models.PositiveIntegerField()
request_date = models.DateField(auto_now_add=True)
status = models.BooleanField(default=False)
def __str__(self):
return f"Recipient: {self.recipient.name}, Blood Group: {self.blood_group}, Units: {self.units_requested}"
Editor is loading...
Leave a Comment