class OrderedService(models.Model): """A paid for service request to the service organization""" ordered_by = models.ForeignKey(Consumer, on_delete=models.CASCADE, null=True) service = models.OneToOneField(HealthierService, on_delete=models.CASCADE, null=True) provided_by = models.ForeignKey(Provider, on_delete=models.CASCADE, blank=True, null=True) payment_status = models.BooleanField(default=False) order_id = models.CharField(max_length=200, default=generate_id("order")) promo_code = models.CharField(max_length=200) order_date = models.DateTimeField(auto_now=False, default=now) price = MoneyField(currency='NGN', decimal_places=2, max_digits=12, default=0.00) cancellation_time = models.CharField(default='', max_length=50) arrival_time = models.CharField(default='', max_length=50) arrival_date = models.CharField(default='', max_length=50) members = JSONField(default='', max_length=300) comment = models.TextField(default='', max_length=1000) is_active = models.BooleanField(default=True) confirmed = models.BooleanField(default=False) def __str__(self): """Return a string representation of the model.""" return "Service Ordered by : {0}".format(self.ordered_by_id)
class Family(models.Model): head = models.ForeignKey(HealthierUser, on_delete=models.CASCADE, related_name="family_head") image = models.ImageField(upload_to=None, height_field=None, width_field=None, max_length=100, null=True, blank=True) username = models.CharField(_('Username'), blank=True, max_length=50) phone_number = models.CharField(max_length=200) description = models.TextField(max_length=1000, blank=True) healthier_id = models.CharField( max_length=50, default=generate_id("healthier_family_member"), blank=True) email = models.EmailField(unique=True) active = models.BooleanField(default=True) added_on = models.DateField(default=now, blank=False) def __unicode__(self): return self.username def __str__(self): return self.username
class Consumer(models.Model): """Organization providing health services and sending reports to users""" healthier_id = models.OneToOneField(HealthierUser, on_delete=models.CASCADE, related_name="consumer_details") healthier_consumer_id = models.CharField(blank=False, max_length=30, default=generate_id("consumer")) def __str__(self): return "Consumer with email: {0}".format(self.healthier_id.email)
class HealthierUser(AbstractBaseUser, PermissionsMixin): def get_full_name(self): return str(self.username) def get_short_name(self): return str(self.username) email = models.EmailField(unique=True) objects = HealthierUserManager() account_choices = ( ('PRO', 'Provider'), ('CON', 'Consumer'), ) account_type = models.CharField(max_length=3, choices=account_choices) image = models.ImageField(upload_to=user_directory_path, height_field=None, width_field=None, max_length=100, null=True, blank=True) address = models.CharField(max_length=100) description = models.TextField(max_length=1000, blank=True) city = models.CharField(max_length=200) phone_number = models.CharField(max_length=200) website = models.URLField(blank=True, null=True) username = models.CharField(_('Username'), blank=True, max_length=50) is_staff = models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status') is_admin = models.BooleanField(_('Admin'), default=False) is_active = models.BooleanField(_('Active'), default=True) groups = models.ManyToManyField(blank=True, help_text='The groups this hospital belongs to. ' 'An hospital will get all permissions granted to ' 'each of their groups.', related_name='hospital_set', related_query_name='hospital', to='auth.Group', verbose_name='groups') is_logged_in = models.BooleanField(_('Logged In'), default=False) is_superuser = models.BooleanField(_('Superuser'), default=True) has_configured_account = models.BooleanField(_('Has Configured Account'), default=False) total_money = MoneyField(currency='NGN', decimal_places=2, max_digits=12, default=0.00) healthier_id = models.CharField(max_length=50, default=generate_id("healthier_user"), blank=True) first_name = models.CharField(_('First Name'), max_length=200, blank=True) last_name = models.CharField(_('Last Name'), max_length=200, blank=True) bank_account_name = models.CharField(_('Bank Account Name'), max_length=400, blank=True) bank_name = models.CharField(_('Bank Name'), max_length=500, blank=True) bank_account_number = models.CharField(_('Account Number'), max_length=30, blank=True) def __unicode__(self): return self.username USERNAME_FIELD = 'email' REQUIRED_FIELD = ['account_type'] @property def image_url(self): if self.image and hasattr(self.image, 'url'): return self.image.url
class HealthierService(models.Model): group = models.ForeignKey(ServiceGroup, on_delete=models.CASCADE, blank=True, null=True) service_name = models.CharField(max_length=200) details = models.CharField(max_length=1000, blank=False, default='') service_id = models.CharField(max_length=200, default=generate_id("service")) orders = models.IntegerField(default=0) views = models.IntegerField(default=0) def __str__(self): return self.service_name