SHARE
TWEET

Untitled

a guest Jun 12th, 2019 28 in 11 hours
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3.  
  4. # User profile
  5. blood_groups = ( ('A+','A+'), ('A-','A-'), ('B+','B+'), ('B-','B-'), ('AB+','AB+'), ('AB-','AB-'), ('O+','O-') )
  6. class UserProfile(models.Model):
  7.     user = models.CharField(max_length=30, related_name='UserProfile')
  8.     password = models.CharField(max_length=50)
  9.     first_name = models.CharField(max_length=100)
  10.     last_name = models.CharField(max_length=100)
  11.     age = models.IntegerField(default=0, )
  12.     guardians_name = models.CharField(max_length=200)
  13.     address = models.CharField(max_length=5000)
  14.     phone = models.IntegerField(default=0)
  15.     blood_type = models.CharField(max_length=5, choices=blood_groups, null=True, blank=False)
  16.  
  17.     def __str__(self):
  18.         return self.user.username
  19.  
  20. # Donatable organs
  21. donatable_organs = ( ('All Organs', 'All Organs'), ('Kidneys','Kidneys'), ('Liver','Liver'), ('Lungs','Lungs'), ('Heart', 'Heart'), ('Pancreas','Pancreas'), ('Intestines','Intestines'), ('Corneas','Corneas'))
  22. class Organs(models.Model):
  23.     name = models.CharField(max_length=20, choices=donatable_organs, null=True, blank=False)
  24.    
  25.     def __str__(self):
  26.         return self.name
  27.  
  28. # User pledge
  29. class Pledge(models.Model):
  30.     name = models.OneToOneField(UserProfile)
  31.     donation = models.ForeignKey(Organs, on_delete=models.CASCADE, null=True)
  32.     signature = models.FileField()
  33.    
  34.     def __str__(self):
  35.         return u'%s, %s' %(self.name, self.donation)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top