from django.db import models from django.utils.translation import gettext_lazy as _ from lib.models.base import MetaDataModel from apps.hospital.models import Hospital # Create your models here. class Polyclinic(MetaDataModel): """ A model that holds the polyclinic information. This is just basic information just for getting in contact. It will inherit the attributes :attr:`~lib.models.base.MetaDataModel.created_at` and :attr:`~lib.models.base.MetaDataModel.updated_at` from the Abstract model :class:`~lib.models.base.MetaDataModel` Attributes ---------- hospital : Hospital The hospital where this polyclinic belongs to. name : str The name of the polyclinic. Max length is 200 characters. phone : str The general/direct phone number of this polyclinic. Max length is 20 characters. """ class Meta: verbose_name = _('polyclinic') verbose_name_plural = _('polyclinics') hospital = models.ForeignKey(Hospital, on_delete=models.CASCADE, help_text=_('To which hospital belongs this polyclinic')) name = models.CharField(_('Name'), max_length=200, blank=True, help_text=_('The name of this polyclinic')) phone = models.CharField(_('Phone number'), max_length=20, blank=True, help_text=_('The general/direct phone number of this polyclinic')) def __str__(self): """str: Returns a readable name for the polyclinic. Format is [polyclinic_name] ([hospital_name]).""" return '{} ({})'.format(self.name, self.hospital)