class Account(AbstractBaseUser):
email = models.EmailField(
verbose_name='email address',
max_length=255,
)
type_choice=(('Nurse','Nurse'),
('Patient','Patient')
)
account_type = models.CharField(choices=type_choice, max_length=20, null=True)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
objects = MyUserManager()
EMAIL_FIELD = 'email'
REQUIRED_FIELDS = ['email']
def __str__(self):
if self.account_type and self.email:
return str(self.email+"---->"+self.account_type)
# elif self.mobile:
# return str(self.mobile)
else:
return None
def has_perm(self, perm, obj=None):
return True
def has_module_perms(self, app_label):
return True
@property
def is_staff(self):
return self.is_admin
class Nurse(models.Model):
account=models.ForeignKey(Account,on_delete=models.CASCADE,max_length=50,blank=True,null=True)
name = models.CharField(max_length=255, null=False)
nurseid = models.CharField(max_length=255, null=False)
hospital = models.CharField(max_length=255, null=False)
speciality = models.CharField(max_length=255, null=False)
country = models.CharField(max_length=255, null=False)
city = models.CharField(max_length=255, null=False)
accesscode = models.CharField(max_length=255, null=False)
mobile = models.CharField(max_length=255, null=False)
created_date = models.DateTimeField(auto_now=True)
modified_date = models.DateTimeField(auto_now=True)
def __str__(self):
return str(self.account)